corrected assert in wxSocket::Initialize()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28482 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -122,14 +122,6 @@ bool wxSocketBase::Initialize()
|
|||||||
{
|
{
|
||||||
if ( !m_countInit++ )
|
if ( !m_countInit++ )
|
||||||
{
|
{
|
||||||
#ifdef __WXMSW__
|
|
||||||
/*
|
|
||||||
The following asserting might be neccessary for linux as well,
|
|
||||||
but I cannot verify this.
|
|
||||||
*/
|
|
||||||
wxASSERT(wxThread::IsMain(),
|
|
||||||
wxT("To use sockets in a secondary thread, ")
|
|
||||||
wxT("call wxSocketBase::Initialize() from the main thread."));
|
|
||||||
/*
|
/*
|
||||||
Details: Initialize() creates a hidden window as a sink for socket
|
Details: Initialize() creates a hidden window as a sink for socket
|
||||||
events, such as 'read completed'. wxMSW has only one message loop
|
events, such as 'read completed'. wxMSW has only one message loop
|
||||||
@@ -138,16 +130,18 @@ bool wxSocketBase::Initialize()
|
|||||||
since there is no message loop on this thread, it will never
|
since there is no message loop on this thread, it will never
|
||||||
receive events and all socket operations will time out.
|
receive events and all socket operations will time out.
|
||||||
BTW, the main thread must not be stopped using sleep or block
|
BTW, the main thread must not be stopped using sleep or block
|
||||||
on a semaphore (a bad idea in any case) or socket operations
|
on a semaphore (a bad idea in any case) or socket operations
|
||||||
will time out.
|
will time out.
|
||||||
*/
|
*/
|
||||||
#endif
|
wxASSERT_MSG( wxThread::IsMain(),
|
||||||
|
wxT("Call wxSocketBase::Initialize() from the main thread first!"));
|
||||||
|
|
||||||
wxAppTraits *traits = wxAppConsole::GetInstance() ?
|
wxAppTraits *traits = wxAppConsole::GetInstance() ?
|
||||||
wxAppConsole::GetInstance()->GetTraits() : NULL;
|
wxAppConsole::GetInstance()->GetTraits() : NULL;
|
||||||
GSocketGUIFunctionsTable *functions =
|
GSocketGUIFunctionsTable *functions =
|
||||||
traits ? traits->GetSocketGUIFunctionsTable() : NULL;
|
traits ? traits->GetSocketGUIFunctionsTable() : NULL;
|
||||||
GSocket_SetGUIFunctions(functions);
|
GSocket_SetGUIFunctions(functions);
|
||||||
|
|
||||||
if ( !GSocket_Init() )
|
if ( !GSocket_Init() )
|
||||||
{
|
{
|
||||||
m_countInit--;
|
m_countInit--;
|
||||||
@@ -700,7 +694,7 @@ bool wxSocketBase::_Wait(long seconds,
|
|||||||
|
|
||||||
#if !defined(wxUSE_GUI) || !wxUSE_GUI
|
#if !defined(wxUSE_GUI) || !wxUSE_GUI
|
||||||
GSocket_SetTimeout(m_socket, timeout);
|
GSocket_SetTimeout(m_socket, timeout);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Wait in an active polling loop.
|
// Wait in an active polling loop.
|
||||||
//
|
//
|
||||||
@@ -860,7 +854,7 @@ void wxSocketBase::RestoreState()
|
|||||||
m_notify = state->m_notify;
|
m_notify = state->m_notify;
|
||||||
m_eventmask = state->m_eventmask;
|
m_eventmask = state->m_eventmask;
|
||||||
m_clientData = state->m_clientData;
|
m_clientData = state->m_clientData;
|
||||||
|
|
||||||
m_states.Erase(node);
|
m_states.Erase(node);
|
||||||
delete state;
|
delete state;
|
||||||
}
|
}
|
||||||
@@ -1149,7 +1143,7 @@ bool wxSocketServer::WaitForAccept(long seconds, long milliseconds)
|
|||||||
|
|
||||||
bool wxSocketBase::GetOption(int level, int optname, void *optval, int *optlen)
|
bool wxSocketBase::GetOption(int level, int optname, void *optval, int *optlen)
|
||||||
{
|
{
|
||||||
if (GSocket_GetSockOpt(m_socket, level, optname, optval, optlen)
|
if (GSocket_GetSockOpt(m_socket, level, optname, optval, optlen)
|
||||||
!= GSOCK_NOERROR)
|
!= GSOCK_NOERROR)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -1157,10 +1151,10 @@ bool wxSocketBase::GetOption(int level, int optname, void *optval, int *optlen)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSocketBase::SetOption(int level, int optname, const void *optval,
|
bool wxSocketBase::SetOption(int level, int optname, const void *optval,
|
||||||
int optlen)
|
int optlen)
|
||||||
{
|
{
|
||||||
if (GSocket_SetSockOpt(m_socket, level, optname, optval, optlen)
|
if (GSocket_SetSockOpt(m_socket, level, optname, optval, optlen)
|
||||||
!= GSOCK_NOERROR)
|
!= GSOCK_NOERROR)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
Reference in New Issue
Block a user