From 125f125aca8b9a76865da23ce3552957b098799a Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Mon, 8 Dec 2014 15:58:08 -0800 Subject: [PATCH] Disallow close if active connections Also moved log file settings save check to mavlink protocol --- src/ui/MainWindow.cc | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 8ed2ee971..b327d10a6 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -778,12 +778,31 @@ void MainWindow::showHILConfigurationWidget(UASInterface* uas) void MainWindow::closeEvent(QCloseEvent *event) { + // Disallow window close if there are active connections + + bool foundConnections = false; + foreach(LinkInterface* link, LinkManager::instance()->getLinks()) { + if (link->isConnected()) { + foundConnections = true; + break; + } + } + + if (foundConnections) { + QGCMessageBox::warning(tr("QGroundControl close"), tr("There are still active connections to vehicles. Please disconnect all connections before closing QGroundControl.")); + event->ignore(); + return; + } + + // Should not be any active connections + foreach(LinkInterface* link, LinkManager::instance()->getLinks()) { + Q_ASSERT(!link->isConnected()); + } + storeViewState(); storeSettings(); mavlink->storeSettings(); UASManager::instance()->storeSettings(); - // FIXME: If connected links, should prompt before close - LinkManager::instance()->disconnectAll(); event->accept(); } @@ -1734,14 +1753,12 @@ bool MainWindow::dockWidgetTitleBarsEnabled() const void MainWindow::_saveTempFlightDataLog(QString tempLogfile) { - if (qgcApp()->promptFlightDataSave()) { - QString saveFilename = QGCFileDialog::getSaveFileName(this, - tr("Select file to save Flight Data Log"), - qgcApp()->mavlinkLogFilesLocation(), - tr("Flight Data Log (*.mavlink)")); - if (!saveFilename.isEmpty()) { - QFile::copy(tempLogfile, saveFilename); - } + QString saveFilename = QGCFileDialog::getSaveFileName(this, + tr("Select file to save Flight Data Log"), + qgcApp()->mavlinkLogFilesLocation(), + tr("Flight Data Log (*.mavlink)")); + if (!saveFilename.isEmpty()) { + QFile::copy(tempLogfile, saveFilename); } QFile::remove(tempLogfile); } -- 2.22.0