diff options
author | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2009-08-20 13:40:31 (GMT) |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2009-08-20 13:43:03 (GMT) |
commit | 552a1f1942ac5a004e54bad2f1048ce220a3156d (patch) | |
tree | 39094a0b6d4bbb0a57105dc4b62dbdf45cd3e8ef /src/gui/kernel/qcocoaapplicationdelegate_mac.mm | |
parent | 984773a54975ed26c5e7aef5d8ff095ca1dfad3d (diff) | |
download | Qt-552a1f1942ac5a004e54bad2f1048ce220a3156d.zip Qt-552a1f1942ac5a004e54bad2f1048ce220a3156d.tar.gz Qt-552a1f1942ac5a004e54bad2f1048ce220a3156d.tar.bz2 |
Cocoa: cannot quit application
If Qt is used from within a native cocoa application. This patch
allowes the application to terminate if we have no current event
loops running. This should be safe in itself, and also handle the
case where NSApp run is called from outside Qt.
Task-number: 259928
Reviewed-by: msorvig
Diffstat (limited to 'src/gui/kernel/qcocoaapplicationdelegate_mac.mm')
-rw-r--r-- | src/gui/kernel/qcocoaapplicationdelegate_mac.mm | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm index 572df70..172d07b 100644 --- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm +++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm @@ -197,11 +197,19 @@ static void cleanupCocoaApplicationDelegate() } } - // Prevent Cocoa from terminating the application, since this simply - // exits the program whithout allowing QApplication::exec() to return. - // The call to QApplication::quit() above will instead quit the - // application from the Qt side. - return NSTerminateCancel; + if (qtPrivate->threadData->eventLoops.size() == 0) { + // INVARIANT: No event loop is executing. This probably + // means that Qt is used as a plugin, or as a part of a native + // Cocoa application. In any case it should be fine to + // terminate now: + return NSTerminateNow; + } else { + // Prevent Cocoa from terminating the application, since this simply + // exits the program whithout allowing QApplication::exec() to return. + // The call to QApplication::quit() above will instead quit the + // application from the Qt side. + return NSTerminateCancel; + } } - (void)applicationDidFinishLaunching:(NSNotification *)aNotification |