]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/socket.cpp
Add new unix bots.
[wxWidgets.git] / src / common / socket.cpp
index 000d89b4648c4371bbacb81f1523136f917d2f3b..09324181ae35d32b9a041a1fece18e4dd1c158d0 100644 (file)
@@ -115,7 +115,7 @@ wxDEFINE_EVENT(wxEVT_SOCKET, wxSocketEvent);
 // discard buffer
 #define MAX_DISCARD_SIZE (10 * 1024)
 
-#define wxTRACE_Socket _T("wxSocket")
+#define wxTRACE_Socket wxT("wxSocket")
 
 // --------------------------------------------------------------------------
 // wxWin macros
@@ -771,7 +771,7 @@ bool wxSocketBase::Initialize()
 void wxSocketBase::Shutdown()
 {
     // we should be initialized
-    wxASSERT_MSG( m_countInit > 0, _T("extra call to Shutdown()") );
+    wxASSERT_MSG( m_countInit > 0, wxT("extra call to Shutdown()") );
     if ( --m_countInit == 0 )
     {
         wxSocketManager * const manager = wxSocketManager::Get();
@@ -841,12 +841,6 @@ wxSocketBase::wxSocketBase(wxSocketFlags flags, wxSocketType type)
 
 wxSocketBase::~wxSocketBase()
 {
-    // Just in case the app called Destroy() *and* then deleted the socket
-    // immediately: don't leave dangling pointers.
-    wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
-    if ( traits )
-        traits->RemoveFromPendingDelete(this);
-
     // Shutdown and close the socket
     if (!m_beingDeleted)
         Close();
@@ -855,8 +849,7 @@ wxSocketBase::~wxSocketBase()
     delete m_impl;
 
     // Free the pushback buffer
-    if (m_unread)
-        free(m_unread);
+    free(m_unread);
 }
 
 bool wxSocketBase::Destroy()
@@ -872,14 +865,13 @@ bool wxSocketBase::Destroy()
     // Suppress events from now on
     Notify(false);
 
-    // schedule this object for deletion
-    wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
-    if ( traits )
+    // Schedule this object for deletion instead of destroying it right now if
+    // possible as we may have other events pending for it
+    if ( wxTheApp )
     {
-        // let the traits object decide what to do with us
-        traits->ScheduleForDestroy(this);
+        wxTheApp->ScheduleForDestruction(this);
     }
-    else // no app or no traits
+    else // no app
     {
         // in wxBase we might have no app object at all, don't leak memory
         delete this;
@@ -1745,13 +1737,13 @@ wxSocketServer::wxSocketServer(const wxSockAddress& addr,
                                wxSocketFlags flags)
               : wxSocketBase(flags, wxSOCKET_SERVER)
 {
-    wxLogTrace( wxTRACE_Socket, _T("Opening wxSocketServer") );
+    wxLogTrace( wxTRACE_Socket, wxT("Opening wxSocketServer") );
 
     m_impl = wxSocketImpl::Create(*this);
 
     if (!m_impl)
     {
-        wxLogTrace( wxTRACE_Socket, _T("*** Failed to create m_impl") );
+        wxLogTrace( wxTRACE_Socket, wxT("*** Failed to create m_impl") );
         return;
     }
 
@@ -1773,11 +1765,11 @@ wxSocketServer::wxSocketServer(const wxSockAddress& addr,
         delete m_impl;
         m_impl = NULL;
 
-        wxLogTrace( wxTRACE_Socket, _T("*** CreateServer() failed") );
+        wxLogTrace( wxTRACE_Socket, wxT("*** CreateServer() failed") );
         return;
     }
 
-    wxLogTrace( wxTRACE_Socket, _T("wxSocketServer on fd %d"), m_impl->m_fd );
+    wxLogTrace( wxTRACE_Socket, wxT("wxSocketServer on fd %d"), m_impl->m_fd );
 }
 
 // --------------------------------------------------------------------------
@@ -1843,7 +1835,7 @@ bool wxSocketServer::WaitForAccept(long seconds, long milliseconds)
 
 bool wxSocketBase::GetOption(int level, int optname, void *optval, int *optlen)
 {
-    wxASSERT_MSG( m_impl, _T("Socket not initialised") );
+    wxASSERT_MSG( m_impl, wxT("Socket not initialised") );
 
     SOCKOPTLEN_T lenreal = *optlen;
     if ( getsockopt(m_impl->m_fd, level, optname,
@@ -1858,7 +1850,7 @@ bool wxSocketBase::GetOption(int level, int optname, void *optval, int *optlen)
 bool
 wxSocketBase::SetOption(int level, int optname, const void *optval, int optlen)
 {
-    wxASSERT_MSG( m_impl, _T("Socket not initialised") );
+    wxASSERT_MSG( m_impl, wxT("Socket not initialised") );
 
     return setsockopt(m_impl->m_fd, level, optname,
                       static_cast<const char *>(optval), optlen) == 0;
@@ -2032,7 +2024,7 @@ wxDatagramSocket& wxDatagramSocket::SendTo( const wxSockAddress& addr,
                                             const void* buf,
                                             wxUint32 nBytes )
 {
-    wxASSERT_MSG( m_impl, _T("Socket not initialised") );
+    wxASSERT_MSG( m_impl, wxT("Socket not initialised") );
 
     m_impl->SetPeer(addr.GetAddress());
     Write(buf, nBytes);