Cocoa: Don't send duplicate close events.

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 <morten.sorvig@digia.com>
This commit is contained in:
Morten Johan Sørvig 2014-06-07 23:34:45 +02:00 committed by The Qt Project
parent 29513210df
commit 360fd4a278

View File

@ -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();