No WM_QUIT, QCoreApplication::processEvents()
-
I use Qt as a offscreen html render in a Win32 application. In the main loop, I repeatedly call QCoreApplication::processEvents() to process qt events. The problem is after I call PostQuitMessage(0) in WM_DESTROY, the main loop don't break. While if I remove QCoreApplication::processEvents(), PostQuitMessage(0) will produce a WM_QUIT message.
Is there anything wrong about the code? Or any ideas? Thanks
Main Loop
[code]
while (true) {
QCoreApplication::processEvents(); // If remove this line, PostQuitMessage(0) will produce WM_QUIT
if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) {
if (msg.message == WM_QUIT) {
break;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
} else {
Render()
}
}
[/code]Message process:
[code]
LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_DESTROY:
PostQuitMessage(0);
break;
}
}
[/code]