X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c9bccf239c1506c7eea0bddea44d9e4b76ad1d93..79cb759dc8580da2e82e880cd94a08cd38bb814e:/src/msw/sockmsw.cpp diff --git a/src/msw/sockmsw.cpp b/src/msw/sockmsw.cpp index 33ce4ab540..bfac07191c 100644 --- a/src/msw/sockmsw.cpp +++ b/src/msw/sockmsw.cpp @@ -179,8 +179,10 @@ public: { return new wxSocketImplMSW(wxsocket); } - virtual void Install_Callback(wxSocketImpl *socket, wxSocketNotify event); - virtual void Uninstall_Callback(wxSocketImpl *socket, wxSocketNotify event); + virtual void Install_Callback(wxSocketImpl *socket, + wxSocketNotify event = wxSOCKET_LOST); + virtual void Uninstall_Callback(wxSocketImpl *socket, + wxSocketNotify event = wxSOCKET_LOST); private: static wxDynamicLibrary gs_wsock32dll; @@ -325,6 +327,11 @@ LRESULT CALLBACK wxSocket_Internal_WinProc(HWND hWnd, if ( !socket ) return 0; + // the socket may be already closed but we could still receive + // notifications for it sent (asynchronously) before it got closed + if ( socket->m_fd == INVALID_SOCKET ) + return 0; + wxASSERT_MSG( socket->m_fd == (SOCKET)wParam, "mismatch between message and socket?" ); @@ -402,7 +409,7 @@ void wxSocketMSWManager::Install_Callback(wxSocketImpl *socket_, * Disable event notifications (used when shutting down the socket) */ void wxSocketMSWManager::Uninstall_Callback(wxSocketImpl *socket_, - wxSocketNotify WXUNUSED(event)) + wxSocketNotify WXUNUSED(event)) { wxSocketImplMSW * const socket = static_cast(socket_); @@ -442,8 +449,7 @@ wxSocketImpl *wxSocketImpl::Create(wxSocketBase& wxsocket) void wxSocketImplMSW::DoClose() { - wxSocketManager::Get()-> - Uninstall_Callback(this, wxSOCKET_MAX_EVENT /* unused anyhow */); + wxSocketManager::Get()->Uninstall_Callback(this); closesocket(m_fd); }