From f81f21151d30a37f955aa4af2398a96507626b15 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Mon, 2 Mar 2015 21:13:35 +0100 Subject: Session management for macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch aims to implement the session management available on macOS. Currently applicationShouldTerminate is just a go through that closes everything and ends the application. The new implementation calls first appCommitData and cancels the termination properly if required. This means that if a user wishes to logout, Qt applications can now cancel that like e.g. answering to Safari asking whether it is ok to close because of a number of opened tab/window. Fixes: QTBUG-33034 Change-Id: Id5d7416cb74c762c5424a77c9c7664f0749da7f6 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm') diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index f1fe2aa98b..3fb9e83d35 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -79,11 +79,14 @@ #include "qcocoamenuitem.h" #include "qcocoansmenu.h" +#if QT_CONFIG(sessionmanager) +# include "qcocoasessionmanager.h" +#endif + #include #include #include #include -#include #include "qt_mac_p.h" #include #include @@ -157,6 +160,17 @@ QT_USE_NAMESPACE return NSTerminateNow; } +#if QT_CONFIG(sessionmanager) + QCocoaSessionManager *cocoaSessionManager = QCocoaSessionManager::instance(); + cocoaSessionManager->resetCancellation(); + cocoaSessionManager->appCommitData(); + + if (cocoaSessionManager->wasCanceled()) { + qCDebug(lcQpaApplication) << "Session management canceled application termination"; + return NSTerminateCancel; + } +#endif + if (!QWindowSystemInterface::handleApplicationTermination()) { qCDebug(lcQpaApplication) << "Application termination canceled"; return NSTerminateCancel; -- cgit v1.2.3