diff --git a/GUI/Model/Project/ProjectDocument.cpp b/GUI/Model/Project/ProjectDocument.cpp index f7098615ca909d1aad1758041cf165dbf2cd729c..ef1cd2d186d226ba2d383a9f9aab492c84aeeeaa 100644 --- a/GUI/Model/Project/ProjectDocument.cpp +++ b/GUI/Model/Project/ProjectDocument.cpp @@ -72,6 +72,13 @@ QString ProjectDocument::projectDir() const return m_project_dir; } +QString ProjectDocument::validProjectDir() const +{ + if (m_project_name.isEmpty()) + return ""; + return m_project_dir; +} + void ProjectDocument::setProjectDir(const QString& text) { m_project_dir = text; diff --git a/GUI/Model/Project/ProjectDocument.h b/GUI/Model/Project/ProjectDocument.h index 6c2380f34d296eb1c9396abd965ca72f0ec0cfbb..0668cc7cdeb0992364ae1c6299e4c665ee60247b 100644 --- a/GUI/Model/Project/ProjectDocument.h +++ b/GUI/Model/Project/ProjectDocument.h @@ -62,6 +62,7 @@ public: void setProjectName(const QString& text); QString projectDir() const; + QString validProjectDir() const; void setProjectDir(const QString& text); QString projectFileName() const; diff --git a/GUI/View/Main/ProjectManager.cpp b/GUI/View/Main/ProjectManager.cpp index e0b06c66b19b24b75ac4ac021c26f05775c7d806..91bae5efd1afe4d1bd55c29c2383636276d8aeb2 100644 --- a/GUI/View/Main/ProjectManager.cpp +++ b/GUI/View/Main/ProjectManager.cpp @@ -123,11 +123,9 @@ void ProjectManager::writeSettings() QStringList ProjectManager::recentProjects() { QStringList updatedList; - for (QString fileName : m_recentProjects) { - QFile fin(fileName); - if (fin.exists()) + for (QString fileName : m_recentProjects) + if (QFile fin(fileName); fin.exists()) updatedList.append(fileName); - } m_recentProjects = updatedList; return m_recentProjects; } @@ -136,8 +134,8 @@ QStringList ProjectManager::recentProjects() QString ProjectManager::projectDir() const { - if (gSessionData->projectDocument && gSessionData->projectDocument->hasValidNameAndPath()) - return gSessionData->projectDocument->projectDir(); + if (gSessionData->projectDocument) + return gSessionData->projectDocument->validProjectDir(); return ""; } @@ -146,11 +144,9 @@ QString ProjectManager::projectDir() const QString ProjectManager::userExportDir() const { - QString result = projectDir(); - if (result.isEmpty()) - result = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); - - return result; + if (QString dir = projectDir(); !dir.isEmpty()) + return dir; + return QStandardPaths::writableLocation(QStandardPaths::HomeLocation); } //! Returns directory name which was used by the user to import files.