More confirmexit fixes

This commit is contained in:
Henrik Rydgård 2025-02-17 16:01:58 -06:00
parent dd119f5971
commit 74ee868cdb
4 changed files with 10 additions and 7 deletions

View file

@ -819,12 +819,12 @@ namespace MainWindow
bool ConfirmExit(HWND hWnd) {
const GlobalUIState state = GetUIState();
if (state == UISTATE_MENU || state == UISTATE_EXIT) {
return false;
return true;
}
std::string confirmExitMessage = GetConfirmExitMessage();
if (confirmExitMessage.empty()) {
return false;
return true;
}
auto di = GetI18NCategory(I18NCat::DIALOG);
auto mm = GetI18NCategory(I18NCat::MAINMENU);
@ -1161,6 +1161,10 @@ namespace MainWindow
UpdateSwitchUMD();
break;
case WM_USER_DESTROY:
DestroyWindow(hWnd);
break;
case WM_MENUSELECT:
// Called when a menu is opened. Also when an item is selected, but meh.
UpdateMenus(true);

View file

@ -20,6 +20,7 @@ namespace MainWindow
WM_USER_RESTART_EMUTHREAD = WM_USER + 106,
WM_USER_SWITCHUMD_UPDATED = WM_USER + 107,
WM_USER_RUN_CALLBACK = WM_USER + 108,
WM_USER_DESTROY = WM_USER + 109,
};
enum {

View file

@ -443,7 +443,7 @@ namespace MainWindow {
PostMessage(MainWindow::GetHWND(), WM_USER_RESTART_EMUTHREAD, 0, 0);
} else {
g_Config.bRestartRequired = true;
DestroyWindow(MainWindow::GetHWND());
PostMessage(MainWindow::GetHWND(), WM_USER_DESTROY, 0, 0);
}
}

View file

@ -537,8 +537,7 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
switch (type) {
case SystemRequestType::EXIT_APP:
if (!NativeIsRestarting()) {
// Not on the window thread here, so postmessage wm_close is pretty reasonable.
PostMessage(MainWindow::GetHWND(), WM_CLOSE, 0, 0);
PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_DESTROY, 0, 0);
}
return true;
case SystemRequestType::RESTART_APP:
@ -550,8 +549,7 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_RESTART_EMUTHREAD, 0, 0);
} else {
g_Config.bRestartRequired = true;
// Not on the window thread here, so postmessage wm_close is pretty reasonable.
PostMessage(MainWindow::GetHWND(), WM_CLOSE, 0, 0);
PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_DESTROY, 0, 0);
}
return true;
}