diff --git a/src/AppEnv.cpp b/src/AppEnv.cpp index 38bb630..ed951f5 100644 --- a/src/AppEnv.cpp +++ b/src/AppEnv.cpp @@ -55,10 +55,10 @@ QString AppEnv::getGameFolder(bool *ok) { QDir dir; QString GTAV_FOLDER = QString::fromUtf8(qgetenv("GTAV_FOLDER")); - if (GTAV_FOLDER != "") { + if (!GTAV_FOLDER.isEmpty()) { dir.setPath(GTAV_FOLDER); if (dir.exists()) { - if (ok != NULL) + if (ok) *ok = true; qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8()); return dir.absolutePath(); @@ -77,7 +77,7 @@ QString AppEnv::getGameFolder(bool *ok) if (forceDir) { dir.setPath(GTAV_returnFolder); if (dir.exists()) { - if (ok != 0) + if (ok) *ok = true; qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8()); return dir.absolutePath(); @@ -86,7 +86,7 @@ QString AppEnv::getGameFolder(bool *ok) dir.setPath(GTAV_defaultFolder); if (dir.exists()) { - if (ok != 0) + if (ok) *ok = true; qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8()); return dir.absolutePath(); @@ -95,14 +95,14 @@ QString AppEnv::getGameFolder(bool *ok) if (!forceDir) { dir.setPath(GTAV_returnFolder); if (dir.exists()) { - if (ok != 0) + if (ok) *ok = true; qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8()); return dir.absolutePath(); } } - if (ok != 0) + if (ok) *ok = false; return QString(); } diff --git a/src/OptionsDialog.cpp b/src/OptionsDialog.cpp index d9b6575..bc4cc7e 100644 --- a/src/OptionsDialog.cpp +++ b/src/OptionsDialog.cpp @@ -694,7 +694,7 @@ void OptionsDialog::setupSnapmaticPictureViewer() void OptionsDialog::on_cmdExploreFolder_clicked() { const QString GTAV_Folder = QFileDialog::getExistingDirectory(this, UserInterface::tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly); - if (QDir(GTAV_Folder).exists()) { + if (!GTAV_Folder.isEmpty() && QDir(GTAV_Folder).exists()) { ui->txtFolder->setText(GTAV_Folder); } } diff --git a/src/ProfileInterface.cpp b/src/ProfileInterface.cpp index 295013e..2c5c352 100644 --- a/src/ProfileInterface.cpp +++ b/src/ProfileInterface.cpp @@ -1302,8 +1302,8 @@ void ProfileInterface::exportSelected() settings.beginGroup("FileDialogs"); //bool dontUseNativeDialog = settings.value("DontUseNativeDialog", false).toBool(); settings.beginGroup("ExportDirectory"); - QString exportDirectory = QFileDialog::getExistingDirectory(this, tr("Export selected..."), settings.value(profileName, profileFolder).toString()); - if (exportDirectory != "") { + const QString exportDirectory = QFileDialog::getExistingDirectory(this, tr("Export selected..."), settings.value(profileName, profileFolder).toString()); + if (!exportDirectory.isEmpty()) { settings.setValue(profileName, exportDirectory); for (const QString &widgetStr : qAsConst(widgets)) { ProfileWidget *widget = widgets.key(widgetStr, nullptr); diff --git a/src/UserInterface.cpp b/src/UserInterface.cpp index a980758..94152c8 100644 --- a/src/UserInterface.cpp +++ b/src/UserInterface.cpp @@ -321,8 +321,9 @@ void UserInterface::setupDirEnv(bool showFolderDialog) QDir::setCurrent(GTAV_Folder); } else if (showFolderDialog) { - GTAV_Folder = QFileDialog::getExistingDirectory(this, tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly); - if (QDir(GTAV_Folder).exists()) { + const QString GTAV_Folder_Temp = QFileDialog::getExistingDirectory(this, tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly); + if (!GTAV_Folder_Temp.isEmpty() && QDir(GTAV_Folder_Temp).exists()) { + GTAV_Folder = GTAV_Folder_Temp; folderExists = true; QDir::setCurrent(GTAV_Folder); AppEnv::setGameFolder(GTAV_Folder); @@ -809,8 +810,8 @@ void UserInterface::updateCacheId(uint cacheId) void UserInterface::on_actionSelect_GTA_Folder_triggered() { - QString GTAV_Folder_Temp = QFileDialog::getExistingDirectory(this, tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly); - if (QDir(GTAV_Folder_Temp).exists()) { + const QString GTAV_Folder_Temp = QFileDialog::getExistingDirectory(this, tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly); + if (!GTAV_Folder_Temp.isEmpty() && QDir(GTAV_Folder_Temp).exists()) { if (profileOpen) { closeProfile_p(); }