Fix dispatching pending events in console applications under Mac

Apply parts of the changes of 34c5aaa769
done in the common code to Mac-specific wxCFEventLoop too.

This is not ideal as we really should reuse the same common code here,
but for now it's better than nothing as previously pending events were
just not dispatched at all in console Mac applications, meaning that
CallAfter() from worker threads never executed.
This commit is contained in:
Vadim Zeitlin 2018-05-08 01:11:55 +02:00
parent 1680c28284
commit 9caa3d5d8e
2 changed files with 31 additions and 0 deletions

View File

@ -94,6 +94,10 @@ wxMSW:
- Fix positioning windows at positions >= SHORT_MAX (Cătălin Răceanu).
- Honour alignment flags for multiline buttons using custom colours too.
wxOSX:
- Fix dispatching pending events (and CallAfter()) in console applications.
3.1.1: (released 2018-02-19)
----------------------------

View File

@ -283,6 +283,33 @@ void wxCFEventLoop::OSXDoRun()
break;
}
// Process the remaining queued messages, both at the level of the
// underlying toolkit level (Pending/Dispatch()) and wx level
// (Has/ProcessPendingEvents()).
//
// We do run the risk of never exiting this loop if pending event
// handlers endlessly generate new events but they shouldn't do
// this in a well-behaved program and we shouldn't just discard the
// events we already have, they might be important.
for ( ;; )
{
bool hasMoreEvents = false;
if ( wxTheApp && wxTheApp->HasPendingEvents() )
{
wxTheApp->ProcessPendingEvents();
hasMoreEvents = true;
}
if ( Pending() )
{
Dispatch();
hasMoreEvents = true;
}
if ( !hasMoreEvents )
break;
}
}
}