From 05e59e37c83a15997fa20c10566a7be693fa07bc 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.9 6.8 6.5 Change-Id: Ibd8f7825051f1a67bed25a0abb2f1a13356f32d8 Reviewed-by: Timur Pocheptsov --- 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 52369f88815..3e7e01d8048 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -489,8 +489,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; } /*