From 360fd4a278a8827d9727b295a753e623502c7445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Sat, 7 Jun 2014 23:34:45 +0200 Subject: Cocoa: Don't send duplicate close events. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't send QCloseEvents to QWidgetWindows during cmd-q application shutdown, since widgets will will already have received close events from QApplication close event handling. Task-number: QTBUG-39398 Change-Id: I7f6e892b0042361bed7a3bc5fac8518eabfc8e4e Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index 548c6a23f0..f89439734f 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -223,7 +223,14 @@ static void cleanupCocoaApplicationDelegate() // events while the event loop is still running. const QWindowList topLevels = QGuiApplication::topLevelWindows(); for (int i = 0; i < topLevels.size(); ++i) { - QWindowSystemInterface::handleCloseEvent(topLevels.at(i)); + QWindow *topLevelWindow = topLevels.at(i); + // Widgets have alreay received a CloseEvent from the QApplication + // QCloseEvent handler. (see canQuit above). Prevent running the + // CloseEvent logic twice, call close() directly. + if (topLevelWindow->inherits("QWidgetWindow")) + topLevelWindow->close(); + else + QWindowSystemInterface::handleCloseEvent(topLevelWindow); } QWindowSystemInterface::flushWindowSystemEvents(); -- cgit v1.2.3