]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed bug for late events arriving after connections had been destroyed
authorGuillermo Rodriguez Garcia <guille@iies.es>
Fri, 17 Mar 2000 15:09:18 +0000 (15:09 +0000)
committerGuillermo Rodriguez Garcia <guille@iies.es>
Fri, 17 Mar 2000 15:09:18 +0000 (15:09 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6798 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/sckipc.cpp

index 28284b2695361e7746f6f82fd9fc68492ba00f34..f577b046f35a7ba33a7225d3c88c242d8fbb16fd 100644 (file)
@@ -191,7 +191,7 @@ wxConnectionBase *wxTCPClient::MakeConnection (const wxString& host,
 
 wxConnectionBase *wxTCPClient::OnMakeConnection()
 {
-  return new wxTCPConnection;
+  return new wxTCPConnection();
 }
 
 // --------------------------------------------------------------------------
@@ -251,7 +251,11 @@ wxTCPConnection::~wxTCPConnection ()
   wxDELETE(m_codeco);
   wxDELETE(m_sockstrm);
 
-  if (m_sock) m_sock->Destroy();
+  if (m_sock)
+  {
+    m_sock->SetClientData(NULL);
+    m_sock->Destroy();
+  }
 }
 
 void wxTCPConnection::Compress(bool WXUNUSED(on))
@@ -407,6 +411,10 @@ void wxTCPEventHandler::Client_OnRequest(wxSocketEvent &event)
   wxSocketNotify evt = event.GetSocketEvent();
   wxTCPConnection *connection = (wxTCPConnection *)(event.GetClientData());
 
+  // This socket is being deleted; skip this event
+  if (!connection)
+    return;
+
   int msg = 0;
   wxDataInputStream *codeci;
   wxDataOutputStream *codeco; 
@@ -414,7 +422,7 @@ void wxTCPEventHandler::Client_OnRequest(wxSocketEvent &event)
   wxString topic_name = connection->m_topic;
   wxString item;
 
-  // The socket handler signals us that we lost the connection: destroy all.
+  // We lost the connection: destroy everything
   if (evt == wxSOCKET_LOST)
   {
     sock->Notify(FALSE);
@@ -549,6 +557,10 @@ void wxTCPEventHandler::Server_OnRequest(wxSocketEvent &event)
   wxSocketServer *server = (wxSocketServer *) event.GetSocket();
   wxTCPServer *ipcserv = (wxTCPServer *) event.GetClientData();
 
+  // This socket is being deleted; skip this event
+  if (!ipcserv)
+    return;
+
   if (event.GetSocketEvent() != wxSOCKET_CONNECTION)
     return;