From c4486be6bdb29625f2a1b0cd8cc4afd898781d17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 15 Apr 2025 23:58:16 +0200 Subject: [PATCH] macOS: Always override NSApp.appearance on requestColorScheme We can't compare to the effective appearance, as we'll then fail to set an explicit appearance if the requested appearance matches the current appearance, which results in the requested appearance not sticking when the system appearance changes. Pick-to: 6.8 6.5 Change-Id: Ibd8f7825051f1a67bed25a0abb2f1a13356f32d8 Reviewed-by: Timur Pocheptsov (cherry picked from commit 05e59e37c83a15997fa20c10566a7be693fa07bc) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/cocoa/qcocoatheme.mm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 6d15e8e5d2c..ed3be1d631e 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -490,8 +490,11 @@ void QCocoaTheme::requestColorScheme(Qt::ColorScheme scheme) case Qt::ColorScheme::Unknown: break; } - if (appearance != NSApp.effectiveAppearance) - NSApplication.sharedApplication.appearance = appearance; + + // Always override the appearance, even if it's the same + // as the current effective appearance, as otherwise the + // requested appearance won't stick on system theme changes. + NSApp.appearance = appearance; } /*