]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/corefoundation/gsockosx.cpp
more checks for non-scrolling windows, some code duplication cleanup
[wxWidgets.git] / src / mac / corefoundation / gsockosx.cpp
index 0d2915900e276095515bd2c6b803685cbe5d07b3..ac4da2300e9e9e70b1fcecb8373f0e6741a7659f 100644 (file)
@@ -1,12 +1,12 @@
 /* -------------------------------------------------------------------------
  * Project: GSocket (Generic Socket) for WX
- * Name:    gsockosx.c
+ * Name:    src/mac/corefoundation/gsockosx.c
  * Purpose: GSocket: Mac OS X mach-o part
  * CVSID:   $Id$
  * Mac code by Brian Victor, February 2002.  Email comments to bhv1@psu.edu
  * ------------------------------------------------------------------------- */
 
-#include "wx/setup.h"
+#include "wx/wxprec.h"
 
 #if wxUSE_SOCKETS
 
@@ -39,7 +39,14 @@ void Mac_Socket_Callback(CFSocketRef s, CFSocketCallBackType callbackType,
   {
     case kCFSocketConnectCallBack:
       assert(!socket->m_server);
-      socket->Detected_Write();
+      // KH: If data is non-NULL, the connect failed, do not call Detected_Write,
+      // which will only end up creating a spurious connect event because the
+      // call to getsocketopt SO_ERROR inexplicably returns no error.
+      // The change in behavior cannot be traced to any particular commit or
+      // timeframe so I'm not sure what to think, but after so many hours,
+      // this seems to address the issue and it's time to move on.
+      if (data == NULL)
+        socket->Detected_Write();
       break;
     case kCFSocketReadCallBack:
       socket->Detected_Read();
@@ -68,7 +75,7 @@ struct MacGSocketData* _GSocket_Get_Mac_Socket(GSocket *socket)
   cont.info = socket;
 
   CFSocketRef cf = CFSocketCreateWithNative(NULL, socket->m_fd,
-                       ALL_CALLBACK_TYPES, Mac_Socket_Callback, &cont);
+                   ALL_CALLBACK_TYPES, Mac_Socket_Callback, &cont);
   CFRunLoopSourceRef source = CFSocketCreateRunLoopSource(NULL, cf, 0);
   assert(source);
   socket->m_gui_dependent = (char*)data;
@@ -123,6 +130,8 @@ void GSocketGUIFunctionsTableConcrete::Destroy_Socket(GSocket *socket)
     struct MacGSocketData *data = (struct MacGSocketData*)(socket->m_gui_dependent);
     if (data)
     {
+        if ( data->source )
+            CFRelease(data->source);
         if ( data->socket )
             CFRelease(data->socket);
         free(data);