discard any pending messages for the socket being destroyed to avoid the problem with having them delivered to the next socket we create which reuses the same message number (patch 1856012)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@50893 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-12-22 14:05:25 +00:00
parent 7d840762c6
commit 9b3fbee03e
2 changed files with 17 additions and 1 deletions

View File

@@ -112,6 +112,10 @@ All (Unix):
- Fixed shared libraries do not depend on GStreamer when built with
--enable-media; only wxMedia library depends on it now.
wxMSW:
- Fix rare bug with messages delivered to wrong wxSocket (Tim Kosse)
wxGTK:

View File

@@ -336,7 +336,19 @@ void GSocketGUIFunctionsTableConcrete::Destroy_Socket(GSocket *socket)
/* Remove the socket from the list */
EnterCriticalSection(&critical);
if ( socket->IsOk() )
socketList[(socket->m_msgnumber - WM_USER)] = NULL;
{
const int msgnum = socket->m_msgnumber;
// we need to remove any pending messages for this socket to avoid having
// them sent to a new socket which could reuse the same message number as
// soon as we destroy this one
MSG msg;
while ( ::PeekMessage(&msg, hWin, msgnum, msgnum, PM_REMOVE) )
;
socketList[msgnum - WM_USER] = NULL;
}
LeaveCriticalSection(&critical);
}