From fe4b246446f721085946e399b96a42eccfcecca8 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Tue, 18 Aug 2020 15:07:38 +0300 Subject: Synchronize QEventDispatcherWin32::processEvents() with QCoreApplication QCoreApplication has a special internal mechanism to control whether the event dispatcher should block after delivering the posted events. To handle queued connections in nested loops properly, we should use that functionality. Pick-to: 5.15 Fixes: QTBUG-85981 Change-Id: I124179a23b26a995cf95ed379e97bfa62c95f42a Reviewed-by: Friedemann Kleint Reviewed-by: Oswald Buddenhagen Reviewed-by: Volker Hilsheimer --- src/corelib/kernel/qeventdispatcher_win.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/corelib/kernel/qeventdispatcher_win.cpp') diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 7e6d478473..b3ae226e58 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -529,6 +529,7 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) // QCoreApplication::sendPostedEvents() takes care about recursions. sendPostedEvents(); + auto threadData = d->threadData.loadRelaxed(); bool canWait; bool retVal = false; do { @@ -599,7 +600,8 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) // wait for message canWait = (!retVal && !d->interrupt.loadRelaxed() - && (flags & QEventLoop::WaitForMoreEvents)); + && flags.testFlag(QEventLoop::WaitForMoreEvents) + && threadData->canWaitLocked()); if (canWait) { emit aboutToBlock(); MsgWaitForMultipleObjectsEx(0, NULL, INFINITE, QS_ALLINPUT, MWMO_ALERTABLE | MWMO_INPUTAVAILABLE); -- cgit v1.2.3