From 08db475a7f97948940f98a6b7ea2129a663a202b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 15 Feb 2020 18:26:09 +0100 Subject: [PATCH] Process queued events with higher priority than idle ones In the port using wxEventLoopManual, such as wxMSW, an idle event handler calling wxIdleEvent::RequestMore() prevented any queued events from being handled until the next "real" event (i.e. originating from the underlying toolkit) was received. This was unexpected and incompatible with the behaviour of wxGTK, where queued events were still processed immediately even when RequestMore() was being constantly called, so change wxEventLoopManual to also give higher priority to these events by stopping calling ProcessIdle() if a queued event is available. Closes #18667. --- src/common/evtloopcmn.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/common/evtloopcmn.cpp b/src/common/evtloopcmn.cpp index bc713b84e1..223e81b531 100644 --- a/src/common/evtloopcmn.cpp +++ b/src/common/evtloopcmn.cpp @@ -270,7 +270,15 @@ int wxEventLoopManual::DoRun() // generate and process idle events for as long as we don't // have anything else to do, but stop doing this if Exit() is // called by one of the idle handlers - while ( !m_shouldExit && !Pending() && ProcessIdle() ) + // + // note that Pending() only checks for pending events from the + // underlying toolkit, but not our own pending events added by + // QueueEvent(), so we need to call HasPendingEvents() to check + // for them too + while ( !m_shouldExit + && !Pending() + && !(wxTheApp && wxTheApp->HasPendingEvents()) + && ProcessIdle() ) ; // if Exit() was called, don't dispatch any more events here