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 <volker.hilsheimer@qt.io>
(cherry picked from commit dd49793bc3b4dd3808f0f24b717c442a5095db14)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2022-12-15 16:40:34 +01:00 committed by Qt Cherry-pick Bot
parent 0ef6a30790
commit 11ed1f643f

View File

@ -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]));
}