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 <christian.stenger@qt.io>
This commit is contained in:
Eike Ziller
2017-08-28 14:50:25 +02:00
parent 410e78e4fd
commit 5cf580c1f3

View File

@@ -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<DropSupport::FileSpec> &files)