diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 72eb6f4ddb..622fb61075 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -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); diff --git a/Windows/MainWindow.h b/Windows/MainWindow.h index 2d3b395e3f..f27a5c2ec6 100644 --- a/Windows/MainWindow.h +++ b/Windows/MainWindow.h @@ -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 { diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index b567ebd5e6..70f8d38713 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -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); } } diff --git a/Windows/main.cpp b/Windows/main.cpp index 8ecffc8354..dec7d3f5e1 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -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; }