From a2222d805b0eb91389944270ee1d04c615cbd205 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 3 Aug 2025 15:11:59 +1000 Subject: [PATCH] Qt: Fix inability to exit with HC mode active --- src/duckstation-qt/displaywidget.cpp | 2 +- src/duckstation-qt/mainwindow.cpp | 16 ++++++++-------- src/duckstation-qt/mainwindow.h | 2 +- src/duckstation-qt/qthost.cpp | 3 +-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/duckstation-qt/displaywidget.cpp b/src/duckstation-qt/displaywidget.cpp index 71bbf3322..e7f42734e 100644 --- a/src/duckstation-qt/displaywidget.cpp +++ b/src/duckstation-qt/displaywidget.cpp @@ -143,7 +143,7 @@ void DisplayWidget::handleCloseEvent(QCloseEvent* event) { 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, true), - Q_ARG(bool, false)); + Q_ARG(bool, true), Q_ARG(bool, false)); } else { diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index f21ed844b..aefc4f439 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -2299,9 +2299,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, true, false, false); }); + [this]() { requestShutdown(true, true, g_settings.save_state_on_exit, true, true, false, false); }); connect(m_ui.actionPowerOffWithoutSaving, &QAction::triggered, this, - [this]() { requestShutdown(false, false, false, true, false, false); }); + [this]() { requestShutdown(false, false, false, true, false, false, false); }); connect(m_ui.actionReset, &QAction::triggered, this, []() { g_emu_thread->resetSystem(true); }); connect(m_ui.actionPause, &QAction::toggled, this, &MainWindow::onPauseActionToggled); connect(m_ui.actionScreenshot, &QAction::triggered, g_emu_thread, &EmuThread::saveScreenshot); @@ -2710,10 +2710,10 @@ void MainWindow::closeEvent(QCloseEvent* event) } // But if there is, we have to cancel the action, regardless of whether we ended exiting - // or not. The window still needs to be visible while GS is shutting down. + // or not. The window still needs to be visible while the system shuts down. event->ignore(); - requestShutdown(true, true, g_settings.save_state_on_exit, true, true, true); + requestShutdown(true, true, g_settings.save_state_on_exit, true, true, true, true); } void MainWindow::changeEvent(QEvent* event) @@ -2830,7 +2830,7 @@ void MainWindow::runOnUIThread(const std::function& func) } void MainWindow::requestShutdown(bool allow_confirm, bool allow_save_to_state, bool save_state, bool check_safety, - bool exit_fullscreen_ui, bool quit_afterwards) + bool check_pause, bool exit_fullscreen_ui, bool quit_afterwards) { if (!QtHost::IsSystemValidOrStarting()) { @@ -2851,7 +2851,7 @@ void MainWindow::requestShutdown(bool allow_confirm, bool allow_save_to_state, b if (!m_is_closing && s_system_valid && allow_confirm && Host::GetBoolSettingValue("Main", "ConfirmPowerOff", true)) { // Hardcore mode restrictions. - if (!s_system_paused && s_achievements_hardcore_mode && allow_confirm) + if (check_pause && !s_system_paused && s_achievements_hardcore_mode && allow_confirm) { Host::RunOnCPUThread( [allow_confirm, allow_save_to_state, save_state, check_safety, exit_fullscreen_ui, quit_afterwards]() { @@ -2860,7 +2860,7 @@ void MainWindow::requestShutdown(bool allow_confirm, bool allow_save_to_state, b Host::RunOnUIThread( [allow_confirm, allow_save_to_state, save_state, check_safety, exit_fullscreen_ui, quit_afterwards]() { - g_main_window->requestShutdown(allow_confirm, allow_save_to_state, save_state, check_safety, + g_main_window->requestShutdown(allow_confirm, allow_save_to_state, save_state, check_safety, false, exit_fullscreen_ui, quit_afterwards); }); }); @@ -2915,7 +2915,7 @@ void MainWindow::requestShutdown(bool allow_confirm, bool allow_save_to_state, b void MainWindow::requestExit(bool allow_confirm /* = true */) { // this is block, because otherwise closeEvent() will also prompt - requestShutdown(allow_confirm, true, g_settings.save_state_on_exit, true, true, true); + requestShutdown(allow_confirm, true, g_settings.save_state_on_exit, true, true, true, true); } void MainWindow::checkForSettingChanges() diff --git a/src/duckstation-qt/mainwindow.h b/src/duckstation-qt/mainwindow.h index 29c76e4f8..973408180 100644 --- a/src/duckstation-qt/mainwindow.h +++ b/src/duckstation-qt/mainwindow.h @@ -123,7 +123,7 @@ public Q_SLOTS: void runOnUIThread(const std::function& func); void requestShutdown(bool allow_confirm, bool allow_save_to_state, bool save_state, bool check_safety, - bool exit_fullscreen_ui, bool quit_afterwards); + bool check_pause, bool exit_fullscreen_ui, bool quit_afterwards); 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 d9b28530e..6e3afcd4c 100644 --- a/src/duckstation-qt/qthost.cpp +++ b/src/duckstation-qt/qthost.cpp @@ -537,7 +537,6 @@ bool QtHost::SetCriticalFolders() || StringUtil::StartsWithNoCase(EmuFolders::AppRoot, "/usr/lib") #endif ) - { QMessageBox::critical(nullptr, QStringLiteral("Error"), QStringLiteral("Resources are missing, your installation is incomplete.")); @@ -2943,7 +2942,7 @@ void Host::RequestSystemShutdown(bool allow_confirm, bool save_state, bool check 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), - Q_ARG(bool, false), Q_ARG(bool, false)); + Q_ARG(bool, true), Q_ARG(bool, false), Q_ARG(bool, false)); } void Host::RequestResetSettings(bool system, bool controller)