- delay the restart action from the error pane until after everything has been shut down.

This cannot be done from a place where the old instance still can write to the config file, which happens only in the shutdown process.
This commit is contained in:
Christoph Oelckers 2021-08-10 22:09:32 +02:00
parent b6156ac490
commit 4505bfa4b8
2 changed files with 19 additions and 5 deletions

View file

@ -545,6 +545,20 @@ LRESULT CALLBACK LConProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
//
//==========================================================================
bool restartrequest;
void CheckForRestart()
{
if (restartrequest)
{
HMODULE hModule = GetModuleHandleW(NULL);
WCHAR path[MAX_PATH];
GetModuleFileNameW(hModule, path, MAX_PATH);
ShellExecuteW(NULL, L"open", path, GetCommandLineW(), NULL, SW_SHOWNORMAL);
}
restartrequest = false;
}
INT_PTR CALLBACK ErrorPaneProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
@ -559,11 +573,7 @@ INT_PTR CALLBACK ErrorPaneProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara
{
if (LOWORD(wParam) == IDC_BUTTON1) // we pressed the restart button, so run GZDoom again
{
HMODULE hModule = GetModuleHandleW(NULL);
WCHAR path[MAX_PATH];
GetModuleFileNameW(hModule, path, MAX_PATH);
ShellExecuteW(NULL, L"open", path, GetCommandLineW(), NULL, SW_SHOWNORMAL);
restartrequest = true;
}
PostQuitMessage (0);
return TRUE;

View file

@ -3716,6 +3716,10 @@ int GameMain()
DeleteStartupScreen();
delete Args;
Args = nullptr;
#ifdef _WIN32
void CheckForRestart();
CheckForRestart();
#endif
return ret;
}