From 3334dfcf53a7b37ca9a3cf11f093b04155fb8ae2 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Sat, 3 Feb 2024 21:06:15 +0100 Subject: [PATCH] Axivion: Fix showing marks on project opening Inside a slot connected to startupProjectChanged() connect to Project::fileListChanged() instead of connecting to ProjectManager::projectFinishedParsing(). Change-Id: I41059ae24138e79747eada1380c5970fbe30b666 Reviewed-by: Christian Stenger Reviewed-by: --- src/plugins/axivion/axivionplugin.cpp | 60 +++++++++++---------------- 1 file changed, 24 insertions(+), 36 deletions(-) diff --git a/src/plugins/axivion/axivionplugin.cpp b/src/plugins/axivion/axivionplugin.cpp index 6cd5164a63b..82bc0862c79 100644 --- a/src/plugins/axivion/axivionplugin.cpp +++ b/src/plugins/axivion/axivionplugin.cpp @@ -134,9 +134,9 @@ class AxivionPluginPrivate : public QObject public: AxivionPluginPrivate(); void handleSslErrors(QNetworkReply *reply, const QList &errors); - void onStartupProjectChanged(); + void onStartupProjectChanged(Project *project); void fetchProjectInfo(const QString &projectName); - void handleOpenedDocs(Project *project); + void handleOpenedDocs(); void onDocumentOpened(IDocument *doc); void onDocumentClosed(IDocument * doc); void clearAllMarks(); @@ -147,6 +147,7 @@ public: AxivionOutputPane m_axivionOutputPane; std::optional m_dashboardInfo; std::optional m_currentProjectInfo; + Project *m_project = nullptr; bool m_runningQuery = false; TaskTreeRunner m_taskTreeRunner; std::unordered_map> m_docMarksTrees; @@ -236,17 +237,24 @@ void AxivionPluginPrivate::handleSslErrors(QNetworkReply *reply, const QListdashboardProjectName()); } @@ -491,10 +499,9 @@ Group issueHtmlRecipe(const QString &issueId, const HtmlHandler &handler) void AxivionPluginPrivate::fetchProjectInfo(const QString &projectName) { - if (m_taskTreeRunner.isRunning()) { // TODO: cache in queue and run when task tree finished - QTimer::singleShot(3000, this, [this, projectName] { fetchProjectInfo(projectName); }); + if (!m_project) return; - } + clearAllMarks(); if (projectName.isEmpty()) { m_currentProjectInfo = {}; @@ -513,15 +520,7 @@ void AxivionPluginPrivate::fetchProjectInfo(const QString &projectName) const auto handler = [this](const Dto::ProjectInfoDto &data) { m_currentProjectInfo = data; m_axivionOutputPane.updateDashboard(); - // handle already opened documents - if (auto buildSystem = ProjectManager::startupBuildSystem(); - !buildSystem || !buildSystem->isParsing()) { - handleOpenedDocs(nullptr); - } else { - connect(ProjectManager::instance(), - &ProjectManager::projectFinishedParsing, - this, &AxivionPluginPrivate::handleOpenedDocs); - } + handleOpenedDocs(); }; const QUrl url(settings().server.dashboard); @@ -559,16 +558,11 @@ void AxivionPluginPrivate::fetchIssueInfo(const QString &id) m_issueInfoRunner.start(issueHtmlRecipe(QString("SV") + id, ruleHandler)); } -void AxivionPluginPrivate::handleOpenedDocs(Project *project) +void AxivionPluginPrivate::handleOpenedDocs() { - if (project && ProjectManager::startupProject() != project) - return; const QList openDocuments = DocumentModel::openedDocuments(); for (IDocument *doc : openDocuments) onDocumentOpened(doc); - if (project) - disconnect(ProjectManager::instance(), &ProjectManager::projectFinishedParsing, - this, &AxivionPluginPrivate::handleOpenedDocs); } void AxivionPluginPrivate::clearAllMarks() @@ -580,18 +574,12 @@ void AxivionPluginPrivate::clearAllMarks() void AxivionPluginPrivate::onDocumentOpened(IDocument *doc) { - if (!m_currentProjectInfo) // we do not have a project info (yet) - return; - - Project *project = ProjectManager::startupProject(); - // TODO: Sometimes the isKnownFile() returns false after opening a session. - // This happens randomly on linux. - if (!doc || !project->isKnownFile(doc->filePath())) + if (!doc || !m_currentProjectInfo || !m_project || !m_project->isKnownFile(doc->filePath())) return; IssueListSearch search; search.kind = "SV"; - search.filter_path = doc->filePath().relativeChildPath(project->projectDirectory()).path(); + search.filter_path = doc->filePath().relativeChildPath(m_project->projectDirectory()).path(); search.limit = 0; const auto issuesHandler = [this](const Dto::IssueTableDto &dto) {