From c370b876b2605f0b06b7c8089d47c1321ea0634f Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 19 May 2017 11:29:03 +0200 Subject: [PATCH] Reduce the scope of variables Those variables should have local scope, not class scope. We are using it only inside of pickDump/LogFile metohds. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/downloadfromdivecomputer.cpp | 13 ++++++------- desktop-widgets/downloadfromdivecomputer.h | 2 -- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp index a80624030..b6cdfa64f 100644 --- a/desktop-widgets/downloadfromdivecomputer.cpp +++ b/desktop-widgets/downloadfromdivecomputer.cpp @@ -336,7 +336,7 @@ void DownloadFromDCWidget::checkLogFile(int state) { ui.chooseLogFile->setEnabled(state == Qt::Checked); // TODO: Verify the Thread. - if (state == Qt::Checked && logFile.isEmpty()) { + if (state == Qt::Checked) { pickLogFile(); } } @@ -346,11 +346,11 @@ void DownloadFromDCWidget::pickLogFile() QString filename = existing_filename ?: prefs.default_filename; QFileInfo fi(filename); filename = fi.absolutePath().append(QDir::separator()).append("subsurface.log"); - logFile = QFileDialog::getSaveFileName(this, tr("Choose file for dive computer download logfile"), + QString logFile = QFileDialog::getSaveFileName(this, tr("Choose file for dive computer download logfile"), filename, tr("Log files (*.log)")); if (!logFile.isEmpty()) { free(logfile_name); - logfile_name = strdup(logFile.toUtf8().data()); + logfile_name = copy_string(logFile.toUtf8().data()); } } @@ -358,8 +358,7 @@ void DownloadFromDCWidget::checkDumpFile(int state) { ui.chooseDumpFile->setEnabled(state == Qt::Checked); if (state == Qt::Checked) { - if (dumpFile.isEmpty()) - pickDumpFile(); + pickDumpFile(); if (!dumpWarningShown) { QMessageBox::warning(this, tr("Warning"), tr("Saving the libdivecomputer dump will NOT download dives to the dive list.")); @@ -373,11 +372,11 @@ void DownloadFromDCWidget::pickDumpFile() QString filename = existing_filename ?: prefs.default_filename; QFileInfo fi(filename); filename = fi.absolutePath().append(QDir::separator()).append("subsurface.bin"); - dumpFile = QFileDialog::getSaveFileName(this, tr("Choose file for dive computer binary dump file"), + QString dumpFile = QFileDialog::getSaveFileName(this, tr("Choose file for dive computer binary dump file"), filename, tr("Dump files (*.bin)")); if (!dumpFile.isEmpty()) { free(dumpfile_name); - dumpfile_name = strdup(dumpFile.toUtf8().data()); + dumpfile_name = copy_string(dumpFile.toUtf8().data()); } } diff --git a/desktop-widgets/downloadfromdivecomputer.h b/desktop-widgets/downloadfromdivecomputer.h index 399debc52..6365aa332 100644 --- a/desktop-widgets/downloadfromdivecomputer.h +++ b/desktop-widgets/downloadfromdivecomputer.h @@ -68,8 +68,6 @@ private: QStringListModel *vendorModel; QStringListModel *productModel; void fill_device_list(int dc_type); - QString logFile; - QString dumpFile; QTimer *timer; bool dumpWarningShown; OstcFirmwareCheck *ostcFirmwareCheck;