Use QDir::exists() instead of QDir::setCurrent() to check for existence

Don't change into a directory just to see if it exists.
Remove unnecessary braces of one of the changed if statements.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2017-12-04 08:49:28 +01:00 committed by Lubomir I. Ivanov
parent ed92b60bfe
commit 0a2e53caf2
4 changed files with 4 additions and 5 deletions

View file

@ -1017,7 +1017,7 @@ QString DiveListView::lastUsedImageDir()
settings.beginGroup("FileDialog");
if (settings.contains("LastImageDir"))
if (QDir::setCurrent(settings.value("LastImageDir").toString()))
if (QDir(settings.value("LastImageDir").toString()).exists())
lastImageDir = settings.value("LastImageDir").toString();
return lastImageDir;
}

View file

@ -127,9 +127,8 @@ void DiveLogExportDialog::on_buttonBox_accepted()
settings.beginGroup("FileDialog");
if (settings.contains("LastDir")) {
if (QDir::setCurrent(settings.value("LastDir").toString())) {
if (QDir(settings.value("LastDir").toString()).exists())
lastDir = settings.value("LastDir").toString();
}
}
settings.endGroup();

View file

@ -743,7 +743,7 @@ QString MainWindow::lastUsedDir()
settings.beginGroup("FileDialog");
if (settings.contains("LastDir"))
if (QDir::setCurrent(settings.value("LastDir").toString()))
if (QDir(settings.value("LastDir").toString()).exists())
lastDir = settings.value("LastDir").toString();
return lastDir;
}

View file

@ -34,7 +34,7 @@ QString Smrtk2ssrfcWindow::lastUsedDir()
settings.beginGroup("FileDialog");
if (settings.contains("LastDir"))
if (QDir::setCurrent(settings.value("LastDir").toString()))
if (QDir(settings.value("LastDir").toString()).exists())
lastDir = settings.value("LastDir").toString();
return lastDir;
}