Piotr Caban : ole32: Don' t pump all messages in CoWaitForMultipleHandles in threads without apartment window.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Jul 30 17:10:04 CDT 2015
Module: wine
Branch: master
Commit: fbf7046ae86f03b839c414748af8c0259dcdff8c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=fbf7046ae86f03b839c414748af8c0259dcdff8c
Author: Piotr Caban <piotr at codeweavers.com>
Date: Thu Jul 30 17:02:51 2015 +0200
ole32: Don't pump all messages in CoWaitForMultipleHandles in threads without apartment window.
---
dlls/ole32/compobj.c | 2 +-
dlls/ole32/tests/compobj.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c
index 762f011..6a30d7d 100644
--- a/dlls/ole32/compobj.c
+++ b/dlls/ole32/compobj.c
@@ -4388,7 +4388,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, 0, 0, PM_REMOVE|PM_NOYIELD) ||
+ return (apt->win && 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);
diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c
index c96d63a..1dc3af0 100644
--- a/dlls/ole32/tests/compobj.c
+++ b/dlls/ole32/tests/compobj.c
@@ -2126,9 +2126,45 @@ static DWORD CALLBACK post_message_thread(LPVOID arg)
return 0;
}
+static const char cls_name[] = "cowait_test_class";
+static DWORD CALLBACK test_CoWaitForMultipleHandles_thread(LPVOID arg)
+{
+ HANDLE *handles = arg;
+ BOOL success;
+ DWORD index;
+ HRESULT hr;
+ HWND hWnd;
+ MSG msg;
+
+ hr = pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+ ok(hr == S_OK, "CoInitializeEx failed with error 0x%08x\n", hr);
+
+ hWnd = CreateWindowExA(0, cls_name, "Test (thread)", WS_TILEDWINDOW, 0, 0, 640, 480, 0, 0, 0, 0);
+ ok(hWnd != 0, "CreateWindowExA failed %u\n", GetLastError());
+
+ index = 0xdeadbeef;
+ PostMessageA(hWnd, WM_DDE_FIRST, 0, 0);
+ hr = CoWaitForMultipleHandles(0, 50, 2, handles, &index);
+ ok(hr == RPC_S_CALLPENDING, "expected S_OK, got 0x%08x\n", hr);
+ ok(index == 0, "expected index 0, got %u\n", index);
+ success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);
+ ok(!success, "CoWaitForMultipleHandles didn't pump any messages\n");
+
+ index = 0xdeadbeef;
+ PostMessageA(hWnd, WM_USER, 0, 0);
+ hr = CoWaitForMultipleHandles(0, 50, 2, handles, &index);
+ ok(hr == RPC_S_CALLPENDING, "expected S_OK, got 0x%08x\n", hr);
+ ok(index == 0, "expected index 0, got %u\n", index);
+ success = PeekMessageA(&msg, hWnd, WM_USER, WM_USER, PM_REMOVE);
+ ok(success, "CoWaitForMultipleHandles unexpectedly pumped messages\n");
+
+ DestroyWindow(hWnd);
+ CoUninitialize();
+ return 0;
+}
+
static void test_CoWaitForMultipleHandles(void)
{
- static const char cls_name[] = "cowait_test_class";
HANDLE handles[2], thread;
DWORD index, tid;
WNDCLASSEXA wc;
@@ -2431,6 +2467,12 @@ static void test_CoWaitForMultipleHandles(void)
CloseHandle(thread);
}
+ /* test message pumping when CoWaitForMultipleHandles is called from non main apartment thread */
+ thread = CreateThread(NULL, 0, test_CoWaitForMultipleHandles_thread, handles, 0, &tid);
+ index = WaitForSingleObject(thread, 500);
+ ok(index == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
+ CloseHandle(thread);
+
CloseHandle(handles[0]);
CloseHandle(handles[1]);
DestroyWindow(hWnd);
More information about the wine-cvs
mailing list