summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/qiosintegration.mm
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@theqtcompany.com>2014-11-24 11:21:07 +0100
committerJani Heikkinen <jani.heikkinen@theqtcompany.com>2014-11-26 10:47:19 +0100
commit503b9c318164122b0111f6d0d9d3b680c8ca016f (patch)
tree2fb6edb1b7f081de686f207cd297a5f429f5164e /src/plugins/platforms/ios/qiosintegration.mm
parent89867f86fc5766c30253748560b8c16f721e808e (diff)
iOS: fallback to use [UIScreen mainScreen] when [UIScreen screens] fail
On iOS 7.1 [UIScreen screens] sometimes (and against documentation) returns an empty array, which will lead to a crash. This patch will add a fallback path that uses [UIScreen mainScreen] instead when the screen count is 0. Task-number: QTBUG-42345 Change-Id: Ie72578ff7ecd0c8fbc971fafea45047bf1347cd9 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Diffstat (limited to 'src/plugins/platforms/ios/qiosintegration.mm')
-rw-r--r--src/plugins/platforms/ios/qiosintegration.mm8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm
index 9a722ead37..461f160892 100644
--- a/src/plugins/platforms/ios/qiosintegration.mm
+++ b/src/plugins/platforms/ios/qiosintegration.mm
@@ -88,7 +88,13 @@ QIOSIntegration::QIOSIntegration()
// Set current directory to app bundle folder
QDir::setCurrent(QString::fromUtf8([[[NSBundle mainBundle] bundlePath] UTF8String]));
- for (UIScreen *screen in [UIScreen screens])
+ NSMutableArray *screens = [[[UIScreen screens] mutableCopy] autorelease];
+ if (![screens containsObject:[UIScreen mainScreen]]) {
+ // Fallback for iOS 7.1 (QTBUG-42345)
+ [screens insertObject:[UIScreen mainScreen] atIndex:0];
+ }
+
+ for (UIScreen *screen in screens)
addScreen(new QIOSScreen(screen));
// Depends on a primary screen being present