summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/qiosscreen.mm
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-05-07 16:17:21 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-06-05 12:24:05 +0000
commita15db3a81aa6053d1b3ce346b4cb160c064a2c43 (patch)
tree69b6323b3d79207748ec3907dd9ff796818df92d /src/plugins/platforms/ios/qiosscreen.mm
parent80583809041717f499c46aeb9b23f97562bcc9e5 (diff)
iOS: Guard all uses of APIs not available in application extensions
Change-Id: Ic058a0c07f6cdd0a015f46db96fce1536a712711 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/plugins/platforms/ios/qiosscreen.mm')
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index c394592d76..f367d1e75e 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -46,6 +46,8 @@
#include "qiosviewcontroller.h"
#include "quiview.h"
+#include <QtCore/private/qcore_mac_p.h>
+
#include <QtGui/private/qwindow_p.h>
#include <private/qcoregraphics_p.h>
@@ -271,17 +273,19 @@ QIOSScreen::QIOSScreen(UIScreen *screen)
m_physicalDpi = 96;
}
- for (UIWindow *existingWindow in [[UIApplication sharedApplication] windows]) {
- if (existingWindow.screen == m_uiScreen) {
- m_uiWindow = [m_uiWindow retain];
- break;
+ if (!qt_apple_isApplicationExtension()) {
+ for (UIWindow *existingWindow in qt_apple_sharedApplication().windows) {
+ if (existingWindow.screen == m_uiScreen) {
+ m_uiWindow = [m_uiWindow retain];
+ break;
+ }
}
- }
- if (!m_uiWindow) {
- // Create a window and associated view-controller that we can use
- m_uiWindow = [[QUIWindow alloc] initWithFrame:[m_uiScreen bounds]];
- m_uiWindow.rootViewController = [[[QIOSViewController alloc] initWithQIOSScreen:this] autorelease];
+ if (!m_uiWindow) {
+ // Create a window and associated view-controller that we can use
+ m_uiWindow = [[QUIWindow alloc] initWithFrame:[m_uiScreen bounds]];
+ m_uiWindow.rootViewController = [[[QIOSViewController alloc] initWithQIOSScreen:this] autorelease];
+ }
}
updateProperties();
@@ -327,17 +331,20 @@ void QIOSScreen::updateProperties()
#ifndef Q_OS_TVOS
if (m_uiScreen == [UIScreen mainScreen]) {
- Qt::ScreenOrientation statusBarOrientation = toQtScreenOrientation(UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation));
-
QIOSViewController *qtViewController = [m_uiWindow.rootViewController isKindOfClass:[QIOSViewController class]] ?
static_cast<QIOSViewController *>(m_uiWindow.rootViewController) : nil;
if (qtViewController.lockedOrientation) {
+ Q_ASSERT(!qt_apple_isApplicationExtension());
+
// Setting the statusbar orientation (content orientation) on will affect the screen geometry,
// which is not what we want. We want to reflect the screen geometry based on the locked orientation,
// and adjust the available geometry based on the repositioned status bar for the current status
// bar orientation.
+ Qt::ScreenOrientation statusBarOrientation = toQtScreenOrientation(
+ UIDeviceOrientation(qt_apple_sharedApplication().statusBarOrientation));
+
Qt::ScreenOrientation lockedOrientation = toQtScreenOrientation(UIDeviceOrientation(qtViewController.lockedOrientation));
QTransform transform = transformBetween(lockedOrientation, statusBarOrientation, m_geometry).inverted();
@@ -487,8 +494,8 @@ Qt::ScreenOrientation QIOSScreen::orientation() const
// the orientation the application was started up in (which may not match
// the physical orientation of the device, but typically does unless the
// application has been locked to a subset of the available orientations).
- if (deviceOrientation == UIDeviceOrientationUnknown)
- deviceOrientation = UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation);
+ if (deviceOrientation == UIDeviceOrientationUnknown && !qt_apple_isApplicationExtension())
+ deviceOrientation = UIDeviceOrientation(qt_apple_sharedApplication().statusBarOrientation);
// If the device reports face up or face down orientations, we can't map
// them to Qt orientations, so we pretend we're in the same orientation