Virtualize wxSocketImpl creation by routing it via wxSocketManager.
This is necessary to create different kinds of sockets for the console and GUI applications under OS X: unlike Unix which use different socket managers for the console and GUI programs but still use the same data structures in both cases as X11 and derived toolkits APIs are very similar, Core Foundation sockets don't have anything in common with their console counterparts and so we need to use different wxSocketImpl versions too. A side effect of this commit is that now we need to force linking of src/msw/sockmsw.cpp when using sockets: this wasn't necessary before because it contained wxSocketImpl method definition but now that there are no more direct dependencies on it, MSVC linker simply discards the object file unless we force it to link with it. Notice that this commit doesn't change anything yet, it simply refactors the code to use wxSocketManager::CreateSocket() instead of wxSocketImpl::Create() in preparation for the next change. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61675 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -533,7 +533,14 @@ wxSocketImpl *wxSocketImpl::Accept(wxSocketBase& wxsocket)
|
||||
if ( fd == INVALID_SOCKET )
|
||||
return NULL;
|
||||
|
||||
wxSocketImpl * const sock = Create(wxsocket);
|
||||
wxSocketManager * const manager = wxSocketManager::Get();
|
||||
if ( !manager )
|
||||
return NULL;
|
||||
|
||||
wxSocketImpl * const sock = manager->CreateSocket(wxsocket);
|
||||
if ( !sock )
|
||||
return NULL;
|
||||
|
||||
sock->m_fd = fd;
|
||||
sock->m_peer = wxSockAddressImpl(from.addr, fromlen);
|
||||
|
||||
@@ -1739,7 +1746,8 @@ wxSocketServer::wxSocketServer(const wxSockAddress& addr,
|
||||
{
|
||||
wxLogTrace( wxTRACE_Socket, wxT("Opening wxSocketServer") );
|
||||
|
||||
m_impl = wxSocketImpl::Create(*this);
|
||||
wxSocketManager * const manager = wxSocketManager::Get();
|
||||
m_impl = manager ? manager->CreateSocket(*this) : NULL;
|
||||
|
||||
if (!m_impl)
|
||||
{
|
||||
@@ -1897,7 +1905,8 @@ bool wxSocketClient::DoConnect(const wxSockAddress& remote,
|
||||
m_establishing = false;
|
||||
|
||||
// Create and set up the new one
|
||||
m_impl = wxSocketImpl::Create(*this);
|
||||
wxSocketManager * const manager = wxSocketManager::Get();
|
||||
m_impl = manager ? manager->CreateSocket(*this) : NULL;
|
||||
if ( !m_impl )
|
||||
return false;
|
||||
|
||||
@@ -1979,7 +1988,8 @@ wxDatagramSocket::wxDatagramSocket( const wxSockAddress& addr,
|
||||
: wxSocketBase( flags, wxSOCKET_DATAGRAM )
|
||||
{
|
||||
// Create the socket
|
||||
m_impl = wxSocketImpl::Create(*this);
|
||||
wxSocketManager * const manager = wxSocketManager::Get();
|
||||
m_impl = manager ? manager->CreateSocket(*this) : NULL;
|
||||
|
||||
if (!m_impl)
|
||||
return;
|
||||
@@ -2064,4 +2074,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxSocketModule, wxModule)
|
||||
wxFORCE_LINK_MODULE( socketiohandler )
|
||||
#endif
|
||||
|
||||
// same for ManagerSetter in the MSW file
|
||||
#ifdef __WXMSW__
|
||||
wxFORCE_LINK_MODULE( mswsocket )
|
||||
#endif
|
||||
|
||||
#endif // wxUSE_SOCKETS
|
||||
|
Reference in New Issue
Block a user