]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/sockmsw.cpp
Do not propagate key events from child controls unless they have modifiers
[wxWidgets.git] / src / msw / sockmsw.cpp
index 33ce4ab540fc43388e06e9b74b4a09dabcba4419..bfac07191c6a6ed9a9a425301e4a03a81d7626bc 100644 (file)
@@ -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<wxSocketImplMSW *>(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);
 }