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:
parent
bc1dcfc1aa
commit
e5b502f3a6
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user