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>
This commit is contained in:
Tomaz Canabrava 2017-05-19 11:29:03 +02:00 committed by Dirk Hohndel
parent 09904ddff5
commit c370b876b2
2 changed files with 6 additions and 9 deletions

View file

@ -336,7 +336,7 @@ void DownloadFromDCWidget::checkLogFile(int state)
{ {
ui.chooseLogFile->setEnabled(state == Qt::Checked); ui.chooseLogFile->setEnabled(state == Qt::Checked);
// TODO: Verify the Thread. // TODO: Verify the Thread.
if (state == Qt::Checked && logFile.isEmpty()) { if (state == Qt::Checked) {
pickLogFile(); pickLogFile();
} }
} }
@ -346,11 +346,11 @@ void DownloadFromDCWidget::pickLogFile()
QString filename = existing_filename ?: prefs.default_filename; QString filename = existing_filename ?: prefs.default_filename;
QFileInfo fi(filename); QFileInfo fi(filename);
filename = fi.absolutePath().append(QDir::separator()).append("subsurface.log"); 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)")); filename, tr("Log files (*.log)"));
if (!logFile.isEmpty()) { if (!logFile.isEmpty()) {
free(logfile_name); free(logfile_name);
logfile_name = strdup(logFile.toUtf8().data()); logfile_name = copy_string(logFile.toUtf8().data());
} }
} }
@ -358,7 +358,6 @@ void DownloadFromDCWidget::checkDumpFile(int state)
{ {
ui.chooseDumpFile->setEnabled(state == Qt::Checked); ui.chooseDumpFile->setEnabled(state == Qt::Checked);
if (state == Qt::Checked) { if (state == Qt::Checked) {
if (dumpFile.isEmpty())
pickDumpFile(); pickDumpFile();
if (!dumpWarningShown) { if (!dumpWarningShown) {
QMessageBox::warning(this, tr("Warning"), QMessageBox::warning(this, tr("Warning"),
@ -373,11 +372,11 @@ void DownloadFromDCWidget::pickDumpFile()
QString filename = existing_filename ?: prefs.default_filename; QString filename = existing_filename ?: prefs.default_filename;
QFileInfo fi(filename); QFileInfo fi(filename);
filename = fi.absolutePath().append(QDir::separator()).append("subsurface.bin"); 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)")); filename, tr("Dump files (*.bin)"));
if (!dumpFile.isEmpty()) { if (!dumpFile.isEmpty()) {
free(dumpfile_name); free(dumpfile_name);
dumpfile_name = strdup(dumpFile.toUtf8().data()); dumpfile_name = copy_string(dumpFile.toUtf8().data());
} }
} }

View file

@ -68,8 +68,6 @@ private:
QStringListModel *vendorModel; QStringListModel *vendorModel;
QStringListModel *productModel; QStringListModel *productModel;
void fill_device_list(int dc_type); void fill_device_list(int dc_type);
QString logFile;
QString dumpFile;
QTimer *timer; QTimer *timer;
bool dumpWarningShown; bool dumpWarningShown;
OstcFirmwareCheck *ostcFirmwareCheck; OstcFirmwareCheck *ostcFirmwareCheck;