diff --git a/docs/changes.txt b/docs/changes.txt index e6551fa719..cb5d94e75b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -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) ---------------------------- diff --git a/src/osx/core/evtloop_cf.cpp b/src/osx/core/evtloop_cf.cpp index 4bdce90f1e..30fe4e39be 100644 --- a/src/osx/core/evtloop_cf.cpp +++ b/src/osx/core/evtloop_cf.cpp @@ -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; + } } }