Qt: Fix inability to exit with HC mode active

pull/3498/head
Stenzek 4 months ago
parent 501380ec7c
commit a2222d805b
No known key found for this signature in database

@ -143,7 +143,7 @@ void DisplayWidget::handleCloseEvent(QCloseEvent* event)
{ {
QMetaObject::invokeMethod(g_main_window, "requestShutdown", Qt::QueuedConnection, Q_ARG(bool, true), 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, 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 else
{ {

@ -2299,9 +2299,9 @@ void MainWindow::connectSignals()
connect(m_ui.actionAddGameDirectory, &QAction::triggered, connect(m_ui.actionAddGameDirectory, &QAction::triggered,
[this]() { getSettingsWindow()->getGameListSettingsWidget()->addSearchDirectory(this); }); [this]() { getSettingsWindow()->getGameListSettingsWidget()->addSearchDirectory(this); });
connect(m_ui.actionPowerOff, &QAction::triggered, 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, 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.actionReset, &QAction::triggered, this, []() { g_emu_thread->resetSystem(true); });
connect(m_ui.actionPause, &QAction::toggled, this, &MainWindow::onPauseActionToggled); connect(m_ui.actionPause, &QAction::toggled, this, &MainWindow::onPauseActionToggled);
connect(m_ui.actionScreenshot, &QAction::triggered, g_emu_thread, &EmuThread::saveScreenshot); 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 // 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(); 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) void MainWindow::changeEvent(QEvent* event)
@ -2830,7 +2830,7 @@ void MainWindow::runOnUIThread(const std::function<void()>& func)
} }
void MainWindow::requestShutdown(bool allow_confirm, bool allow_save_to_state, bool save_state, bool check_safety, 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()) 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)) if (!m_is_closing && s_system_valid && allow_confirm && Host::GetBoolSettingValue("Main", "ConfirmPowerOff", true))
{ {
// Hardcore mode restrictions. // 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( Host::RunOnCPUThread(
[allow_confirm, allow_save_to_state, save_state, check_safety, exit_fullscreen_ui, quit_afterwards]() { [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( Host::RunOnUIThread(
[allow_confirm, allow_save_to_state, save_state, check_safety, exit_fullscreen_ui, quit_afterwards]() { [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); 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 */) void MainWindow::requestExit(bool allow_confirm /* = true */)
{ {
// this is block, because otherwise closeEvent() will also prompt // 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() void MainWindow::checkForSettingChanges()

@ -123,7 +123,7 @@ public Q_SLOTS:
void runOnUIThread(const std::function<void()>& func); void runOnUIThread(const std::function<void()>& func);
void requestShutdown(bool allow_confirm, bool allow_save_to_state, bool save_state, bool check_safety, 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 requestExit(bool allow_confirm = true);
void checkForSettingChanges(); void checkForSettingChanges();
std::optional<WindowInfo> getWindowInfo(); std::optional<WindowInfo> getWindowInfo();

@ -537,7 +537,6 @@ bool QtHost::SetCriticalFolders()
|| StringUtil::StartsWithNoCase(EmuFolders::AppRoot, "/usr/lib") || StringUtil::StartsWithNoCase(EmuFolders::AppRoot, "/usr/lib")
#endif #endif
) )
{ {
QMessageBox::critical(nullptr, QStringLiteral("Error"), QMessageBox::critical(nullptr, QStringLiteral("Error"),
QStringLiteral("Resources are missing, your installation is incomplete.")); 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), 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, 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) void Host::RequestResetSettings(bool system, bool controller)

Loading…
Cancel
Save