Don't block in wxEventLoopManual::Dispatch() if loop was exited.

If Exit() was called from a handler for one of the pending events we could
reenter Dispatch() and block there indefinitely if no other events were coming
and this was exactly what happened in wxFileSystemWatcher unit test,
preventing it from ever running to completion under Unix.

Fix this by checking m_shouldExit after executing the pending handlers and
before calling Dispatch().

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71304 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-04-28 22:24:54 +00:00
parent a6a181a303
commit 586c455167

View File

@@ -104,8 +104,24 @@ bool wxEventLoopManual::ProcessEvents()
// and this input is only removed from it when pending event handlers are
// executed)
if ( wxTheApp )
{
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 ( 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();
}