summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
diff options
context:
space:
mode:
authorSamuel Gaist <samuel.gaist@edeltech.ch>2015-10-18 00:11:49 +0200
committerJake Petroules <jake.petroules@theqtcompany.com>2015-10-18 21:00:10 +0000
commitf7e9e035fd379ae4ad8cf2771e5ceca3e7602286 (patch)
tree17872bf5959472062f64a18576cc21a3d01a7ab6 /src/plugins/platforms/cocoa
parent27361eadf178e6544277118973a00151daebfc8a (diff)
Fix cocoa plugin build with OS X 10.8 SDK
With the 10.8 SDK, NSArray may not respond to firstObject which ends the build with an error. This implementation doesn't use it and also handles the case where no screen is available when calling qt_mac_mainScreenHeight Change-Id: Idce278423c37cc24d8fc31062a386e78d6487492 Reviewed-by: Jake Petroules <jake.petroules@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm
index 8ad80333f8..f51c21ee9b 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.mm
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm
@@ -634,10 +634,14 @@ QString qt_mac_applicationName()
int qt_mac_mainScreenHeight()
{
QMacAutoReleasePool pool;
- // The first screen in the screens array is documented
- // to have the (0,0) origin.
- NSRect screenFrame = [[[NSScreen screens] firstObject] frame];
- return screenFrame.size.height;
+ NSArray *screens = [NSScreen screens];
+ if ([screens count] > 0) {
+ // The first screen in the screens array is documented
+ // to have the (0,0) origin.
+ NSRect screenFrame = [[screens objectAtIndex: 0] frame];
+ return screenFrame.size.height;
+ }
+ return 0;
}
int qt_mac_flipYCoordinate(int y)