From 0033212b2f0facf676458cd9a217401bb203a4cf Mon Sep 17 00:00:00 2001 From: Stenzek Date: Tue, 21 Apr 2026 21:46:52 +1000 Subject: [PATCH] Qt: Don't read g_main_window on core thread --- src/core/system.cpp | 2 +- src/core/system_private.h | 2 +- src/duckstation-qt/mainwindow.cpp | 6 ++++-- src/duckstation-qt/mainwindow.h | 2 +- src/duckstation-qt/qthost.cpp | 6 ++---- src/duckstation-qt/qthost.h | 1 + src/duckstation-regtest/regtest_host.cpp | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/core/system.cpp b/src/core/system.cpp index 11922bfb3..adde23c29 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -1496,7 +1496,7 @@ void System::ApplySettings(bool display_osd_messages) } CheckForSettingsChanges(old_settings); - Host::CheckForSettingsChanges(old_settings); + Host::OnSettingsReloaded(); } void System::ReloadGameSettings(bool display_osd_messages) diff --git a/src/core/system_private.h b/src/core/system_private.h index d73c1c520..320026cc5 100644 --- a/src/core/system_private.h +++ b/src/core/system_private.h @@ -94,7 +94,7 @@ namespace Host { void LoadSettings(const SettingsInterface& si, std::unique_lock& lock); /// Called after settings are updated. -void CheckForSettingsChanges(const Settings& old_settings); +void OnSettingsReloaded(); /// Called when the VM is starting initialization, but has not been completed yet. void OnSystemStarting(); diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 714df84fd..4b86062a1 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -2606,6 +2606,7 @@ void MainWindow::connectSignals() connect(g_core_thread, &CoreThread::onReleaseRenderWindowRequested, this, &MainWindow::releaseRenderWindow); connect(g_core_thread, &CoreThread::onResizeRenderWindowRequested, this, &MainWindow::displayResizeRequested, Qt::BlockingQueuedConnection); + connect(g_core_thread, &CoreThread::settingsReloaded, this, &MainWindow::onSettingsReloaded); connect(g_core_thread, &CoreThread::systemStarting, this, &MainWindow::onSystemStarting); connect(g_core_thread, &CoreThread::systemStarted, this, &MainWindow::onSystemStarted); connect(g_core_thread, &CoreThread::systemStopping, this, &MainWindow::onSystemStopping); @@ -2787,7 +2788,8 @@ SettingsWindow* MainWindow::getSettingsWindow() if (!m_settings_window) { m_settings_window = new SettingsWindow(); - connect(m_settings_window, &SettingsWindow::debugOptionsVisibiltyChanged, this, &MainWindow::updateDebugMenuVisibility); + connect(m_settings_window, &SettingsWindow::debugOptionsVisibiltyChanged, this, + &MainWindow::updateDebugMenuVisibility); } return m_settings_window; @@ -3132,7 +3134,7 @@ void MainWindow::requestExit(bool allow_confirm /* = true */) requestShutdown(allow_confirm, true, g_settings.save_state_on_exit, true, true, true, true); } -void MainWindow::checkForSettingChanges() +void MainWindow::onSettingsReloaded() { #ifdef _WIN32 if (const bool disable_window_rounded_corners = diff --git a/src/duckstation-qt/mainwindow.h b/src/duckstation-qt/mainwindow.h index 3c5b4d888..d66e691f9 100644 --- a/src/duckstation-qt/mainwindow.h +++ b/src/duckstation-qt/mainwindow.h @@ -131,7 +131,6 @@ public: void requestShutdown(bool allow_confirm, bool allow_save_to_state, bool save_state, bool check_safety, bool check_pause, bool exit_fullscreen_ui, bool quit_afterwards); void requestExit(bool allow_confirm = true); - void checkForSettingChanges(); std::optional getWindowInfo(); void recreate(); @@ -236,6 +235,7 @@ private: void onSettingsResetToDefault(bool system, bool controller); void updateDebugMenuVisibility(); + void onSettingsReloaded(); void onSystemStarting(); void onSystemStarted(); void onSystemStopping(); diff --git a/src/duckstation-qt/qthost.cpp b/src/duckstation-qt/qthost.cpp index 97686d4ab..8a2eb018f 100644 --- a/src/duckstation-qt/qthost.cpp +++ b/src/duckstation-qt/qthost.cpp @@ -865,11 +865,9 @@ void Host::LoadSettings(const SettingsInterface& si, std::unique_locksettingsReloaded(); } void CoreThread::setDefaultSettings(bool host, bool system, bool controller) diff --git a/src/duckstation-qt/qthost.h b/src/duckstation-qt/qthost.h index 837c0002e..2c56739cb 100644 --- a/src/duckstation-qt/qthost.h +++ b/src/duckstation-qt/qthost.h @@ -104,6 +104,7 @@ Q_SIGNALS: void errorReported(const QString& title, const QString& message); void statusMessage(const QString& message); void settingsResetToDefault(bool host, bool system, bool controller); + void settingsReloaded(); void systemStarting(); void systemStarted(); void systemStopping(); diff --git a/src/duckstation-regtest/regtest_host.cpp b/src/duckstation-regtest/regtest_host.cpp index a506b41ba..89ec8881a 100644 --- a/src/duckstation-regtest/regtest_host.cpp +++ b/src/duckstation-regtest/regtest_host.cpp @@ -205,7 +205,7 @@ void Host::LoadSettings(const SettingsInterface& si, std::unique_lock