From 37aecdd112e496c4f246aed87f6ffaee15f9d4f9 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 3 Feb 2020 12:38:08 +0100 Subject: [PATCH] QmakeProjectManager: Do not keep an IDocument in QmakePriFile Instead, we keep the IDocuments as "extra project files" in the Project class, like the other project managers do it. This has two advantages: - The document is no longer created in a parser thread callback, improving Qt Creator responsiveness while loading a project. - The IDocuments no longer get needlessly destroyed and re-created on a re-parse. This is relevant because adding these objects to the DocumentManager results in the creation of file watchers, which is expensive. Task-number: QTCREATORBUG-18533 Change-Id: I49c03377974e6b33340234dbabbbd82b8d0c827c Reviewed-by: hjk --- src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp | 2 -- src/plugins/qmakeprojectmanager/qmakeparsernodes.h | 1 - src/plugins/qmakeprojectmanager/qmakeproject.cpp | 10 ++++++++++ src/plugins/qmakeprojectmanager/qmakeproject.h | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp b/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp index a226ca6400f..4aec1f02049 100644 --- a/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp @@ -182,8 +182,6 @@ void QmakePriFile::finishInitialization(QmakeBuildSystem *buildSystem, QmakeProF QTC_ASSERT(buildSystem, return); m_buildSystem = buildSystem; m_qmakeProFile = qmakeProFile; - m_priFileDocument = std::make_unique(this, filePath()); - Core::DocumentManager::addDocument(m_priFileDocument.get()); } FilePath QmakePriFile::filePath() const diff --git a/src/plugins/qmakeprojectmanager/qmakeparsernodes.h b/src/plugins/qmakeprojectmanager/qmakeparsernodes.h index 9a5977348af..0812e162550 100644 --- a/src/plugins/qmakeprojectmanager/qmakeparsernodes.h +++ b/src/plugins/qmakeprojectmanager/qmakeparsernodes.h @@ -236,7 +236,6 @@ private: QmakePriFile *m_parent = nullptr; QVector m_children; - std::unique_ptr m_priFileDocument; Utils::TextFileFormat m_textFormat; // Memory is cheap... diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp index ca2a977258f..91987e2574f 100644 --- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp @@ -259,6 +259,15 @@ void QmakeBuildSystem::updateCodeModels() updateQmlJSCodeModel(); } +void QmakeBuildSystem::updateDocuments() +{ + QVector projectDocuments; + project()->rootProjectNode()->forEachProjectNode([&projectDocuments](const ProjectNode *n) { + projectDocuments << n->filePath(); + }); + project()->setExtraProjectFiles(projectDocuments); +} + void QmakeBuildSystem::updateCppCodeModel() { m_toolChainWarnings.clear(); @@ -528,6 +537,7 @@ void QmakeBuildSystem::decrementPendingEvaluateFutures() m_asyncUpdateState = Base; updateBuildSystemData(); updateCodeModels(); + updateDocuments(); target()->updateDefaultDeployConfigurations(); m_guard.markAsSuccess(); // Qmake always returns (some) data, even when it failed:-) m_guard = {}; // This triggers emitParsingFinished by destroying the previous guard. diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.h b/src/plugins/qmakeprojectmanager/qmakeproject.h index 8c138e54994..04cad72c690 100644 --- a/src/plugins/qmakeprojectmanager/qmakeproject.h +++ b/src/plugins/qmakeprojectmanager/qmakeproject.h @@ -151,6 +151,7 @@ public: bool wasEvaluateCanceled(); void updateCodeModels(); + void updateDocuments(); void watchFolders(const QStringList &l, QmakePriFile *file); void unwatchFolders(const QStringList &l, QmakePriFile *file);