]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/core/sockosx.cpp
Applying patch #10784: eliminate gauge flicker
[wxWidgets.git] / src / osx / core / sockosx.cpp
index fcd10dbc6ea1826a666ea2f44b122ef69f2b46e9..0b6b77d0e195ef7a1f90c04fd7d83c7b06a6fc27 100644 (file)
@@ -16,6 +16,9 @@
 #include "wx/private/socket.h"
 #include "wx/unix/private/sockunix.h"
 #include "wx/apptrait.h"
+#include "wx/link.h"
+
+#include "wx/osx/core/cfstring.h"           // for wxMacWakeUp() only
 
 #include <CoreFoundation/CoreFoundation.h>
 
@@ -75,7 +78,10 @@ private:
         CFSocketInvalidate(m_socket);
 
         CFRelease(m_source);
+        m_source = NULL;
+
         CFRelease(m_socket);
+        m_socket = NULL;
     }
 
     // initialize the data associated with the given socket
@@ -110,6 +116,8 @@ private:
         if ( !m_source )
         {
             CFRelease(m_socket);
+            m_socket = NULL;
+
             return false;
         }
 
@@ -151,6 +159,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;
@@ -271,4 +286,7 @@ static struct OSXManagerSetter
     }
 } gs_OSXManagerSetter;
 
+// see the relative linker macro in socket.cpp
+wxFORCE_LINK_THIS_MODULE( osxsocket );
+
 #endif // wxUSE_SOCKETS