ole32: Make CoWaitForMultipleHandles peek at all posted messages.

Signed-off-by: Anton Romanov <theli.ua@gmail.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Anton Romanov 2018-01-18 22:17:06 -08:00 committed by Alexandre Julliard
parent 71d8edebb9
commit 90a094cc24
2 changed files with 25 additions and 0 deletions

View File

@ -4547,6 +4547,12 @@ HRESULT WINAPI CoWaitForMultipleHandles(DWORD dwFlags, DWORD dwTimeout,
}
}
if (!apt->win)
{
/* If window is NULL on apartment, peek at messages so that it will not trigger
* MsgWaitForMultipleObjects next time. */
PeekMessageW(NULL, NULL, 0, 0, PM_QS_POSTMESSAGE | PM_NOREMOVE | PM_NOYIELD);
}
/* some apps (e.g. Visio 2010) don't handle WM_PAINT properly and loop forever,
* so after processing 100 messages we go back to checking the wait handles */
while (count++ < 100 && COM_PeekMessage(apt, &msg))

View File

@ -2648,7 +2648,9 @@ static DWORD CALLBACK test_CoWaitForMultipleHandles_thread(LPVOID arg)
DWORD index;
HRESULT hr;
HWND hWnd;
UINT uMSG = 0xc065;
MSG msg;
int ret;
hr = pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
ok(hr == S_OK, "CoInitializeEx failed with error 0x%08x\n", hr);
@ -2672,6 +2674,23 @@ static DWORD CALLBACK test_CoWaitForMultipleHandles_thread(LPVOID arg)
success = PeekMessageA(&msg, hWnd, WM_USER, WM_USER, PM_REMOVE);
ok(success, "CoWaitForMultipleHandles unexpectedly pumped messages\n");
/* Even if CoWaitForMultipleHandles does not pump a message it peeks
* at ALL of them */
index = 0xdeadbeef;
PostMessageA(NULL, uMSG, 0, 0);
hr = CoWaitForMultipleHandles(COWAIT_ALERTABLE, 50, 2, handles, &index);
ok(hr == RPC_S_CALLPENDING, "expected RPC_S_CALLPENDING, got 0x%08x\n", hr);
ok(index == 0 || broken(index == 0xdeadbeef) /* Win 8 */, "expected index 0, got %u\n", index);
/* Make sure message was peeked at */
ret = MsgWaitForMultipleObjectsEx(0, NULL, 2, QS_ALLPOSTMESSAGE, MWMO_ALERTABLE);
ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
/* But not pumped */
success = PeekMessageA(&msg, NULL, uMSG, uMSG, PM_REMOVE);
ok(success, "CoWaitForMultipleHandles unexpectedly pumped messages\n");
DestroyWindow(hWnd);
CoUninitialize();
return 0;