From 115615fc7ca880aa8e12308df79a0a63548c0d5b Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Fri, 8 Dec 2017 15:09:29 +0100 Subject: [PATCH] Qmake: Do not crash when accessing PriFiles from project tree The project tree is static nowadays, and the QmakePriFileNodes hold pointers to their corresponding PriFiles. This is fast, but not entirely safe: The PriFiles are constantly updating as the project is parsed. So make sure not to rely on the stored pointer while the project is parsing and go through Project::rootProFile() in that case. Once the parsing is done, the project tree has been updated with new data, that reflects the current QmakePriFile tree. Task-number: QTCREATORBUG-19428 Change-Id: Ifaa3432cad7774142d562648d93104629736d478 Reviewed-by: Eike Ziller --- src/plugins/qmakeprojectmanager/qmakenodes.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.cpp b/src/plugins/qmakeprojectmanager/qmakenodes.cpp index 2d0ff674657..5efacbf4c47 100644 --- a/src/plugins/qmakeprojectmanager/qmakenodes.cpp +++ b/src/plugins/qmakeprojectmanager/qmakenodes.cpp @@ -53,7 +53,11 @@ QmakePriFileNode::QmakePriFileNode(QmakeProject *project, QmakeProFileNode *qmak QmakePriFile *QmakePriFileNode::priFile() const { - return m_qmakePriFile; + if (!m_project->isParsing()) + return m_qmakePriFile; + // During a parsing run the qmakePriFile tree will change, so search for the PriFile and + // do not depend on the cached value. + return m_project->rootProFile()->findPriFile(filePath()); } bool QmakePriFileNode::deploysFolder(const QString &folder) const