summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-04-30 13:29:54 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-30 23:30:56 +0200
commit130b579a160e623066d20bf144ca230b721f0461 (patch)
tree6be43d296a5163ed563a267158a39124bbdeeb04 /src/plugins/platforms
parent02e406ac50e7e57ad50d9596e9db1b32639a6a8f (diff)
iOS: Don't use -1 as magic value for UIDeviceOrientationFaceUp/Down
The check in [QIOSOrientationListener orientationChanged] ensured we never reported the two unsupported orientations through QPA, but we were reporting back the orientation through QIOSScreen::orientation() as well, and that didn't have a guard for -1. This resulted in crashes in client code that assumed the range of QScreen::orientation() was defined by the enum, such as the paintedwindow example. The listener now ignores the two unsupported orientations, which leaves us at the previous orientation. For the conversion function, we still have to support all UIDeviceOrientations, so we fall back to portrait for the two unsupported orientations. In the future we should consider caching the previous value explicitly, or fall back to the interface orientation. Change-Id: Ic19d0ce86b4ddea250ea927d5e8664396b2b68fd Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/ios/qiosglobal.mm3
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm15
2 files changed, 14 insertions, 4 deletions
diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm
index d26eca54e5..9abb4ba851 100644
--- a/src/plugins/platforms/ios/qiosglobal.mm
+++ b/src/plugins/platforms/ios/qiosglobal.mm
@@ -104,7 +104,8 @@ Qt::ScreenOrientation toQtScreenOrientation(UIDeviceOrientation uiDeviceOrientat
break;
case UIDeviceOrientationFaceUp:
case UIDeviceOrientationFaceDown:
- qtOrientation = static_cast<Qt::ScreenOrientation>(-1); // not supported ATM.
+ // FIXME: Use cached device orientation, or fall back to interface orientation
+ qtOrientation = Qt::PortraitOrientation;
break;
default:
qtOrientation = Qt::PortraitOrientation;
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index b73f9c3cbc..c1613c1af4 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -83,9 +83,18 @@
- (void) orientationChanged:(NSNotification *)notification
{
Q_UNUSED(notification);
- Qt::ScreenOrientation orientation = toQtScreenOrientation([UIDevice currentDevice].orientation);
- if (orientation != -1)
- QWindowSystemInterface::handleScreenOrientationChange(m_screen->screen(), orientation);
+
+ UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
+ switch (deviceOrientation) {
+ case UIDeviceOrientationFaceUp:
+ case UIDeviceOrientationFaceDown:
+ // We ignore these events, as iOS will send events with the 'regular'
+ // orientations alongside these two orientations.
+ return;
+ default:
+ Qt::ScreenOrientation screenOrientation = toQtScreenOrientation(deviceOrientation);
+ QWindowSystemInterface::handleScreenOrientationChange(m_screen->screen(), screenOrientation);
+ }
}
@end