From 83a7ab5c711237d32068cce4c82b7e16808d5614 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 23 Nov 2008 13:17:49 +0000 Subject: [PATCH] fix wxSocket notifications under MSW after the last change git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56935 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gsocket.h | 7 ++++--- src/msw/gsockmsw.cpp | 13 ++----------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/include/wx/gsocket.h b/include/wx/gsocket.h index 4d1c621596..d2fc0d07dd 100644 --- a/include/wx/gsocket.h +++ b/include/wx/gsocket.h @@ -179,6 +179,10 @@ public: virtual void Close() = 0; virtual void Shutdown(); + // notify m_wxsocket about the given socket event by calling its (inaptly + // named) OnRequest() method + void NotifyOnStateChange(GSocketEvent event); + // this is officially SOCKET (unsigned int) under Windows but we don't want // to include winsock.h which defines SOCKET from here so just use int // under all platforms @@ -210,9 +214,6 @@ public: protected: GSocketBase(wxSocketBase& wxsocket); - // notify m_wxsocket - void NotifyOnStateChange(GSocketEvent event); - private: // set in ctor and never changed except that it's reset to NULL when the // socket is shut down diff --git a/src/msw/gsockmsw.cpp b/src/msw/gsockmsw.cpp index 3ca8b48349..1975b983a0 100644 --- a/src/msw/gsockmsw.cpp +++ b/src/msw/gsockmsw.cpp @@ -387,9 +387,6 @@ LRESULT CALLBACK _GSocket_Internal_WinProc(HWND hWnd, if (event != -1) { - cback = socket->m_cbacks[event]; - data = socket->m_data[event]; - if (event == GSOCK_LOST) socket->m_detected = GSOCK_LOST_FLAG; else @@ -397,16 +394,10 @@ LRESULT CALLBACK _GSocket_Internal_WinProc(HWND hWnd, } } - /* OK, we can now leave the critical section because we have - * already obtained the callback address (we make no further - * accesses to socket->whatever). However, the app should - * be prepared to handle events from a socket that has just - * been closed! - */ LeaveCriticalSection(&critical); - if (cback != NULL) - (cback)(socket, event, data); + if ( socket ) + socket->NotifyOnStateChange(event); return (LRESULT) 0; }