Win32: Keep GL error dialog from immediately closing

GL startup failures call Application.Clear(), which will at some point
before creating the error dialog post a WM_QUIT. When the dialog box's
message loop retrieves that message, it will shut down the dialog box,
thus ensuring that the user will never see it.
So before showing the dialog box, we have to dispatch any pending
messages, then retrieve the WM_QUIT ourselves, run the dialog box, then
re-post the WM_QUIT.
alternate-lights
Nicolas Hake 2015-02-18 23:02:02 +01:00
parent ba9a5fd757
commit ceeb322a87
1 changed files with 14 additions and 0 deletions

View File

@ -127,6 +127,16 @@ static INT_PTR CALLBACK GfxErrProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPAR
void ShowGfxErrorDialog()
{
// Application.Close will eventually post a quit message. We need to discard
// that, so DialogBox() doesn't immediately exit.
auto msg = MSG();
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != 0)
{
if (msg.message == WM_QUIT) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
int ret = DialogBox(Application.GetInstance(), MAKEINTRESOURCE(IDD_GFXERROR), NULL, GfxErrProcedure);
if (ret == 0 || ret == -1)
{
@ -144,6 +154,10 @@ void ShowGfxErrorDialog()
LogF("Error in GfxErrorDlg: %d - %s", err, StdStrBuf((wchar_t*)lpMsgBuf).getData());
LocalFree(lpMsgBuf);
}
// If we discarded a quit message, re-post it now
if (msg.message == WM_QUIT)
PostQuitMessage(msg.wParam);
}
#else