diff options
author | Andy Shaw <andy.shaw@digia.com> | 2014-03-27 14:48:54 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-29 21:23:18 +0100 |
commit | f2111ff1d7ce3b521f447baf1a6bb42bfad83d9d (patch) | |
tree | f9952cc1fb5ada5e8acc6768baa92975cde10ee5 /src | |
parent | 24ac9f518d382dc1a780f4eb80e5703637e557d2 (diff) |
NSScreen screens may be empty so add the main screen in that case
In some circumstances NSScreen screens can be empty yet there is still a
valid main screen so we prevent any problems arising by ensuring we work
with the main screen in that instance.
Task-number: QTBUG-37876
Change-Id: I5827009a9894eb8c1d4f5addc6c6f59e1c50c3d0
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaintegration.mm | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 65a9f87e2d..412818ae47 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -316,11 +316,17 @@ QCocoaIntegration *QCocoaIntegration::instance() */ void QCocoaIntegration::updateScreens() { - NSArray *screens = [NSScreen screens]; + NSArray *scrs = [NSScreen screens]; + NSMutableArray *screens = [NSMutableArray arrayWithArray:scrs]; + if ([screens count] == 0) + if ([NSScreen mainScreen]) + [screens addObject:[NSScreen mainScreen]]; + if ([screens count] == 0) + return; QSet<QCocoaScreen*> remainingScreens = QSet<QCocoaScreen*>::fromList(mScreens); QList<QPlatformScreen *> siblings; for (uint i = 0; i < [screens count]; i++) { - NSScreen* scr = [[NSScreen screens] objectAtIndex:i]; + NSScreen* scr = [screens objectAtIndex:i]; CGDirectDisplayID dpy = [[[scr deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; // If this screen is a mirror and is not the primary one of the mirror set, ignore it. if (CGDisplayIsInMirrorSet(dpy)) { |