From 8f46cb3ade5a57506afcd1589e489bbcf38ca7f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 27 Aug 2013 12:43:16 +0200 Subject: [PATCH] Keep Cocoa screen list in sync on screen connect. The backtrace in QTBUG-33012 indicates that the screen list is getting out of sync on plugging/unplugging an external monitor. This happens on 10.9 only. Check if we are about to out of bounds access the screen list; call updateScreens() which will add the new screen. Task-number: QTBUG-33012 Change-Id: Id1acc3baca9e60e7f2a83188d66cdf9d322a582c Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoaintegration.h | 2 +- src/plugins/platforms/cocoa/qcocoaintegration.mm | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h index 7831888da16..8620ef4267b 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.h +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -125,7 +125,7 @@ public: QList possibleKeys(const QKeyEvent *event) const; void updateScreens(); - QCocoaScreen *screenAtIndex(int index) const { return mScreens.at(index); } + QCocoaScreen *screenAtIndex(int index); private: diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index fad743439e3..5f0ad242412 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -343,6 +343,14 @@ void QCocoaIntegration::updateScreens() screen->setVirtualSiblings(siblings); } +QCocoaScreen *QCocoaIntegration::screenAtIndex(int index) +{ + if (index >= mScreens.count()) + updateScreens(); + + return mScreens.at(index); +} + bool QCocoaIntegration::hasCapability(QPlatformIntegration::Capability cap) const { switch (cap) {