summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/qiosglobal.mm
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2013-04-15 15:15:36 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-19 12:03:36 +0200
commit5ea3845bd0bf4dec9828270ab18e7c94d596975e (patch)
tree2277c94fa2cff0ea0760a56eb31c2629e57a4578 /src/plugins/platforms/ios/qiosglobal.mm
parent963b8dabef3b82f6d7cdda0669373ceae1629699 (diff)
iOS: use an explicit pointer to qiosViewController
As it stood, we always relied on the root view controller being a QIOSViewController if isQtApplication() returned true. For mixed application, this might not always be true as native code can choose to replace the root view controller at times, or even rip it out, and place it as a child of another (e.g UISplitViewController). This change will give an extra protection against that. Change-Id: I0cb85796a8b82f9037c32f9e85e04e1dc7aad8e2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Diffstat (limited to 'src/plugins/platforms/ios/qiosglobal.mm')
-rw-r--r--src/plugins/platforms/ios/qiosglobal.mm8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm
index 5860078372..d26eca54e5 100644
--- a/src/plugins/platforms/ios/qiosglobal.mm
+++ b/src/plugins/platforms/ios/qiosglobal.mm
@@ -58,10 +58,14 @@ bool isQtApplication()
return isQt;
}
-QIOSViewController *rootViewController()
+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<QIOSViewController *>([UIApplication sharedApplication].delegate.window.rootViewController) : nil;
+ static_cast<QIOSApplicationDelegate *>([UIApplication sharedApplication].delegate).qiosViewController : nil;
return c;
}