From 94364a5abe8aedca86ce9be31c1dc1b002f13033 Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Fri, 12 Jan 2018 15:02:13 -0800 Subject: [PATCH] Fix double-close bug on OSX --- src/ui/MainWindow.cc | 3 ++- src/ui/MainWindow.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 041cbe5..0a7d170 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -395,7 +395,7 @@ void MainWindow::showStatusBarCallback(bool checked) checked ? statusBar()->show() : statusBar()->hide(); } -void MainWindow::reallyClose(void) +void MainWindow::_reallyClose(void) { _forceClose = true; close(); @@ -458,6 +458,7 @@ void MainWindow::connectCommonActions() { // Connect internal actions connect(qgcApp()->toolbox()->multiVehicleManager(), &MultiVehicleManager::vehicleAdded, this, &MainWindow::_vehicleAdded); + connect(this, &MainWindow::reallyClose, this, &MainWindow::_reallyClose, Qt::QueuedConnection); // Queued to allow closeEvent to fully unwind before _reallyClose is called } void MainWindow::_openUrl(const QString& url, const QString& errorMessage) diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 5efc40a..001955f 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -80,7 +80,7 @@ public: void saveLastUsedConnection(const QString connection); // Called from MainWindow.qml when the user accepts the window close dialog - Q_INVOKABLE void reallyClose(void); + void _reallyClose(void); /// @return Root qml object of main window QML QObject* rootQmlObject(void); @@ -104,6 +104,7 @@ signals: void initStatusChanged(const QString& message, int alignment, const QColor &color); /** Emitted when any value changes from any source */ void valueChanged(const int uasId, const QString& name, const QString& unit, const QVariant& value, const quint64 msec); + void reallyClose(void); // Used for unit tests to know when the main window closes void mainWindowClosed(void);