diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-05-07 15:10:01 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-05-30 09:16:23 +0000 |
commit | 0587941f6eda05dfc3cc66ce44bf8f32320d7d24 (patch) | |
tree | 53e649e33eeeab68d20c015bb8678062c875f81d /src/corelib/kernel/qcore_mac_objc.mm | |
parent | 6ada504475fc8ec3f7fe4d05f8af1ba3735208e9 (diff) |
Add function to safely access the shared application on Apple platforms
Change-Id: I52910309ba94d84d69f049b5c1990f1f866e1698
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/corelib/kernel/qcore_mac_objc.mm')
-rw-r--r-- | src/corelib/kernel/qcore_mac_objc.mm | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm index d1a736c9bb..c29c4dfc14 100644 --- a/src/corelib/kernel/qcore_mac_objc.mm +++ b/src/corelib/kernel/qcore_mac_objc.mm @@ -167,6 +167,28 @@ bool qt_apple_isApplicationExtension() return isExtension; } +#if !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WATCHOS) +AppleApplication *qt_apple_sharedApplication() +{ + // Application extensions are not allowed to access the shared application + if (qt_apple_isApplicationExtension()) { + qWarning() << "accessing the shared" << [AppleApplication class] + << "is not allowed in application extensions"; + + // In practice the application is actually available, but the the App + // review process will likely catch uses of it, so we return nil just + // in case, unless we don't care about being App Store compliant. +#if QT_CONFIG(appstore_compliant) + return nil; +#endif + } + + // We use performSelector so that building with -fapplication-extension will + // not mistakenly think we're using the shared application in extensions. + return [[AppleApplication class] performSelector:@selector(sharedApplication)]; +} +#endif + #ifdef Q_OS_MACOS /* Ensure that Objective-C objects auto-released in main(), directly or indirectly, |