diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-12-20 18:41:26 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-02-05 05:44:47 +0100 |
commit | 07d065cbbe7e45f251497d8a0c440ecf61afd848 (patch) | |
tree | 334ee8b2b9bca286ab39a6081d937b39946442fb /src/corelib/kernel/qeventdispatcher_win.cpp | |
parent | ff6299e271cb4d06c65d1756de077a1538aaedc5 (diff) |
Win32: always allow the event loop to be woken up by posted events
We set the wakeUps atomic to prevent multiple WM_QT_SENDPOSTEDEVENTS from
being posted. However, this might happen right after the event processing
thread cleared the atomic, but before it processed the previous
WM_QT_SENDPOSTEDEVENTS message. In that case, we end up with a set
atomic and an empty event queue, resulting in the event loop to block
even though there are posted QEvents.
To prevent that, always reset the atomic when we handle the
WM_QT_SENDPOSTEDEVENTS message. In that case, we either call
sendPostedEvents, or startPostedEventsTimer. The former already resets
wakeUps; reset it in the latter as well.
Fixes: QTBUG-99323
Change-Id: I931c02be9c42b02e8ca20daba5059cd8185f0a37
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
(cherry picked from commit d671bab0e3fc61532bcfdb4ff3f7a468d2b14b6b)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/kernel/qeventdispatcher_win.cpp')
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_win.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index f8e6d979b2..91673fe158 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -275,6 +275,8 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA void QEventDispatcherWin32Private::startPostedEventsTimer() { + // we received WM_QT_SENDPOSTEDEVENTS, so allow posting it again + wakeUps.storeRelaxed(0); if (sendPostedEventsTimerId == 0) { // Start a timer to deliver posted events when the message queue is emptied. sendPostedEventsTimerId = SetTimer(internalHwnd, SendPostedEventsTimerId, |