]> git.saurik.com Git - wxWidgets.git/commitdiff
ensure correct linking of the socket manager initializer for static builds of wxWidgets
authorFrancesco Montorsi <f18m_cpp217828@yahoo.it>
Mon, 12 Jan 2009 23:14:17 +0000 (23:14 +0000)
committerFrancesco Montorsi <f18m_cpp217828@yahoo.it>
Mon, 12 Jan 2009 23:14:17 +0000 (23:14 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58059 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/socket.cpp
src/common/socketiohandler.cpp
src/unix/sockunix.cpp

index 3d5338425be32f65ff34dd18b2c921be401bcc8e..ede71ebcf13cffcf31bcdd02a0193d16a79cacfe 100644 (file)
@@ -42,6 +42,7 @@
 #include "wx/stopwatch.h"
 #include "wx/thread.h"
 #include "wx/evtloop.h"
+#include "wx/link.h"
 
 #include "wx/private/fd.h"
 #include "wx/private/socket.h"
@@ -769,7 +770,8 @@ void wxSocketBase::Init()
     {
         // this Initialize() will be undone by wxSocketModule::OnExit(), all
         // the other calls to it should be matched by a call to Shutdown()
-        Initialize();
+        if (!Initialize())
+            wxLogError("Cannot initialize wxSocketBase");
     }
 }
 
@@ -1988,4 +1990,9 @@ private:
 
 IMPLEMENT_DYNAMIC_CLASS(wxSocketModule, wxModule)
 
+// NOTE: we need to force linking against socketiohandler.cpp otherwise in
+//       static builds of wxWidgets the ManagerSetter::ManagerSetter ctor
+//       contained there wouldn't be ever called
+wxFORCE_LINK_MODULE( socketiohandler )
+
 #endif // wxUSE_SOCKETS
index 89f8edafee05d75fd4452040920062c76c8f5822..080532be0f8cb2191c12eff39dc1603f892a965e 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "wx/apptrait.h"
 #include "wx/private/socket.h"
+#include "wx/link.h"
 
 // ============================================================================
 // implementation
@@ -111,4 +112,8 @@ static struct ManagerSetter
     }
 } gs_managerSetter;
 
+
+// see the relative linker macro in socket.cpp
+wxFORCE_LINK_THIS_MODULE( socketiohandler );
+
 #endif // wxUSE_SOCKETS
index c50debc3266e2c9971769d6effe5b89378137898..51a158cab657bc0b18d0de9ab154d928fcb98c1f 100644 (file)
@@ -107,6 +107,9 @@ wxSocketError wxSocketImplUnix::GetLastError() const
 void wxSocketImplUnix::DoEnableEvents(int flags, bool enable)
 {
     wxSocketManager * const manager = wxSocketManager::Get();
+    if (!manager)
+        return;
+
     if ( enable )
     {
         if ( flags & wxSOCKET_INPUT_FLAG )