Anton Romanov : ole32: Make CoWaitForMultipleHandles peek at all posted messages.

Alexandre Julliard julliard at winehq.org
Fri Jan 19 15:43:20 CST 2018


Module: wine
Branch: master
Commit: 90a094cc24a900687347af8f490c46617f9782df
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=90a094cc24a900687347af8f490c46617f9782df

Author: Anton Romanov <theli.ua at gmail.com>
Date:   Thu Jan 18 22:17:06 2018 -0800

ole32: Make CoWaitForMultipleHandles peek at all posted messages.

Signed-off-by: Anton Romanov <theli.ua at gmail.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ole32/compobj.c       |  6 ++++++
 dlls/ole32/tests/compobj.c | 19 +++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c
index d136ee6..3da3c2f 100644
--- a/dlls/ole32/compobj.c
+++ b/dlls/ole32/compobj.c
@@ -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))
diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c
index b46ff03..83595cb 100644
--- a/dlls/ole32/tests/compobj.c
+++ b/dlls/ole32/tests/compobj.c
@@ -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;




More information about the wine-cvs mailing list