From 251e98cb7313462485e9e36ab900fbed51a40871 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 17 Aug 2009 23:02:18 +0000 Subject: [PATCH] Added wxFDIOHandler::IsOk() and use it with wxSocketImplUnix. This will allow to use the base wxFDIOHandler class only in GUI-specific network code and this remove its dependency on wxSocketImplUnix. IOW it paves the way for a proper solution of the problem fixed by r61336 without the hack of r61335 which results in linking problems (which went undiscovered until now but were, in fact, always present, i.e. r61335 couldn't work). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61685 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/private/fdiodispatcher.h | 4 ++++ include/wx/unix/private/sockunix.h | 1 + src/gtk/sockgtk.cpp | 2 +- src/gtk1/sockgtk.cpp | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/wx/private/fdiodispatcher.h b/include/wx/private/fdiodispatcher.h index f37e0217a4..bc372926dd 100644 --- a/include/wx/private/fdiodispatcher.h +++ b/include/wx/private/fdiodispatcher.h @@ -26,6 +26,10 @@ public: // called when there is exception on descriptor virtual void OnExceptionWaiting() = 0; + // called to check if the handler is still valid, only used by + // wxSocketImplUnix currently + virtual bool IsOk() const { return true; } + // virtual dtor for the base class virtual ~wxFDIOHandler() { } }; diff --git a/include/wx/unix/private/sockunix.h b/include/wx/unix/private/sockunix.h index a5832a9443..4b8f80afe3 100644 --- a/include/wx/unix/private/sockunix.h +++ b/include/wx/unix/private/sockunix.h @@ -52,6 +52,7 @@ public: virtual void OnReadWaiting(); virtual void OnWriteWaiting(); virtual void OnExceptionWaiting(); + virtual bool IsOk() const { return m_fd != INVALID_SOCKET; } // Unix-specific functions used by wxSocketFDIOManager only bool HasAnyEnabledCallbacks() const { return m_enabledCallbacks != 0; } diff --git a/src/gtk/sockgtk.cpp b/src/gtk/sockgtk.cpp index c8d449cfd8..7c0ed5c27d 100644 --- a/src/gtk/sockgtk.cpp +++ b/src/gtk/sockgtk.cpp @@ -37,7 +37,7 @@ void wxSocket_GDK_Input(gpointer data, // we could have lost connection while reading in which case we // shouldn't call OnWriteWaiting() as the socket is now closed and it // would assert - if ( handler->m_fd == INVALID_SOCKET ) + if ( !handler->IsOk() ) return; } diff --git a/src/gtk1/sockgtk.cpp b/src/gtk1/sockgtk.cpp index c8d449cfd8..7c0ed5c27d 100644 --- a/src/gtk1/sockgtk.cpp +++ b/src/gtk1/sockgtk.cpp @@ -37,7 +37,7 @@ void wxSocket_GDK_Input(gpointer data, // we could have lost connection while reading in which case we // shouldn't call OnWriteWaiting() as the socket is now closed and it // would assert - if ( handler->m_fd == INVALID_SOCKET ) + if ( !handler->IsOk() ) return; } -- 2.45.2