}
// wxEventLoopManual is unused in the other ports
-#if defined(__WXMSW__) || defined(__WXMAC__) || defined(__WXDFB__) || (defined(__UNIX__) && wxUSE_BASE)
+#if defined(__WINDOWS__) || defined(__WXDFB__) || ( ( defined(__UNIX__) && !defined(__WXOSX__) ) && wxUSE_BASE)
// ============================================================================
// wxEventLoopManual implementation
// and this input is only removed from it when pending event handlers are
// executed)
if ( wxTheApp )
+ {
+ const bool hadExitedBefore = m_shouldExit;
+
wxTheApp->ProcessPendingEvents();
+ // One of the pending event handlers could have decided to exit the
+ // loop so check for the flag before trying to dispatch more events
+ // (which could block indefinitely if no more are coming).
+ if ( !hadExitedBefore && m_shouldExit )
+ {
+ // We still need to dispatch any remaining pending events, just as
+ // we do in the event loop in Run() if the loop is exited from a
+ // normal event handler.
+ while ( wxTheApp->HasPendingEvents() )
+ wxTheApp->ProcessPendingEvents();
+
+ return false;
+ }
+ }
+
return Dispatch();
}
int wxEventLoopManual::Run()
{
// event loops are not recursive, you need to create another loop!
- wxCHECK_MSG( !IsRunning(), -1, _T("can't reenter a message loop") );
+ wxCHECK_MSG( !IsRunning(), -1, wxT("can't reenter a message loop") );
// ProcessIdle() and ProcessEvents() below may throw so the code here should
// be exception-safe, hence we must use local objects for all actions we
// generate and process idle events for as long as we don't
// have anything else to do
- while ( !Pending() && ProcessIdle() )
+ while ( !Pending() && ProcessIdle() && !m_shouldExit )
;
// if the "should exit" flag is set, the loop should terminate
void wxEventLoopManual::Exit(int rc)
{
- wxCHECK_RET( IsRunning(), _T("can't call Exit() if not running") );
+ wxCHECK_RET( IsRunning(), wxT("can't call Exit() if not running") );
m_exitcode = rc;
m_shouldExit = true;
WakeUp();
}
-#endif // __WXMSW__ || __WXMAC__ || __WXDFB__
+#endif // __WINDOWS__ || __WXMAC__ || __WXDFB__