diff --git a/GUI/View/Manager/ProjectLoadProblemDialog.cpp b/GUI/View/Manager/ProjectLoadProblemDialog.cpp index 7cbfbfa49cb1cbfc2f5d1b55ba89c9e8a9c55149..ed49466f2bd8c86bd5b8827c54ca8b5a90983f32 100644 --- a/GUI/View/Manager/ProjectLoadProblemDialog.cpp +++ b/GUI/View/Manager/ProjectLoadProblemDialog.cpp @@ -13,6 +13,8 @@ // ************************************************************************************************ #include "GUI/View/Manager/ProjectLoadProblemDialog.h" +#include "Base/Util/Assert.h" +#include "GUI/Model/Project/ProjectDocument.h" #include "GUI/Support/Style/Style.h" #include "GUI/Support/Util/Path.h" #include <QGridLayout> @@ -23,12 +25,10 @@ namespace { const int top_panel_height = 80; + } // namespace -ProjectLoadProblemDialog::ProjectLoadProblemDialog(QWidget* parent, const QStringList& details, - QString documentVersion) - : QDialog(parent) - , m_projectDocumentVersion(std::move(documentVersion)) +ProjectLoadProblemDialog::ProjectLoadProblemDialog(const QStringList& details) { setMinimumSize(256, 256); resize(520, 620); @@ -119,18 +119,20 @@ QLayout* ProjectLoadProblemDialog::buttonLayout() //! Returns explanations what went wrong. QString ProjectLoadProblemDialog::explanationText() const { - if (m_projectDocumentVersion != GUI::Path::getBornAgainVersionString()) { + ASSERT(gDoc); + const QString& doc_version = gDoc->documentVersion(); + + if (doc_version != GUI::Path::getBornAgainVersionString()) return QString( "Given project was created using BornAgain version %1 " " which is different from version %2 you are currently using. " "At the moment we provide only limited support for import from older versions.") - .arg(m_projectDocumentVersion) + .arg(doc_version) .arg(GUI::Path::getBornAgainVersionString()); - } return QString("Given project was created using BornAgain version %1 " "which is the same as the current version of the framework. " "Strangely enough, some parts were not loaded correctly due to format mismatch. " "Please contact the developers.") - .arg(m_projectDocumentVersion); + .arg(doc_version); } diff --git a/GUI/View/Manager/ProjectLoadProblemDialog.h b/GUI/View/Manager/ProjectLoadProblemDialog.h index 6af31a2f4511e196f126b1afe947ddb5164f104d..e06afe647c9ec692b850967c5a28a732d1220550 100644 --- a/GUI/View/Manager/ProjectLoadProblemDialog.h +++ b/GUI/View/Manager/ProjectLoadProblemDialog.h @@ -23,14 +23,12 @@ class ProjectLoadProblemDialog : public QDialog { Q_OBJECT public: - ProjectLoadProblemDialog(QWidget* parent, const QStringList& details, QString documentVersion); + ProjectLoadProblemDialog(const QStringList& details); private: QWidget* createWarningWidget(); QLayout* buttonLayout(); QString explanationText() const; - - QString m_projectDocumentVersion; }; #endif // BORNAGAIN_GUI_VIEW_MANAGER_PROJECTLOADPROBLEMDIALOG_H diff --git a/GUI/View/Manager/ProjectManager.cpp b/GUI/View/Manager/ProjectManager.cpp index 1ca3b03fe5fb6eb979087eb73dd8d5ec60e3dc59..e35f6f68ce21ae0a3bf34a3447526c4a71ed4801 100644 --- a/GUI/View/Manager/ProjectManager.cpp +++ b/GUI/View/Manager/ProjectManager.cpp @@ -423,10 +423,7 @@ void ProjectManager::riseProjectLoadFailedDialog(const MessageService& messageSe void ProjectManager::riseProjectLoadProblemDialog(const MessageService& messageService) { - ASSERT(gDoc); - auto* problemDialog = new ProjectLoadProblemDialog( - GUI::Global::mainWindow, messageService.warnings(true), gDoc->documentVersion()); - + auto* problemDialog = new ProjectLoadProblemDialog(messageService.warnings(true)); problemDialog->show(); problemDialog->raise(); }