Workaround for misbehaving [UIScreen screens] in iOS 7.1

On iOS 7.1 [UIScreen screens] sometimes returns empty NSArray which
is against documentation and causes immediate application crash.
This workaround uses [UIScreen mainScreen] in case [UIScreen screens]
returns empty NSArray.

Task-number: QTBUG-37601

Change-Id: I9b341b9ca788b5fc81804489d2e0a3af84207168
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
This commit is contained in:
Eduard Veleba 2014-03-19 13:53:57 +01:00 committed by The Qt Project
parent aea988a3d9
commit 379238496d

View File

@ -120,7 +120,9 @@ static QString deviceModelIdentifier()
QIOSScreen::QIOSScreen(unsigned int screenIndex)
: QPlatformScreen()
, m_uiScreen([[UIScreen screens] objectAtIndex:qMin(NSUInteger(screenIndex), [[UIScreen screens] count] - 1)])
, m_uiScreen([[UIScreen screens] count] > screenIndex
? [[UIScreen screens] objectAtIndex:screenIndex]
: [UIScreen mainScreen])
, m_orientationListener(0)
{
QString deviceIdentifier = deviceModelIdentifier();