diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-11-03 17:14:34 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-11-04 05:06:03 +0100 |
commit | 36852d78bfe20bbb5eebc2bd8cf9ee4ebae4db50 (patch) | |
tree | 8a178a757618ae8db0165c327717ba58fec0cb2d /src/plugins/platforms | |
parent | f2d150242907c3d5c20522ffff3a7e46330ec221 (diff) |
iOS: Defer restoring screen mirroring until next runloop pass
Associating the UIWindow with a different screen will trigger layout
of the child views of the window, including the view that we're in
the process of removing, which doesn't have a platform window anymore.
Instead of protecting every possible code path in the view code
with checks for a platform window we defer the restoring of
mirror mode until after the view has been removed.
Pick-to: 6.2 5.15
Task-number: QTBUG-94530
Change-Id: I8c66106cafa67e06721e621c019b2d10acf02326
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/ios/qiosviewcontroller.mm | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index 7aeb3b9ca6..64d42d6b65 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -147,9 +147,13 @@ UIWindow *uiWindow = self.window; if (uiWindow.screen != [UIScreen mainScreen] && self.subviews.count == 1) { - // Removing the last view of an external screen, go back to mirror mode - uiWindow.screen = [UIScreen mainScreen]; - uiWindow.hidden = YES; + // We're about to remove the last view of an external screen, so go back + // to mirror mode, but defer it until after the view has been removed, + // to ensure that we don't try to layout the view that's being removed. + dispatch_async(dispatch_get_main_queue(), ^{ + uiWindow.screen = [UIScreen mainScreen]; + uiWindow.hidden = YES; + }); } } |