forked from qt-creator/qt-creator
QmakeProjectManager: Fix crash on reparsing
After a re-parse, the existing IDocuments need to be updated with the
new QmakePriFile object, as the old one may no longer be valid and thus
cause a crash on the next re-parse.
Amends f3bd07efd1.
Fixes: QTCREATORBUG-24683
Change-Id: Ib03d3005cb7831f1e05cb116aa3cdfe6cf5e72ad
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -127,6 +127,8 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
void setPriFile(QmakePriFile *priFile) { m_priFile = priFile; }
|
||||
|
||||
private:
|
||||
QmakePriFile *m_priFile;
|
||||
};
|
||||
@@ -305,15 +307,24 @@ void QmakeBuildSystem::updateDocuments()
|
||||
projectDocuments.insert(n->filePath());
|
||||
|
||||
});
|
||||
project()->setExtraProjectFiles(projectDocuments, [p = project()](const FilePath &fp)
|
||||
-> std::unique_ptr<Core::IDocument> {
|
||||
const auto priFileForPath = [p = project()](const FilePath &fp) -> QmakePriFile * {
|
||||
const Node * const n = p->nodeForFilePath(fp, [](const Node *n) {
|
||||
return dynamic_cast<const QmakePriFileNode *>(n); });
|
||||
QTC_ASSERT(n, return std::make_unique<Core::IDocument>());
|
||||
QmakePriFile * const priFile = static_cast<const QmakePriFileNode *>(n)->priFile();
|
||||
QTC_ASSERT(n, return nullptr);
|
||||
return static_cast<const QmakePriFileNode *>(n)->priFile();
|
||||
};
|
||||
const auto docGenerator = [&](const FilePath &fp)
|
||||
-> std::unique_ptr<Core::IDocument> {
|
||||
QmakePriFile * const priFile = priFileForPath(fp);
|
||||
QTC_ASSERT(priFile, return std::make_unique<Core::IDocument>());
|
||||
return std::make_unique<QmakePriFileDocument>(priFile, fp);
|
||||
});
|
||||
};
|
||||
const auto docUpdater = [&](Core::IDocument *doc) {
|
||||
QmakePriFile * const priFile = priFileForPath(doc->filePath());
|
||||
QTC_ASSERT(priFile, return);
|
||||
static_cast<QmakePriFileDocument *>(doc)->setPriFile(priFile);
|
||||
};
|
||||
project()->setExtraProjectFiles(projectDocuments, docGenerator, docUpdater);
|
||||
}
|
||||
|
||||
void QmakeBuildSystem::updateCppCodeModel()
|
||||
|
||||
Reference in New Issue
Block a user