Commit 90a094cc authored by Anton Romanov's avatar Anton Romanov Committed by Alexandre Julliard

ole32: Make CoWaitForMultipleHandles peek at all posted messages.

parent 71d8edeb
...@@ -4547,6 +4547,12 @@ HRESULT WINAPI CoWaitForMultipleHandles(DWORD dwFlags, DWORD dwTimeout, ...@@ -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, /* 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 */ * so after processing 100 messages we go back to checking the wait handles */
while (count++ < 100 && COM_PeekMessage(apt, &msg)) while (count++ < 100 && COM_PeekMessage(apt, &msg))
......
...@@ -2648,7 +2648,9 @@ static DWORD CALLBACK test_CoWaitForMultipleHandles_thread(LPVOID arg) ...@@ -2648,7 +2648,9 @@ static DWORD CALLBACK test_CoWaitForMultipleHandles_thread(LPVOID arg)
DWORD index; DWORD index;
HRESULT hr; HRESULT hr;
HWND hWnd; HWND hWnd;
UINT uMSG = 0xc065;
MSG msg; MSG msg;
int ret;
hr = pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED); hr = pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
ok(hr == S_OK, "CoInitializeEx failed with error 0x%08x\n", hr); ok(hr == S_OK, "CoInitializeEx failed with error 0x%08x\n", hr);
...@@ -2672,6 +2674,23 @@ static DWORD CALLBACK test_CoWaitForMultipleHandles_thread(LPVOID arg) ...@@ -2672,6 +2674,23 @@ static DWORD CALLBACK test_CoWaitForMultipleHandles_thread(LPVOID arg)
success = PeekMessageA(&msg, hWnd, WM_USER, WM_USER, PM_REMOVE); success = PeekMessageA(&msg, hWnd, WM_USER, WM_USER, PM_REMOVE);
ok(success, "CoWaitForMultipleHandles unexpectedly pumped messages\n"); 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); DestroyWindow(hWnd);
CoUninitialize(); CoUninitialize();
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment