From 5ed77ec28e1965ceced180304cf9d20a4d9b9131 Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Wed, 17 May 2017 01:11:27 -0400 Subject: [PATCH] =?UTF-8?q?Remove=20test=20where=20it=20doesn=E2=80=99t=20?= =?UTF-8?q?belong.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/QGCApplication.cc | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index 4e09048..e067a19 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -505,35 +505,32 @@ void QGCApplication::criticalMessageBoxOnMainThread(const QString& title, const void QGCApplication::saveTelemetryLogOnMainThread(QString tempLogfile) { - // Are we supposed to log? - if(toolbox()->settingsManager()->appSettings()->telemetrySave()->rawValue().toBool()) { - // The vehicle is gone now and we are shutting down so we need to use a message box for errors to hold shutdown and show the error - if (_checkTelemetrySavePath(true /* useMessageBox */)) { - - QString saveDirPath = _toolbox->settingsManager()->appSettings()->telemetrySavePath(); - QDir saveDir(saveDirPath); - - QString nameFormat("%1%2.%3"); - QString dtFormat("yyyy-MM-dd hh-mm-ss"); - - int tryIndex = 1; - QString saveFileName = nameFormat.arg( - QDateTime::currentDateTime().toString(dtFormat)).arg("").arg(toolbox()->settingsManager()->appSettings()->telemetryFileExtension); - while (saveDir.exists(saveFileName)) { - saveFileName = nameFormat.arg( - QDateTime::currentDateTime().toString(dtFormat)).arg(QStringLiteral(".%1").arg(tryIndex++)).arg(toolbox()->settingsManager()->appSettings()->telemetryFileExtension); - } - QString saveFilePath = saveDir.absoluteFilePath(saveFileName); + // The vehicle is gone now and we are shutting down so we need to use a message box for errors to hold shutdown and show the error + if (_checkTelemetrySavePath(true /* useMessageBox */)) { + + QString saveDirPath = _toolbox->settingsManager()->appSettings()->telemetrySavePath(); + QDir saveDir(saveDirPath); - QFile tempFile(tempLogfile); - if (!tempFile.copy(saveFilePath)) { - QString error = tr("Unable to save telemetry log. Error copying telemetry to '%1': '%2'.").arg(saveFilePath).arg(tempFile.errorString()); + QString nameFormat("%1%2.%3"); + QString dtFormat("yyyy-MM-dd hh-mm-ss"); + + int tryIndex = 1; + QString saveFileName = nameFormat.arg( + QDateTime::currentDateTime().toString(dtFormat)).arg("").arg(toolbox()->settingsManager()->appSettings()->telemetryFileExtension); + while (saveDir.exists(saveFileName)) { + saveFileName = nameFormat.arg( + QDateTime::currentDateTime().toString(dtFormat)).arg(QStringLiteral(".%1").arg(tryIndex++)).arg(toolbox()->settingsManager()->appSettings()->telemetryFileExtension); + } + QString saveFilePath = saveDir.absoluteFilePath(saveFileName); + + QFile tempFile(tempLogfile); + if (!tempFile.copy(saveFilePath)) { + QString error = tr("Unable to save telemetry log. Error copying telemetry to '%1': '%2'.").arg(saveFilePath).arg(tempFile.errorString()); #ifndef __mobile__ - QGCMessageBox::warning(tr("Telemetry Save Error"), error); + QGCMessageBox::warning(tr("Telemetry Save Error"), error); #else - showMessage(error); + showMessage(error); #endif - } } } QFile::remove(tempLogfile);