]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix hangups when using sockets under OS X.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 16 Aug 2009 23:14:07 +0000 (23:14 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 16 Aug 2009 23:14:07 +0000 (23:14 +0000)
A socket event apparently doesn't count as a real event under OS X and our
wxEventLoop::DispatchTimeout() doesn't return when it happens -- so we need to
generate an artificial wake up event ourselves to make it do it and return
control to the code in wxSocket::DoWait() in order for it to process the event.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61678 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/osx/core/sockosx.cpp

index d19c7ef9016e40213cc7e888f366c6b9b0143273..6a5928bbb876114fd3f4d5959068f712da91e8cd 100644 (file)
@@ -17,6 +17,8 @@
 #include "wx/unix/private/sockunix.h"
 #include "wx/apptrait.h"
 
+#include "wx/osx/core/cfstring.h"           // for wxMacWakeUp() only
+
 #include <CoreFoundation/CoreFoundation.h>
 
 namespace
@@ -156,6 +158,13 @@ private:
             default:
                 wxFAIL_MSG( "unexpected socket callback" );
         }
+
+        // receiving a socket event does _not_ make ReceiveNextEvent() (or the
+        // equivalent NSApp:nextEventMatchingMask:untilDate:inMode:dequeue)
+        // return control, i.e. apparently it doesn't count as a real event, so
+        // we need to generate a wake up to return control to the code waiting
+        // for something to happen and process this socket event
+        wxMacWakeUp();
     }
 
     CFSocketRef m_socket;