From ff2ba8b9d2798c4b7a77734df723d6312b983f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 14 Oct 2019 14:07:20 +0200 Subject: 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 Reviewed-by: Volker Hilsheimer --- .../platforms/cocoa/qcocoaapplicationdelegate.mm | 25 +++------------------- 1 file 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. -- cgit v1.2.3