// Yield to other processes
-bool wxApp::Yield(bool onlyIfNeeded)
+bool wxApp::DoYield(bool onlyIfNeeded, long eventsToProcess)
{
// Sometimes only 2 yields seem
// to do the trick, e.g. in the
int i;
for (i = 0; i < 2; i++)
{
- static bool s_inYield = false;
-
- if ( s_inYield )
+ if ( m_isInsideYield )
{
if ( !onlyIfNeeded )
{
return false;
}
- s_inYield = true;
+ m_isInsideYield = true;
+ m_eventsToProcessInsideYield = eventsToProcess;
// Make sure we have an event loop object,
// or Pending/Dispatch will fail
- wxEventLoopBase * const eventLoop = wxEventLoop::GetActive();
- wxEventLoop* newEventLoop = NULL;
- if (!eventLoop)
- {
- newEventLoop = new wxEventLoop;
- wxEventLoop::SetActive(newEventLoop);
- }
+ wxEventLoopGuarantor dummyLoopIfNeeded;
// Call dispatch at least once so that sockets
// can be tested
wxTheApp->Dispatch();
+ // TODO: implement event filtering using the eventsToProcess mask
while (wxTheApp && wxTheApp->Pending())
wxTheApp->Dispatch();
#endif
ProcessIdle();
- if (newEventLoop)
- {
- wxEventLoop::SetActive(NULL);
- delete newEventLoop;
- }
-
- s_inYield = false;
+ m_isInsideYield = false;
}
return true;