summaryrefslogtreecommitdiffstats
path: root/mkspecs
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>2013-06-19 12:27:51 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-29 12:44:07 +0200
commit1e14762b8d79118540bd09a84dd3e48f4f5e113e (patch)
treef06cb1b7ccb161f3495d2c1abb941c2911a50314 /mkspecs
parentee9b9d9fd9a714f97ed8f7e26404c2f113588e9c (diff)
Make QGuiApplication::exec() run within NSApplicationMain()
We follow the same pattern as for iOS and Windows ports, making sure the user's main() runs in a platform friendly environment. In this particular case, it means calling the user's main() during the call of NSApplicationMain(), and calling the user's main() function (renamed to qMain() as in Windows) after receiving NSApplicationDidFinishLaunchingNotification. In practice, this means that NSApp is running when qMain() is called, and therefore when QCoreApplication::exec() is called. For those command-line utilities running on QGuiApplication, or any deriving class, and that do not provide a bundle, we override the main bundle's dictionary and get NSApplicationMain() to run as usual. Added cocoa/cocoamain "subdir" to build libqtcocoamain.a (together with cocoa/cocoaplugin -- plugins/platforms/cocoa is made a subdirs project). This library is linked against all GUI Qt apps and provides the actual main() function. It also catches the launching NSApplication notifications, and calls the user's qMain() function. Note that this will happen in the same cases when the user's application will run with the Cocoa QPA plugin. Launch related code in QCocoaApplicationDelegate is moved to libqtcocoamain, QNSApplication is removed (but sendEvent: redirection still there), and code in QCocoaEventDispatcher dealing with calling [NSApp run] and related has been removed since it's become unreachable. ChangeLog: [Qt for Mac] Make QGuiApplication::exec() run within NSApplicationMain() Change-Id: I790e5138c29aac2e0215a9147d0148fece40ca22 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'mkspecs')
-rw-r--r--mkspecs/features/mac/default_post.prf14
1 files changed, 14 insertions, 0 deletions
diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf
index b183814e63..4de0423f33 100644
--- a/mkspecs/features/mac/default_post.prf
+++ b/mkspecs/features/mac/default_post.prf
@@ -1,6 +1,20 @@
load(default_post)
!no_objective_c:CONFIG += objective_c
+
+equals(TEMPLATE, app):qt: {
+ deps = $$replace(QT, -private$, )
+ deps = $$resolve_depends(deps, "QT.", ".depends" ".private_depends" ".run_depends")
+ contains(deps, gui): {
+ DEFINES += QT_NEEDS_QMAIN
+ CONFIG += link_prl
+ # When CI'ing Qt we still need to link against libqtcocoamain.a, even before deployment.
+ # Hence the /get variable, suffix which looks for the libraries location effective path.
+ QMAKE_LIBDIR += $$[QT_INSTALL_LIBS/get]
+ QMAKE_LIBS += -lqtcocoamain
+ }
+}
+
qt:!isEmpty(QT_CONFIG) {
# Pick a suitable default architecture for qmake-based applications.
# If the Qt package contains one of x86 and x86_64, pick that one. If it