From 4a3a5d5b0fc8211420f89e5b61cf9c99b44a5ebf Mon Sep 17 00:00:00 2001 From: Andrew Nelless Date: Sun, 18 Mar 2018 20:50:26 +0000 Subject: [PATCH] #6251 Attempt to fix Windows event loop hang --- src/lib/platform/MSWindowsEventQueueBuffer.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/platform/MSWindowsEventQueueBuffer.cpp b/src/lib/platform/MSWindowsEventQueueBuffer.cpp index b1203f9a..8cc70a82 100644 --- a/src/lib/platform/MSWindowsEventQueueBuffer.cpp +++ b/src/lib/platform/MSWindowsEventQueueBuffer.cpp @@ -62,7 +62,7 @@ MSWindowsEventQueueBuffer::waitForEvent(double timeout) // MsgWaitForMultipleObjects() will block even if the queue isn't // empty if the messages in the queue were there before the last // call to GetMessage()/PeekMessage(). - if (HIWORD(GetQueueStatus(QS_ALLINPUT)) != 0) { + if (HIWORD(GetQueueStatus(QS_ALLPOSTMESSAGE)) != 0) { return; } @@ -79,12 +79,14 @@ MSWindowsEventQueueBuffer::waitForEvent(double timeout) // cancellation but that's okay because we're run in the main // thread and we never cancel that thread. HANDLE dummy[1]; - MsgWaitForMultipleObjects(0, dummy, FALSE, t, QS_ALLINPUT); + MsgWaitForMultipleObjects(0, dummy, FALSE, t, QS_ALLPOSTMESSAGE); } IEventQueueBuffer::Type MSWindowsEventQueueBuffer::getEvent(Event& event, UInt32& dataID) { + // NOTE: QS_ALLINPUT was replaced with QS_ALLPOSTMESSAGE. + // // peek at messages first. waiting for QS_ALLINPUT will return // if a message has been sent to our window but GetMessage will // dispatch that message behind our backs and block. PeekMessage @@ -128,7 +130,7 @@ MSWindowsEventQueueBuffer::addEvent(UInt32 dataID) bool MSWindowsEventQueueBuffer::isEmpty() const { - return (HIWORD(GetQueueStatus(QS_ALLINPUT)) == 0); + return (HIWORD(GetQueueStatus(QS_ALLPOSTMESSAGE)) == 0); } EventQueueTimer*