From: Andrew Eikum Subject: [PATCH 1/2] mciqtz: Dispatch messages while waiting on command completion. Message-Id: <20160427190511.GQ31257@foghorn.codeweavers.com> Date: Wed, 27 Apr 2016 14:05:11 -0500 Without this, we can hit a deadlock if the task thread tries to call a SendMessage on a window owned by the calling thread. Signed-off-by: Andrew Eikum --- dlls/mciqtz32/mciqtz.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dlls/mciqtz32/mciqtz.c b/dlls/mciqtz32/mciqtz.c index 4e559b6..6627910 100644 --- a/dlls/mciqtz32/mciqtz.c +++ b/dlls/mciqtz32/mciqtz.c @@ -90,8 +90,17 @@ static LRESULT MCIQTZ_relayTaskMessage(DWORD_PTR dwDevID, UINT wMsg, SetEvent(wma->task.notify); handles[0] = wma->task.done; handles[1] = wma->task.thread; - ret = WaitForMultipleObjects(sizeof(handles)/sizeof(handles[0]), handles, - FALSE, INFINITE); + + while ((ret = MsgWaitForMultipleObjects(sizeof(handles)/sizeof(handles[0]), + handles, FALSE, INFINITE, QS_ALLINPUT)) == WAIT_OBJECT_0 + 2) + { + MSG msg; + while (PeekMessageW( &msg, NULL, 0, 0, PM_REMOVE )) + { + TranslateMessage( &msg ); + DispatchMessageW( &msg ); + } + } if (ret == WAIT_OBJECT_0) res = wma->task.res; else -- 2.8.0