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
This commit is contained in:
Guillermo Rodriguez Garcia 2000-03-17 15:09:18 +00:00
parent bc1dcfc1aa
commit e5b502f3a6

View File

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