From 6892c3d09520db7d994f9c05557c0f3cab727bdc Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 23 Jun 2024 13:34:39 +1000 Subject: [PATCH] Qt: Work around theme swap bug with Classic Windows --- src/duckstation-qt/debuggerwindow.cpp | 2 -- src/duckstation-qt/mainwindow.cpp | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/duckstation-qt/debuggerwindow.cpp b/src/duckstation-qt/debuggerwindow.cpp index 3eefcb3e1..153c3422d 100644 --- a/src/duckstation-qt/debuggerwindow.cpp +++ b/src/duckstation-qt/debuggerwindow.cpp @@ -411,9 +411,7 @@ void DebuggerWindow::onMemorySearchStringChanged(const QString&) void DebuggerWindow::closeEvent(QCloseEvent* event) { g_emu_thread->disconnect(this); - g_emu_thread->setSystemPaused(true, true); Host::RunOnCPUThread(&CPU::ClearBreakpoints); - g_emu_thread->setSystemPaused(false); QMainWindow::closeEvent(event); emit closed(); } diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 195ffeb94..0f9c49767 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -53,6 +54,7 @@ #ifdef _WIN32 #include "common/windows_headers.h" #include +#include #endif #ifdef __APPLE__ @@ -718,6 +720,9 @@ void MainWindow::quit() void MainWindow::recreate() { + // Remove subwindows before switching to surfaceless, because otherwise e.g. the debugger can cause funkyness. + destroySubWindows(); + const bool was_display_created = m_display_created; if (was_display_created) { @@ -2199,9 +2204,22 @@ void MainWindow::connectSignals() void MainWindow::setTheme(const QString& theme) { + [[maybe_unused]] const QString old_theme = + QString::fromStdString(Host::GetStringSettingValue("UI", "Theme", InterfaceSettingsWidget::DEFAULT_THEME_NAME)); + Host::SetBaseStringSettingValue("UI", "Theme", theme.toUtf8().constData()); Host::CommitBaseSettingChanges(); updateTheme(); + +#ifdef _WIN32 + if (((old_theme.isEmpty() && QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows11) || + old_theme == QStringLiteral("windowsvista")) != + ((old_theme.isEmpty() && QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows11) || + theme == QStringLiteral("windowsvista"))) + { + recreate(); + } +#endif } void MainWindow::updateTheme()