Use CF socket manager in GUI OS X applications.
wxSocketManagerMac was never created under OS X since wxSocket code refactoring as wxGUIAppTraits::GetSocketManager() wasn't overridden. Doing this required an extra nasty hack with a global variable in the base library which is used just to pass the socket manager pointer from the net library to the core one without creating a dependency between them but this seems unfortunately unavoidable. See #11030. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61676 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -36,15 +36,11 @@ public:
|
|||||||
// TODO: Should we use XtAddInput() for wxX11 too? Or, vice versa, if there is
|
// TODO: Should we use XtAddInput() for wxX11 too? Or, vice versa, if there is
|
||||||
// no advantage in doing this compared to the generic way currently used
|
// no advantage in doing this compared to the generic way currently used
|
||||||
// by wxX11, should we continue to use GTK/Motif-specific stuff?
|
// by wxX11, should we continue to use GTK/Motif-specific stuff?
|
||||||
#if defined(__WXGTK__) || defined(__WXMOTIF__)
|
#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__)
|
||||||
#define wxHAS_GUI_PROCESS_CALLBACKS
|
#define wxHAS_GUI_PROCESS_CALLBACKS
|
||||||
#define wxHAS_GUI_SOCKET_MANAGER
|
#define wxHAS_GUI_SOCKET_MANAGER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __DARWIN__
|
|
||||||
#define wxHAS_GUI_PROCESS_CALLBACKS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxGUIAppTraits : public wxGUIAppTraitsBase
|
class WXDLLIMPEXP_CORE wxGUIAppTraits : public wxGUIAppTraitsBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@@ -254,17 +254,21 @@ void wxSocketManagerMac::Uninstall_Callback(wxSocketImpl *socket_,
|
|||||||
CFSocketDisableCallBacks(socket->GetSocket(), GetCFCallback(socket, event));
|
CFSocketDisableCallBacks(socket->GetSocket(), GetCFCallback(socket, event));
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the wxBase variable to point to our wxSocketManager implementation
|
// set the wxBase variable to point to CF wxSocketManager implementation so
|
||||||
|
// that the GUI code in utilsexc_cf.cpp could return it from its traits method
|
||||||
//
|
//
|
||||||
// see comments in wx/apptrait.h for the explanation of why do we do it
|
// this is very roundabout but necessary to allow us to have different
|
||||||
// like this
|
// behaviours in console and GUI applications while avoiding dependencies of
|
||||||
static struct ManagerSetter
|
// GUI library on the network one
|
||||||
|
extern WXDLLIMPEXP_BASE wxSocketManager *wxOSXSocketManagerCF;
|
||||||
|
|
||||||
|
static struct OSXManagerSetter
|
||||||
{
|
{
|
||||||
ManagerSetter()
|
OSXManagerSetter()
|
||||||
{
|
{
|
||||||
static wxSocketManagerMac s_manager;
|
static wxSocketManagerMac s_manager;
|
||||||
wxAppTraits::SetDefaultSocketManager(&s_manager);
|
wxOSXSocketManagerCF = &s_manager;
|
||||||
}
|
}
|
||||||
} gs_managerSetter;
|
} gs_OSXManagerSetter;
|
||||||
|
|
||||||
#endif // wxUSE_SOCKETS
|
#endif // wxUSE_SOCKETS
|
||||||
|
@@ -45,6 +45,15 @@
|
|||||||
// Default path style
|
// Default path style
|
||||||
#define kDefaultPathStyle kCFURLPOSIXPathStyle
|
#define kDefaultPathStyle kCFURLPOSIXPathStyle
|
||||||
|
|
||||||
|
#if wxUSE_SOCKETS
|
||||||
|
// global pointer which lives in the base library, set from the net one (see
|
||||||
|
// sockosx.cpp) and used from the GUI code (see utilsexc_cf.cpp) -- ugly but
|
||||||
|
// needed hack, see the above-mentioned files for more information
|
||||||
|
class wxSocketManager;
|
||||||
|
extern WXDLLIMPEXP_BASE wxSocketManager *wxOSXSocketManagerCF;
|
||||||
|
wxSocketManager *wxOSXSocketManagerCF = NULL;
|
||||||
|
#endif // wxUSE_SOCKETS
|
||||||
|
|
||||||
extern bool WXDLLEXPORT wxIsDebuggerRunning()
|
extern bool WXDLLEXPORT wxIsDebuggerRunning()
|
||||||
{
|
{
|
||||||
// TODO : try to find out ...
|
// TODO : try to find out ...
|
||||||
|
@@ -116,3 +116,19 @@ wxStandardPaths& wxGUIAppTraits::GetStandardPaths()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if wxUSE_SOCKETS
|
||||||
|
|
||||||
|
// we need to implement this method in a file of the core library as it should
|
||||||
|
// only be used for the GUI applications but we can't use socket stuff from it
|
||||||
|
// directly as this would create unwanted dependencies of core on net library
|
||||||
|
//
|
||||||
|
// so we have this global pointer which is set from sockosx.cpp when it is
|
||||||
|
// linked in and we simply return it from here
|
||||||
|
extern WXDLLIMPEXP_BASE wxSocketManager *wxOSXSocketManagerCF;
|
||||||
|
wxSocketManager *wxGUIAppTraits::GetSocketManager()
|
||||||
|
{
|
||||||
|
return wxOSXSocketManagerCF ? wxOSXSocketManagerCF
|
||||||
|
: wxGUIAppTraitsBase::GetSocketManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_SOCKETS
|
||||||
|
Reference in New Issue
Block a user