Applied patch [ 1431955 ] Fixes wxSocket* _Wait/Select

From Angel Vidal Veiga


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37619 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2006-02-16 08:53:35 +00:00
parent 3025abca05
commit f01bca89fd

View File

@@ -694,6 +694,8 @@ bool wxSocketBase::_Wait(long seconds,
else else
timeout = m_timeout * 1000; timeout = m_timeout * 1000;
bool has_event_loop = wxTheApp ? (wxTheApp->GetTraits() ? true : false) : false;
// Wait in an active polling loop. // Wait in an active polling loop.
// //
// NOTE: We duplicate some of the code in OnRequest, but this doesn't // NOTE: We duplicate some of the code in OnRequest, but this doesn't
@@ -709,14 +711,15 @@ bool wxSocketBase::_Wait(long seconds,
bool done = false; bool done = false;
bool valid_result = false; bool valid_result = false;
#if !defined(wxUSE_GUI) || !wxUSE_GUI if (!has_event_loop)
{
// This is used to avoid a busy loop on wxBase - having a select // This is used to avoid a busy loop on wxBase - having a select
// timeout of 50 ms per iteration should be enough. // timeout of 50 ms per iteration should be enough.
if (timeout > 50) if (timeout > 50)
m_socket->SetTimeout(50); m_socket->SetTimeout(50);
else else
m_socket->SetTimeout(timeout); m_socket->SetTimeout(timeout);
#endif }
while (!done) while (!done)
{ {
@@ -754,20 +757,22 @@ bool wxSocketBase::_Wait(long seconds,
done = true; done = true;
else else
{ {
#if !defined(wxUSE_GUI) || !wxUSE_GUI if (has_event_loop)
{
PROCESS_EVENTS();
}
else
{
// If there's less than 50 ms left, just call select with that timeout. // If there's less than 50 ms left, just call select with that timeout.
if (time_left < 50) if (time_left < 50)
m_socket->SetTimeout(time_left); m_socket->SetTimeout(time_left);
#else }
PROCESS_EVENTS(); }
#endif
}
} }
// Set timeout back to original value (we overwrote it for polling) // Set timeout back to original value (we overwrote it for polling)
#if !defined(wxUSE_GUI) || !wxUSE_GUI if (!has_event_loop)
m_socket->SetTimeout(m_timeout*1000); m_socket->SetTimeout(m_timeout*1000);
#endif
return valid_result; return valid_result;
} }