ole32: Don't pump all messages in CoWaitForMultipleHandles in threads without apartment window.
This commit is contained in:
parent
fc761cb935
commit
fbf7046ae8
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue