From 259df3ca0b860f6ea485e7121dd7931f6ee18464 Mon Sep 17 00:00:00 2001 From: Doris Verria Date: Thu, 2 Jun 2022 10:01:21 +0200 Subject: [PATCH] qiostheme: Don't determine the appearance mode from the keyWindow We were querying the traitCollection property of the application's keyWindow in order to determine the appearance mode (light/dark) of the app. However, the application may not have a keyWindow (visible window) by the time the we set up the appearance mode, so get that information from the last window in the application's windows array instead. Change-Id: If7435d9f565b5c594a26027c971c16a1e3a9af26 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qiostheme.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/ios/qiostheme.mm b/src/plugins/platforms/ios/qiostheme.mm index e9525a0275..a03a0b9515 100644 --- a/src/plugins/platforms/ios/qiostheme.mm +++ b/src/plugins/platforms/ios/qiostheme.mm @@ -140,7 +140,7 @@ QVariant QIOSTheme::themeHint(ThemeHint hint) const QPlatformTheme::Appearance QIOSTheme::appearance() const { if (@available(ios 12, *)) { - if (UIWindow *window = qt_apple_sharedApplication().keyWindow) { + if (UIWindow *window = qt_apple_sharedApplication().windows.lastObject) { return window.rootViewController.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? QPlatformTheme::Appearance::Dark