From 5cf580c1f3ae2426e716f77a9a69187609beb968 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 28 Aug 2017 14:50:25 +0200 Subject: [PATCH] macOS: Fix issue with saving settings (work around Qt bug) When closing the application via Quit from the application's context menu in the dock, Qt sends the closeEvent twice, leading to funny issues (QTBUG-43344). Remember if we already successfully went through the closeEvent, and skip it in that case. Task-number: QTCREATORBUG-18798 Change-Id: I8c54f0695b1af2572fa0ade7487a6a993022946b Reviewed-by: Christian Stenger --- src/plugins/coreplugin/mainwindow.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index 17fed47e85c..9010fd8da3c 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -355,6 +355,13 @@ void MainWindow::extensionsInitialized() void MainWindow::closeEvent(QCloseEvent *event) { + // work around QTBUG-43344 + static bool alreadyClosed = false; + if (alreadyClosed) { + event->accept(); + return; + } + ICore::saveSettings(); // Save opened files @@ -378,6 +385,7 @@ void MainWindow::closeEvent(QCloseEvent *event) m_rightNavigationWidget->closeSubWidgets(); event->accept(); + alreadyClosed = true; } void MainWindow::openDroppedFiles(const QList &files)