summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/downloadfromdivecomputer.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2017-05-19 11:29:03 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-05-27 11:07:19 -0700
commitc370b876b2605f0b06b7c8089d47c1321ea0634f (patch)
tree4a8b5b8a8e6da436f948592513bce57b7ec671e9 /desktop-widgets/downloadfromdivecomputer.cpp
parent09904ddff525ccf3f1165956e0d2d5483290bf12 (diff)
downloadsubsurface-c370b876b2605f0b06b7c8089d47c1321ea0634f.tar.gz
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 <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/downloadfromdivecomputer.cpp')
-rw-r--r--desktop-widgets/downloadfromdivecomputer.cpp13
1 files changed, 6 insertions, 7 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());
}
}