diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2019-10-14 14:07:20 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2019-10-18 13:30:54 +0200 |
commit | ff2ba8b9d2798c4b7a77734df723d6312b983f1d (patch) | |
tree | 38c76b108974910e5bf97e3d806d370e786029ef | |
parent | 2c9bd677abde65e8a31ef6d9772497203525f29a (diff) |
macOS: Let system decide whether modal window should prevent app termination
The logic for preventing application termination when there are modal
windows active was a leftover from the Carbon to Cocoa port, and is no
longer needed. AppKit will deal with this on its own, by checking the
preventsApplicationTerminationWhenModal property of each NSWindow.
In some cases AppKit will also ignore this property, such as when
quitting the application from the menu entry, which means we now get
the default system behavior for this use-case.
Change-Id: Iac5d8d8e17eb0974448f7ee6f39c9b7761bf4d90
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index 9daf65abcf..33a45985a8 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -142,28 +142,9 @@ QT_USE_NAMESPACE - (BOOL)canQuit { - bool handle_quit = true; - NSMenuItem *quitMenuItem = [[QCocoaMenuLoader sharedMenuLoader] quitMenuItem]; - if (!QGuiApplicationPrivate::instance()->modalWindowList.isEmpty() - && [quitMenuItem isEnabled]) { - int visible = 0; - const QWindowList tlws = QGuiApplication::topLevelWindows(); - for (int i = 0; i < tlws.size(); ++i) { - if (tlws.at(i)->isVisible()) - ++visible; - } - handle_quit = (visible <= 1); - } - - if (handle_quit) { - QCloseEvent ev; - QGuiApplication::sendEvent(qGuiApp, &ev); - if (ev.isAccepted()) { - return YES; - } - } - - return NO; + QCloseEvent ev; + QGuiApplication::sendEvent(qGuiApp, &ev); + return ev.isAccepted(); } // This function will only be called when NSApp is actually running. |