From d1c0eb22914645d021ad6414f3b88003a97a6566 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao Date: Mon, 9 Dec 2024 16:15:46 +0800 Subject: [PATCH] Windows theme: don't refresh anything unless theme really changed Refreshing the global theme may be expensive for large scale applications, and even if Windows sent corresponding message, it may be triggered by many reasons, not just the system theme, so no matter what we'd better add an extra check. Change-Id: I70847aa54fb4af37c81855a62330a4bce31ff104 Reviewed-by: Oliver Wolff (cherry picked from commit 9b924a4907a4a2b27ee52e807fd419caf219f655) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/windows/qwindowstheme.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 56f0db7c9e7..1379018793b 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -604,16 +604,16 @@ void QWindowsTheme::handleSettingsChanged() const auto newColorScheme = effectiveColorScheme(); const bool colorSchemeChanged = newColorScheme != oldColorScheme; s_colorScheme = newColorScheme; + if (!colorSchemeChanged) + return; auto integration = QWindowsIntegration::instance(); integration->updateApplicationBadge(); if (integration->darkModeHandling().testFlag(QWindowsApplication::DarkModeStyle)) { QWindowsTheme::instance()->refresh(); QWindowSystemInterface::handleThemeChange(); } - if (colorSchemeChanged) { - for (QWindowsWindow *w : std::as_const(QWindowsContext::instance()->windows())) - w->setDarkBorder(s_colorScheme == Qt::ColorScheme::Dark); - } + for (QWindowsWindow *w : std::as_const(QWindowsContext::instance()->windows())) + w->setDarkBorder(s_colorScheme == Qt::ColorScheme::Dark); } void QWindowsTheme::clearPalettes()