From 11ed1f643fbb14d7d7dd7d2949e720ff1ed1a0ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 15 Dec 2022 16:40:34 +0100 Subject: [PATCH] iOS: Don't assume screens will not be connected before QIOSIntegration When an external screen is connected to an iPad, and the application is starting up on that screen, we will get a connection notification about that screen as part of the initial bootstrap of UIApplicationMain, before we call the user's main(). Since we initialize and add all available screen on QIOSIntegration creation, we can just ignore the early connection notification. This avoids a crash, but the window will not show anything on the external screen, which is a separate issue. Fixes: QTBUG-106701 Change-Id: I9e0a9736bf602277316bd004e0d01c640feaf319 Reviewed-by: Volker Hilsheimer (cherry picked from commit dd49793bc3b4dd3808f0f24b717c442a5095db14) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/ios/qiosscreen.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index d1ec359f9f5..be17972d367 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -73,8 +73,8 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen) + (void)screenConnected:(NSNotification*)notification { - Q_ASSERT_X(QIOSIntegration::instance(), Q_FUNC_INFO, - "Screen connected before QIOSIntegration creation"); + if (!QIOSIntegration::instance()) + return; // Will be added when QIOSIntegration is created QWindowSystemInterface::handleScreenAdded(new QIOSScreen([notification object])); }