diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp index 065dbacf2e5..908438b8620 100644 --- a/src/plugins/projectexplorer/project.cpp +++ b/src/plugins/projectexplorer/project.cpp @@ -388,6 +388,25 @@ void Project::setExtraProjectFiles(const QSet &projectDocumentP } } +void Project::updateExtraProjectFiles(const QSet &projectDocumentPaths, + const DocUpdater &docUpdater) +{ + for (const Utils::FilePath &fp : projectDocumentPaths) { + for (const auto &doc : d->m_extraProjectDocuments) { + if (doc->filePath() == fp) { + docUpdater(doc.get()); + break; + } + } + } +} + +void Project::updateExtraProjectFiles(const DocUpdater &docUpdater) +{ + for (const auto &doc : qAsConst(d->m_extraProjectDocuments)) + docUpdater(doc.get()); +} + Target *Project::target(Utils::Id id) const { return Utils::findOrDefault(d->m_targets, Utils::equal(&Target::id, id)); diff --git a/src/plugins/projectexplorer/project.h b/src/plugins/projectexplorer/project.h index 64236a39a26..e91fec8e7cf 100644 --- a/src/plugins/projectexplorer/project.h +++ b/src/plugins/projectexplorer/project.h @@ -169,6 +169,9 @@ public: void setExtraProjectFiles(const QSet &projectDocumentPaths, const DocGenerator &docGenerator = {}, const DocUpdater &docUpdater = {}); + void updateExtraProjectFiles(const QSet &projectDocumentPaths, + const DocUpdater &docUpdater); + void updateExtraProjectFiles(const DocUpdater &docUpdater); void setDisplayName(const QString &name); void setProjectLanguage(Utils::Id id, bool enabled); diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp index f4ea729c899..387c0688a4b 100644 --- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp @@ -122,7 +122,8 @@ public: Q_UNUSED(errorString) Q_UNUSED(flag) Q_UNUSED(type) - m_priFile->scheduleUpdate(); + if (m_priFile) + m_priFile->scheduleUpdate(); return true; } @@ -692,7 +693,26 @@ void QmakeBuildSystem::asyncUpdate() return; } + // Make sure we ignore requests for re-evaluation for files whose QmakePriFile objects + // will get deleted during the parse. + const auto docUpdater = [](Core::IDocument *doc) { + static_cast(doc)->setPriFile(nullptr); + }; + if (m_asyncUpdateState != AsyncFullUpdatePending) { + QSet projectFilePaths; + for (QmakeProFile * const file : qAsConst(m_partialEvaluate)) { + QVector priFiles = file->children(); + for (int i = 0; i < priFiles.count(); ++i) { + const QmakePriFile * const priFile = priFiles.at(i); + projectFilePaths << priFile->filePath(); + priFiles << priFile->children(); + } + } + project()->updateExtraProjectFiles(projectFilePaths, docUpdater); + } + if (m_asyncUpdateState == AsyncFullUpdatePending) { + project()->updateExtraProjectFiles(docUpdater); rootProFile()->asyncUpdate(); } else { foreach (QmakeProFile *file, m_partialEvaluate)