diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index c558cd96..bd78c4a3 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -107,7 +107,6 @@ void Application::createAndLoadProject(const FilePath& projectSettingsFilePath) if (m_hasGUI) { m_mainView->setTitle("Coati - " + projectSettingsFilePath.fileName()); - m_mainView->updateRecentProjectMenu(); m_mainView->hideStartScreen(); m_componentManager->refreshViews(); @@ -227,6 +226,7 @@ void Application::handleMessage(MessageLoadProject* message) if (result == 1) { + m_project->load(projectSettingsFilePath); return; } } @@ -296,12 +296,14 @@ void Application::updateRecentProjects(const FilePath& projectSettingsFilePath) } recentProjects.insert(recentProjects.begin(), projectSettingsFilePath); - if (recentProjects.size() > 7) + while (recentProjects.size() > 7) { recentProjects.pop_back(); } appSettings->setRecentProjects(recentProjects); appSettings->save(UserPaths::getAppSettingsPath()); + + m_mainView->updateRecentProjectMenu(); } } diff --git a/src/lib/Project.cpp b/src/lib/Project.cpp index 4a889350..8cbf432c 100644 --- a/src/lib/Project.cpp +++ b/src/lib/Project.cpp @@ -35,7 +35,7 @@ Project::ProjectState Project::load(const FilePath& projectSettingsFile) m_state = PROJECT_NONE; bool success = true; - if (!projectSettingsFile.empty() && projectSettingsFile != m_projectSettingsFilepath) + if (!projectSettingsFile.empty()) { success = ProjectSettings::getInstance()->load(projectSettingsFile); } diff --git a/src/lib/component/controller/CodeController.cpp b/src/lib/component/controller/CodeController.cpp index 8e740b3e..b1487f67 100644 --- a/src/lib/component/controller/CodeController.cpp +++ b/src/lib/component/controller/CodeController.cpp @@ -606,7 +606,7 @@ std::vector CodeController::getProjectDescription(TokenLocationFile // todo fixme: this split currently prevents the next step from recognizing multi level name hierarchies. std::vector lines = utility::splitToVector(description, "\\n"); - size_t startLineNumber = 4; + size_t startLineNumber = 2; for (size_t i = 0; i < lines.size(); i++) { diff --git a/src/lib/component/controller/GraphController.cpp b/src/lib/component/controller/GraphController.cpp index 3afa18d7..bda243d3 100644 --- a/src/lib/component/controller/GraphController.cpp +++ b/src/lib/component/controller/GraphController.cpp @@ -358,6 +358,7 @@ void GraphController::setActiveAndVisibility(const std::vector& activeTokenI if (find(activeTokenIds.begin(), activeTokenIds.end(), edge.data->getId()) != activeTokenIds.end()) { edge.active = true; + noActive = false; } DummyNode* from = findDummyNodeRecursive(m_dummyNodes, edge.ownerId); diff --git a/src/lib/data/DefinitionType.cpp b/src/lib/data/DefinitionType.cpp index 47ce98b4..34ef88f7 100644 --- a/src/lib/data/DefinitionType.cpp +++ b/src/lib/data/DefinitionType.cpp @@ -16,4 +16,5 @@ DefinitionType intToDefinitionType(int definitionType) case 2: return DEFINITION_EXPLICIT; } + return DEFINITION_NONE; } diff --git a/src/lib/data/Storage.cpp b/src/lib/data/Storage.cpp index 66dc1fcb..f8dbcfd3 100644 --- a/src/lib/data/Storage.cpp +++ b/src/lib/data/Storage.cpp @@ -27,6 +27,9 @@ Storage::Storage(const FilePath& dbPath) : m_sqliteStorage(dbPath) { + m_commandIndex.addNode(0, NameHierarchy(SearchMatch::getCommandName(SearchMatch::COMMAND_ALL))); + m_commandIndex.addNode(0, NameHierarchy(SearchMatch::getCommandName(SearchMatch::COMMAND_ERROR))); + m_commandIndex.finishSetup(); } Storage::~Storage() @@ -45,10 +48,6 @@ Version Storage::getVersion() const void Storage::init() { - m_commandIndex.addNode(0, NameHierarchy(SearchMatch::getCommandName(SearchMatch::COMMAND_ALL))); - m_commandIndex.addNode(0, NameHierarchy(SearchMatch::getCommandName(SearchMatch::COMMAND_ERROR))); - m_commandIndex.finishSetup(); - m_sqliteStorage.init(); } @@ -288,11 +287,6 @@ std::vector Storage::getAutocompletionMatches(const std::string& qu std::vector matches; for (const SearchResult& result : results) { - if (result.elementIds.size() == 0) - { - continue; - } - SearchMatch match; const StorageNode* firstNode = nullptr; diff --git a/src/lib/data/location/LocationType.cpp b/src/lib/data/location/LocationType.cpp index 4d246ebc..774cc67e 100644 --- a/src/lib/data/location/LocationType.cpp +++ b/src/lib/data/location/LocationType.cpp @@ -24,4 +24,5 @@ LocationType intToLocationType(int value) case 2: return LOCATION_LOCAL_SYMBOL; } + return LOCATION_TOKEN; } diff --git a/src/lib/data/parser/ParserClientImpl.cpp b/src/lib/data/parser/ParserClientImpl.cpp index 46233d58..9108a617 100644 --- a/src/lib/data/parser/ParserClientImpl.cpp +++ b/src/lib/data/parser/ParserClientImpl.cpp @@ -389,6 +389,8 @@ Node::NodeType ParserClientImpl::symbolTypeToNodeType(SymbolType symbolType) con return Node::NODE_TEMPLATE_PARAMETER_TYPE; case SYMBOL_UNION: return Node::NODE_TYPE; + default: + break; } return Node::NODE_UNDEFINED; } diff --git a/src/lib/utility/messaging/MessageListenerBase.h b/src/lib/utility/messaging/MessageListenerBase.h index 9c7c00b1..727ad073 100644 --- a/src/lib/utility/messaging/MessageListenerBase.h +++ b/src/lib/utility/messaging/MessageListenerBase.h @@ -19,8 +19,11 @@ public: virtual ~MessageListenerBase() { + if (m_alive) + { + MessageQueue::getInstance()->unregisterListener(this); + } m_alive = false; - MessageQueue::getInstance()->unregisterListener(this); } uint getId() const @@ -45,6 +48,11 @@ public: } } + void removedListener() + { + m_alive = false; + } + private: virtual std::string doGetType() const = 0; virtual void doHandleMessageBase(MessageBase*) = 0; diff --git a/src/lib/utility/messaging/MessageQueue.cpp b/src/lib/utility/messaging/MessageQueue.cpp index 13ed9323..b8506add 100644 --- a/src/lib/utility/messaging/MessageQueue.cpp +++ b/src/lib/utility/messaging/MessageQueue.cpp @@ -20,7 +20,12 @@ std::shared_ptr MessageQueue::getInstance() MessageQueue::~MessageQueue() { - // TODO: remove remaining listeners. And tell them that they shouldn't unregister anymore. + std::lock_guard lock(m_listenersMutex); + for (size_t i = 0; i < m_listeners.size(); i++) + { + m_listeners[i]->removedListener(); + } + m_listeners.clear(); } void MessageQueue::registerListener(MessageListenerBase* listener) diff --git a/src/lib_gui/qt/window/QtMainWindow.cpp b/src/lib_gui/qt/window/QtMainWindow.cpp index cd07b54a..af7807d2 100644 --- a/src/lib_gui/qt/window/QtMainWindow.cpp +++ b/src/lib_gui/qt/window/QtMainWindow.cpp @@ -559,7 +559,7 @@ void QtMainWindow::updateRecentProjectMenu() std::vector recentProjects = ApplicationSettings::getInstance()->getRecentProjects(); for (int i = 0; i < ApplicationSettings::getInstance()->getMaxRecentProjectsCount(); i++) { - if ((size_t)i < recentProjects.size()) + if ((size_t)i < recentProjects.size() && recentProjects[i].exists()) { FilePath project = recentProjects[i]; m_recentProjectAction[i]->setVisible(true); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp index 3b20dc43..9d5c61aa 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp @@ -528,8 +528,8 @@ void QtProjectWizzard::showSummary() summary->addContent(source, false, true); connectShowFiles(source); - summary->addContent(new QtProjectWizzardContentSimple(settings, window), false, true); - summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(settings, window), false, false); + summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(settings, window), false, true); + summary->addContent(new QtProjectWizzardContentSimple(settings, window), false, false); summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(settings, window), false, false); if (QSysInfo::macVersion() != QSysInfo::MV_None)