diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index 6cee31a3e..5322fb2c6 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -1600,7 +1600,7 @@ void FullscreenUI::RequestShutdown(bool save_state) ConfirmIfSavingMemoryCards(FSUI_STR("shut down"), [save_state](bool result) { if (result) - Host::RunOnCPUThread([save_state]() { Host::RequestSystemShutdown(false, save_state); }); + Host::RunOnCPUThread([save_state]() { Host::RequestSystemShutdown(false, save_state, false); }); else ClosePauseMenuImmediately(); }); diff --git a/src/core/hotkeys.cpp b/src/core/hotkeys.cpp index f5f1b5f7d..00b672946 100644 --- a/src/core/hotkeys.cpp +++ b/src/core/hotkeys.cpp @@ -200,7 +200,7 @@ DEFINE_HOTKEY("TogglePause", TRANSLATE_NOOP("Hotkeys", "General"), TRANSLATE_NOO DEFINE_HOTKEY("PowerOff", TRANSLATE_NOOP("Hotkeys", "General"), TRANSLATE_NOOP("Hotkeys", "Power Off System"), [](s32 pressed) { if (!pressed && CanPause()) - Host::RequestSystemShutdown(true, g_settings.save_state_on_exit); + Host::RequestSystemShutdown(true, g_settings.save_state_on_exit, true); }) DEFINE_HOTKEY("OpenPauseMenu", TRANSLATE_NOOP("Hotkeys", "General"), TRANSLATE_NOOP("Hotkeys", "Open Pause Menu"), diff --git a/src/core/system.h b/src/core/system.h index 548a35f30..fb32f2b1c 100644 --- a/src/core/system.h +++ b/src/core/system.h @@ -445,6 +445,6 @@ void UpdateRichPresence(bool update_session_time); namespace Host { /// Requests shut down of the current virtual machine. -void RequestSystemShutdown(bool allow_confirm, bool save_state); +void RequestSystemShutdown(bool allow_confirm, bool save_state, bool check_memcard_busy); } // namespace Host diff --git a/src/duckstation-mini/mini_host.cpp b/src/duckstation-mini/mini_host.cpp index ae3974654..63a99bce7 100644 --- a/src/duckstation-mini/mini_host.cpp +++ b/src/duckstation-mini/mini_host.cpp @@ -1291,7 +1291,7 @@ void Host::RequestExitBigPicture() // sorry dude } -void Host::RequestSystemShutdown(bool allow_confirm, bool save_state) +void Host::RequestSystemShutdown(bool allow_confirm, bool save_state, bool check_memcard_busy) { // TODO: Confirm if (System::IsValid()) diff --git a/src/duckstation-qt/displaywidget.cpp b/src/duckstation-qt/displaywidget.cpp index b40777656..01490a5f6 100644 --- a/src/duckstation-qt/displaywidget.cpp +++ b/src/duckstation-qt/displaywidget.cpp @@ -140,7 +140,7 @@ void DisplayWidget::handleCloseEvent(QCloseEvent* event) if (QtHost::IsSystemValid() && !isActuallyFullscreen()) { QMetaObject::invokeMethod(g_main_window, "requestShutdown", Qt::QueuedConnection, Q_ARG(bool, true), - Q_ARG(bool, true), Q_ARG(bool, false)); + Q_ARG(bool, true), Q_ARG(bool, false), Q_ARG(bool, true)); } else { diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 9c82f3594..35ebc5a52 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -2072,9 +2072,9 @@ void MainWindow::connectSignals() connect(m_ui.actionAddGameDirectory, &QAction::triggered, [this]() { getSettingsWindow()->getGameListSettingsWidget()->addSearchDirectory(this); }); connect(m_ui.actionPowerOff, &QAction::triggered, this, - [this]() { requestShutdown(true, true, g_settings.save_state_on_exit); }); + [this]() { requestShutdown(true, true, g_settings.save_state_on_exit, true); }); connect(m_ui.actionPowerOffWithoutSaving, &QAction::triggered, this, - [this]() { requestShutdown(false, false, false); }); + [this]() { requestShutdown(false, false, false, true); }); connect(m_ui.actionReset, &QAction::triggered, this, []() { g_emu_thread->resetSystem(true); }); connect(m_ui.actionPause, &QAction::toggled, this, [](bool active) { g_emu_thread->setSystemPaused(active); }); connect(m_ui.actionScreenshot, &QAction::triggered, g_emu_thread, &EmuThread::saveScreenshot); @@ -2499,7 +2499,7 @@ void MainWindow::closeEvent(QCloseEvent* event) event->ignore(); // Exit cancelled? - if (!requestShutdown(true, true, g_settings.save_state_on_exit)) + if (!requestShutdown(true, true, g_settings.save_state_on_exit, true)) return; // Application will be exited in VM stopped handler. @@ -2619,8 +2619,7 @@ void MainWindow::runOnUIThread(const std::function& func) func(); } -bool MainWindow::requestShutdown(bool allow_confirm /* = true */, bool allow_save_to_state /* = true */, - bool save_state /* = true */) +bool MainWindow::requestShutdown(bool allow_confirm, bool allow_save_to_state, bool save_state, bool check_memcard_busy) { if (!s_system_valid) return true; @@ -2666,14 +2665,14 @@ bool MainWindow::requestShutdown(bool allow_confirm /* = true */, bool allow_sav updateWindowState(true); // Now we can actually shut down the VM. - g_emu_thread->shutdownSystem(save_state, true); + g_emu_thread->shutdownSystem(save_state, check_memcard_busy); return true; } void MainWindow::requestExit(bool allow_confirm /* = true */) { // this is block, because otherwise closeEvent() will also prompt - if (!requestShutdown(allow_confirm, true, g_settings.save_state_on_exit)) + if (!requestShutdown(allow_confirm, true, g_settings.save_state_on_exit, true)) return; // VM stopped signal won't have fired yet, so queue an exit if we still have one. diff --git a/src/duckstation-qt/mainwindow.h b/src/duckstation-qt/mainwindow.h index 0a2f4f489..917d16255 100644 --- a/src/duckstation-qt/mainwindow.h +++ b/src/duckstation-qt/mainwindow.h @@ -117,7 +117,7 @@ public Q_SLOTS: void cancelGameListRefresh(); void runOnUIThread(const std::function& func); - bool requestShutdown(bool allow_confirm = true, bool allow_save_to_state = true, bool save_state = true); + bool requestShutdown(bool allow_confirm, bool allow_save_to_state, bool save_state, bool check_memcard_busy); void requestExit(bool allow_confirm = true); void checkForSettingChanges(); std::optional getWindowInfo(); diff --git a/src/duckstation-qt/qthost.cpp b/src/duckstation-qt/qthost.cpp index 5d38cdcef..c2ee72234 100644 --- a/src/duckstation-qt/qthost.cpp +++ b/src/duckstation-qt/qthost.cpp @@ -2567,20 +2567,13 @@ bool QtHost::ShouldShowDebugOptions() return Host::GetBaseBoolSettingValue("Main", "ShowDebugMenu", false); } -void Host::RequestSystemShutdown(bool allow_confirm, bool save_state) +void Host::RequestSystemShutdown(bool allow_confirm, bool save_state, bool check_memcard_busy) { if (!System::IsValid()) return; - if (!allow_confirm) - { - g_emu_thread->shutdownSystem(save_state, false); - } - else - { - QMetaObject::invokeMethod(g_main_window, "requestShutdown", Qt::QueuedConnection, Q_ARG(bool, allow_confirm), - Q_ARG(bool, true), Q_ARG(bool, save_state)); - } + QMetaObject::invokeMethod(g_main_window, "requestShutdown", Qt::QueuedConnection, Q_ARG(bool, allow_confirm), + Q_ARG(bool, true), Q_ARG(bool, save_state), Q_ARG(bool, check_memcard_busy)); } void Host::RequestResetSettings(bool system, bool controller) diff --git a/src/duckstation-regtest/regtest_host.cpp b/src/duckstation-regtest/regtest_host.cpp index 68eb5da5b..62635af50 100644 --- a/src/duckstation-regtest/regtest_host.cpp +++ b/src/duckstation-regtest/regtest_host.cpp @@ -360,7 +360,7 @@ void Host::RequestExitBigPicture() // } -void Host::RequestSystemShutdown(bool allow_confirm, bool save_state) +void Host::RequestSystemShutdown(bool allow_confirm, bool save_state, bool check_memcard_busy) { // }