Alexandre Julliard : ole32: Process all pending messages in CoWaitForMultipleHandles before waiting again , otherwise we may not wake up.

Alexandre Julliard julliard at winehq.org
Wed Nov 30 14:19:19 CST 2011


Module: wine
Branch: master
Commit: 0f3e60747f1958eaa6ef5ff31f65eb3e77da146f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0f3e60747f1958eaa6ef5ff31f65eb3e77da146f

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Nov 29 21:22:40 2011 +0100

ole32: Process all pending messages in CoWaitForMultipleHandles before waiting again, otherwise we may not wake up.

---

 dlls/ole32/compobj.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c
index 4579f0a..72ba32a 100644
--- a/dlls/ole32/compobj.c
+++ b/dlls/ole32/compobj.c
@@ -3650,7 +3650,7 @@ HRESULT WINAPI CoRevertToSelf(void)
 static BOOL COM_PeekMessage(struct apartment *apt, MSG *msg)
 {
     /* first try to retrieve messages for incoming COM calls to the apartment window */
-    return PeekMessageW(msg, apt->win, WM_USER, WM_APP - 1, PM_REMOVE|PM_NOYIELD) ||
+    return PeekMessageW(msg, apt->win, 0, 0, PM_REMOVE|PM_NOYIELD) ||
            /* next retrieve other messages necessary for the app to remain responsive */
            PeekMessageW(msg, NULL, WM_DDE_FIRST, WM_DDE_LAST, PM_REMOVE|PM_NOYIELD) ||
            PeekMessageW(msg, NULL, 0, 0, PM_QS_PAINT|PM_QS_SENDMESSAGE|PM_REMOVE|PM_NOYIELD);
@@ -3712,7 +3712,7 @@ HRESULT WINAPI CoWaitForMultipleHandles(DWORD dwFlags, DWORD dwTimeout,
 
             res = MsgWaitForMultipleObjectsEx(cHandles, pHandles,
                 (dwTimeout == INFINITE) ? INFINITE : start_time + dwTimeout - now,
-                QS_ALLINPUT, wait_flags);
+                QS_SENDMESSAGE | QS_ALLPOSTMESSAGE | QS_PAINT, wait_flags);
 
             if (res == WAIT_OBJECT_0 + cHandles)  /* messages available */
             {
@@ -3746,11 +3746,7 @@ HRESULT WINAPI CoWaitForMultipleHandles(DWORD dwFlags, DWORD dwTimeout,
                     }
                 }
 
-                /* note: using "if" here instead of "while" might seem less
-                 * efficient, but only if we are optimising for quick delivery
-                 * of pending messages, rather than quick completion of the
-                 * COM call */
-                if (COM_PeekMessage(apt, &msg))
+                while (COM_PeekMessage(apt, &msg))
                 {
                     TRACE("received message whilst waiting for RPC: 0x%04x\n", msg.message);
                     TranslateMessage(&msg);
@@ -3761,6 +3757,7 @@ HRESULT WINAPI CoWaitForMultipleHandles(DWORD dwFlags, DWORD dwTimeout,
                         PostQuitMessage(msg.wParam);
                         /* no longer need to process messages */
                         message_loop = FALSE;
+                        break;
                     }
                 }
                 continue;




More information about the wine-cvs mailing list