From b47b9ea9511db6330db22c8abfd67658323430ea Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 19 Jul 2016 10:51:03 +0200 Subject: [PATCH] QML: Band-aid fix to prevent a crash If the document that FindExportedCppTypes is to search is not in the snapshot, skip over it (instead of passing the shared pointer with a null-value inside). Change-Id: I462e3d22aa4e1cc51e710c75ae0f9399c151240b Reviewed-by: Ulf Hermann Reviewed-by: Nikolai Kosjar --- src/libs/qmljs/qmljsfindexportedcpptypes.cpp | 3 +++ src/libs/qmljs/qmljsmodelmanagerinterface.cpp | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libs/qmljs/qmljsfindexportedcpptypes.cpp b/src/libs/qmljs/qmljsfindexportedcpptypes.cpp index ff82a56cd54..e1c4d55de70 100644 --- a/src/libs/qmljs/qmljsfindexportedcpptypes.cpp +++ b/src/libs/qmljs/qmljsfindexportedcpptypes.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -819,6 +820,8 @@ FindExportedCppTypes::FindExportedCppTypes(const CPlusPlus::Snapshot &snapshot) QStringList FindExportedCppTypes::operator()(const CPlusPlus::Document::Ptr &document) { + QTC_ASSERT(!document.isNull(), return QStringList()); + m_contextProperties.clear(); m_exportedTypes.clear(); QStringList fileNames; diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp index a919087fea6..bdd6e6eeab2 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp @@ -1321,7 +1321,10 @@ void ModelManagerInterface::updateCppQmlTypes(QFutureInterface &interface, if (!scan) { hasNewInfo = newData.remove(fileName) > 0 || hasNewInfo; foreach (const QString &file, newDeclarations[fileName]) { - finder(snapshot.document(file)); + CPlusPlus::Document::Ptr doc = snapshot.document(file); + if (doc.isNull()) + continue; + finder(doc); hasNewInfo = rescanExports(file, finder, newData) || hasNewInfo; } continue;