ole: Fix WM_QUIT Handling in CoWaitForMultipleHandles.
When a WM_QUIT message in encountered in CoWaitForMultipleHandles then it should repost the WM_QUIT message and then switch to waiting without checking messages.
This commit is contained in:
parent
12805f08aa
commit
6e0029f83d
|
@ -2658,9 +2658,8 @@ HRESULT WINAPI CoWaitForMultipleHandles(DWORD dwFlags, DWORD dwTimeout,
|
||||||
ULONG cHandles, const HANDLE* pHandles, LPDWORD lpdwindex)
|
ULONG cHandles, const HANDLE* pHandles, LPDWORD lpdwindex)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
DWORD wait_flags = (dwFlags & COWAIT_WAITALL) ? MWMO_WAITALL : 0 |
|
|
||||||
(dwFlags & COWAIT_ALERTABLE ) ? MWMO_ALERTABLE : 0;
|
|
||||||
DWORD start_time = GetTickCount();
|
DWORD start_time = GetTickCount();
|
||||||
|
BOOL message_loop = TRUE;
|
||||||
|
|
||||||
TRACE("(0x%08lx, 0x%08lx, %ld, %p, %p)\n", dwFlags, dwTimeout, cHandles,
|
TRACE("(0x%08lx, 0x%08lx, %ld, %p, %p)\n", dwFlags, dwTimeout, cHandles,
|
||||||
pHandles, lpdwindex);
|
pHandles, lpdwindex);
|
||||||
|
@ -2676,30 +2675,49 @@ HRESULT WINAPI CoWaitForMultipleHandles(DWORD dwFlags, DWORD dwTimeout,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("waiting for rpc completion or window message\n");
|
if (message_loop)
|
||||||
|
|
||||||
res = MsgWaitForMultipleObjectsEx(cHandles, pHandles,
|
|
||||||
(dwTimeout == INFINITE) ? INFINITE : start_time + dwTimeout - now,
|
|
||||||
QS_ALLINPUT, wait_flags);
|
|
||||||
|
|
||||||
if (res == WAIT_OBJECT_0 + cHandles) /* messages available */
|
|
||||||
{
|
{
|
||||||
MSG msg;
|
DWORD wait_flags = (dwFlags & COWAIT_WAITALL) ? MWMO_WAITALL : 0 |
|
||||||
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
|
(dwFlags & COWAIT_ALERTABLE ) ? MWMO_ALERTABLE : 0;
|
||||||
|
|
||||||
|
TRACE("waiting for rpc completion or window message\n");
|
||||||
|
|
||||||
|
res = MsgWaitForMultipleObjectsEx(cHandles, pHandles,
|
||||||
|
(dwTimeout == INFINITE) ? INFINITE : start_time + dwTimeout - now,
|
||||||
|
QS_ALLINPUT, wait_flags);
|
||||||
|
|
||||||
|
if (res == WAIT_OBJECT_0 + cHandles) /* messages available */
|
||||||
{
|
{
|
||||||
/* FIXME: filter the messages here */
|
MSG msg;
|
||||||
TRACE("received message whilst waiting for RPC: 0x%04x\n", msg.message);
|
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
|
||||||
TranslateMessage(&msg);
|
|
||||||
DispatchMessageW(&msg);
|
|
||||||
if (msg.message == WM_QUIT)
|
|
||||||
{
|
{
|
||||||
TRACE("resending WM_QUIT to outer message loop\n");
|
/* FIXME: filter the messages here */
|
||||||
PostQuitMessage(msg.wParam);
|
TRACE("received message whilst waiting for RPC: 0x%04x\n", msg.message);
|
||||||
goto done;
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessageW(&msg);
|
||||||
|
if (msg.message == WM_QUIT)
|
||||||
|
{
|
||||||
|
TRACE("resending WM_QUIT to outer message loop\n");
|
||||||
|
PostQuitMessage(msg.wParam);
|
||||||
|
/* no longer need to process messages */
|
||||||
|
message_loop = FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((res >= WAIT_OBJECT_0) && (res < WAIT_OBJECT_0 + cHandles))
|
else
|
||||||
|
{
|
||||||
|
TRACE("waiting for rpc completion\n");
|
||||||
|
|
||||||
|
res = WaitForMultipleObjectsEx(cHandles, pHandles,
|
||||||
|
(dwFlags & COWAIT_WAITALL) ? TRUE : FALSE,
|
||||||
|
(dwTimeout == INFINITE) ? INFINITE : start_time + dwTimeout - now,
|
||||||
|
(dwFlags & COWAIT_ALERTABLE) ? TRUE : FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((res >= WAIT_OBJECT_0) && (res < WAIT_OBJECT_0 + cHandles))
|
||||||
{
|
{
|
||||||
/* handle signaled, store index */
|
/* handle signaled, store index */
|
||||||
*lpdwindex = (res - WAIT_OBJECT_0);
|
*lpdwindex = (res - WAIT_OBJECT_0);
|
||||||
|
@ -2717,7 +2735,6 @@ HRESULT WINAPI CoWaitForMultipleHandles(DWORD dwFlags, DWORD dwTimeout,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
done:
|
|
||||||
TRACE("-- 0x%08lx\n", hr);
|
TRACE("-- 0x%08lx\n", hr);
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue