From e5b502f3a610d5d72b0fb6ca4b9cf9034d0d271b Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Garcia Date: Fri, 17 Mar 2000 15:09:18 +0000 Subject: [PATCH] Fixed bug for late events arriving after connections had been destroyed git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6798 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/sckipc.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/common/sckipc.cpp b/src/common/sckipc.cpp index 28284b2695..f577b046f3 100644 --- a/src/common/sckipc.cpp +++ b/src/common/sckipc.cpp @@ -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;