summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-11-18 11:32:32 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-20 14:10:18 +0100
commit837228151d085264e8244969349b3d68d6f9cc94 (patch)
treebc80191009e16a992b7da903c4507cecdf672090 /src/plugins/platforms/ios
parent49a3fe0cf8c8cddba6dacfb796e9db13c4ac74c6 (diff)
iOS: Don't keep around reference to a single QIOSViewController
We might have more of them in a multi-screen setup or when implementing support for modal windows using sub-viewcontrollers. Change-Id: Ibe98273a13af981fffe2704a2c05bfd9d3f3e9e0 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r--src/plugins/platforms/ios/qiosapplicationdelegate.h1
-rw-r--r--src/plugins/platforms/ios/qiosapplicationdelegate.mm5
-rw-r--r--src/plugins/platforms/ios/qiosglobal.h1
-rw-r--r--src/plugins/platforms/ios/qiosglobal.mm11
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm2
-rw-r--r--src/plugins/platforms/ios/qioswindow.h1
-rw-r--r--src/plugins/platforms/ios/qioswindow.mm19
7 files changed, 20 insertions, 20 deletions
diff --git a/src/plugins/platforms/ios/qiosapplicationdelegate.h b/src/plugins/platforms/ios/qiosapplicationdelegate.h
index bfe31af198..617b740d6e 100644
--- a/src/plugins/platforms/ios/qiosapplicationdelegate.h
+++ b/src/plugins/platforms/ios/qiosapplicationdelegate.h
@@ -47,6 +47,5 @@
@interface QIOSApplicationDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
-@property (strong, nonatomic) QIOSViewController *qiosViewController;
@end
diff --git a/src/plugins/platforms/ios/qiosapplicationdelegate.mm b/src/plugins/platforms/ios/qiosapplicationdelegate.mm
index 4d88faba75..775074baae 100644
--- a/src/plugins/platforms/ios/qiosapplicationdelegate.mm
+++ b/src/plugins/platforms/ios/qiosapplicationdelegate.mm
@@ -49,7 +49,6 @@
@implementation QIOSApplicationDelegate
@synthesize window;
-@synthesize qiosViewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
@@ -57,8 +56,7 @@
Q_UNUSED(launchOptions);
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
- self.qiosViewController = [[[QIOSViewController alloc] init] autorelease];
- self.window.rootViewController = self.qiosViewController;
+ self.window.rootViewController = [[[QIOSViewController alloc] init] autorelease];
self.window.hidden = NO;
@@ -67,7 +65,6 @@
- (void)dealloc
{
- [qiosViewController release];
[window release];
[super dealloc];
}
diff --git a/src/plugins/platforms/ios/qiosglobal.h b/src/plugins/platforms/ios/qiosglobal.h
index fd328c9171..41b0d7f93a 100644
--- a/src/plugins/platforms/ios/qiosglobal.h
+++ b/src/plugins/platforms/ios/qiosglobal.h
@@ -52,7 +52,6 @@ QT_BEGIN_NAMESPACE
class QPlatformScreen;
bool isQtApplication();
-QIOSViewController *qiosViewController();
CGRect toCGRect(const QRect &rect);
QRect fromCGRect(const CGRect &rect);
diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm
index 9b8462a6cc..be68e4d7d5 100644
--- a/src/plugins/platforms/ios/qiosglobal.mm
+++ b/src/plugins/platforms/ios/qiosglobal.mm
@@ -58,17 +58,6 @@ bool isQtApplication()
return isQt;
}
-QIOSViewController *qiosViewController()
-{
- // If Qt controls the application, we have created a root view controller were we place top-level
- // QWindows. Note that in a mixed native application, our view controller might later be removed or
- // added as a child of another controller. To protect against that, we keep an explicit pointer to the
- // view controller in cases where this is the controller we need to access.
- static QIOSViewController *c = isQtApplication() ?
- static_cast<QIOSApplicationDelegate *>([UIApplication sharedApplication].delegate).qiosViewController : nil;
- return c;
-}
-
CGRect toCGRect(const QRect &rect)
{
return CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index d57e678810..9d01053548 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -149,7 +149,7 @@ QIOSScreen::QIOSScreen(unsigned int screenIndex)
if (isQtApplication()) {
// When in a non-mixed environment, let QScreen follow the current interface orientation:
- setPrimaryOrientation(toQtScreenOrientation(UIDeviceOrientation(qiosViewController().interfaceOrientation)));
+ setPrimaryOrientation(toQtScreenOrientation(UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation)));
}
}
diff --git a/src/plugins/platforms/ios/qioswindow.h b/src/plugins/platforms/ios/qioswindow.h
index 5ded589205..6e8683af00 100644
--- a/src/plugins/platforms/ios/qioswindow.h
+++ b/src/plugins/platforms/ios/qioswindow.h
@@ -52,6 +52,7 @@ class QIOSWindow;
@interface UIView (QIOS)
@property(readonly) QWindow *qwindow;
+@property(readonly) UIViewController *viewController;
@end
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm
index 3d1fe935e5..b13ce456a4 100644
--- a/src/plugins/platforms/ios/qioswindow.mm
+++ b/src/plugins/platforms/ios/qioswindow.mm
@@ -348,6 +348,16 @@
return nil;
}
+- (UIViewController *)viewController
+{
+ id responder = self;
+ while ((responder = [responder nextResponder])) {
+ if ([responder isKindOfClass:UIViewController.class])
+ return responder;
+ }
+ return nil;
+}
+
@end
QT_BEGIN_NAMESPACE
@@ -404,7 +414,7 @@ void QIOSWindow::setVisible(bool visible)
requestActivateWindow();
} else {
// Activate top-most visible QWindow:
- NSArray *subviews = qiosViewController().view.subviews;
+ NSArray *subviews = m_view.viewController.view.subviews;
for (int i = int(subviews.count) - 1; i >= 0; --i) {
UIView *view = [subviews objectAtIndex:i];
if (!view.hidden) {
@@ -460,7 +470,12 @@ void QIOSWindow::setParent(const QPlatformWindow *parentWindow)
UIView *parentView = reinterpret_cast<UIView *>(parentWindow->winId());
[parentView addSubview:m_view];
} else if (isQtApplication()) {
- [qiosViewController().view addSubview:m_view];
+ for (UIWindow *uiWindow in [[UIApplication sharedApplication] windows]) {
+ if (uiWindow.screen == static_cast<QIOSScreen *>(screen())->uiScreen()) {
+ [uiWindow.rootViewController.view addSubview:m_view];
+ break;
+ }
+ }
}
}