diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index c30aeacb..dd06012b 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -148,6 +148,7 @@ void Application::createAndLoadProject(const FilePath& projectSettingsFilePath) updateRecentProjects(projectSettingsFilePath); m_storageCache->clear(); + m_storageCache->setSubject(nullptr); m_project = m_projectFactory.createProject(projectSettingsFilePath, m_storageCache.get(), getDialogView()); @@ -157,8 +158,6 @@ void Application::createAndLoadProject(const FilePath& projectSettingsFilePath) { setTitle("Coati - " + projectSettingsFilePath.fileName()); m_mainView->hideStartScreen(); - - m_componentManager->clearComponents(); } } else @@ -169,9 +168,11 @@ void Application::createAndLoadProject(const FilePath& projectSettingsFilePath) } catch (...) { - LOG_ERROR_STREAM(<< "Failed to load project."); - MessageStatus("Failed to load project: " + projectSettingsFilePath.str(), true).dispatch(); + LOG_ERROR_STREAM(<< "Failed to load project, exception thrown."); + MessageStatus("Failed to load project, exception was thrown: " + projectSettingsFilePath.str(), true).dispatch(); } + + m_componentManager->clearComponents(); } void Application::refreshProject(bool force) diff --git a/src/lib/component/controller/CodeController.cpp b/src/lib/component/controller/CodeController.cpp index f16351af..65e4b051 100644 --- a/src/lib/component/controller/CodeController.cpp +++ b/src/lib/component/controller/CodeController.cpp @@ -107,7 +107,7 @@ void CodeController::handleMessage(MessageActivateTokens* message) if (!message->keepContent()) { - view->clear(); + view->clearCodeSnippets(); } std::vector activeTokenIds = message->tokenIds; diff --git a/src/lib/component/view/CodeView.h b/src/lib/component/view/CodeView.h index c1ccbdc0..07949120 100644 --- a/src/lib/component/view/CodeView.h +++ b/src/lib/component/view/CodeView.h @@ -29,6 +29,7 @@ public: virtual std::string getName() const; virtual void clear() = 0; + virtual void clearCodeSnippets() = 0; virtual void setErrorInfos(const std::vector& errorInfos) = 0; virtual bool showsErrors() const = 0; diff --git a/src/lib_gui/qt/element/QtCodeNavigator.cpp b/src/lib_gui/qt/element/QtCodeNavigator.cpp index ab660642..f66af649 100644 --- a/src/lib_gui/qt/element/QtCodeNavigator.cpp +++ b/src/lib_gui/qt/element/QtCodeNavigator.cpp @@ -192,6 +192,12 @@ void QtCodeNavigator::addedFiles() } } +void QtCodeNavigator::clear() +{ + clearCodeSnippets(); + clearCaches(); +} + void QtCodeNavigator::clearCodeSnippets() { m_list->clear(); diff --git a/src/lib_gui/qt/element/QtCodeNavigator.h b/src/lib_gui/qt/element/QtCodeNavigator.h index 727e1a87..60a06bc0 100644 --- a/src/lib_gui/qt/element/QtCodeNavigator.h +++ b/src/lib_gui/qt/element/QtCodeNavigator.h @@ -37,6 +37,7 @@ public: void addedFiles(); + void clear(); void clearCodeSnippets(); void clearCaches(); diff --git a/src/lib_gui/qt/view/QtCodeView.cpp b/src/lib_gui/qt/view/QtCodeView.cpp index de886d50..cd37537e 100644 --- a/src/lib_gui/qt/view/QtCodeView.cpp +++ b/src/lib_gui/qt/view/QtCodeView.cpp @@ -55,6 +55,18 @@ void QtCodeView::refreshView() } void QtCodeView::clear() +{ + m_onQtThread( + [=]() + { + m_widget->clear(); + } + ); + + m_errorInfos.clear(); +} + +void QtCodeView::clearCodeSnippets() { m_onQtThread( [=]() diff --git a/src/lib_gui/qt/view/QtCodeView.h b/src/lib_gui/qt/view/QtCodeView.h index a74f5e1f..51b7676f 100644 --- a/src/lib_gui/qt/view/QtCodeView.h +++ b/src/lib_gui/qt/view/QtCodeView.h @@ -27,6 +27,7 @@ public: // CodeView implementation virtual void clear(); + virtual void clearCodeSnippets(); virtual void setErrorInfos(const std::vector& errorInfos); virtual bool showsErrors() const;