From 912a1b95a9239ef6bd5e70c931fee0d3c15805e9 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen <erik.verbruggen@nokia.com> Date: Thu, 25 Feb 2010 12:56:59 +0100 Subject: [PATCH] Fixed crash when putting a second root item into a QML file. --- src/libs/qmljs/qmljslink.cpp | 3 ++- src/libs/qmljs/qmljsscopebuilder.cpp | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/qmljs/qmljslink.cpp b/src/libs/qmljs/qmljslink.cpp index 660d4f7ff7d..c94ad265e05 100644 --- a/src/libs/qmljs/qmljslink.cpp +++ b/src/libs/qmljs/qmljslink.cpp @@ -49,6 +49,7 @@ void Link::scopeChainAt(Document::Ptr doc, const QList<Node *> &astPath) _context->setLookupMode(Context::QmlLookup); scopeChain.qmlComponentScope.clear(); + componentScopes.insert(doc.data(), &scopeChain.qmlComponentScope); makeComponentChain(doc, &scopeChain.qmlComponentScope, &componentScopes); if (const ObjectValue *typeEnvironment = _context->typeEnvironment(doc.data())) @@ -93,7 +94,7 @@ void Link::makeComponentChain( continue; if (otherDoc->bind()->usesQmlPrototype(bind->rootObjectValue(), _context)) { if (components->contains(otherDoc.data())) { - target->instantiatingComponents += components->value(otherDoc.data()); +// target->instantiatingComponents += components->value(otherDoc.data()); } else { ScopeChain::QmlComponentChain *component = new ScopeChain::QmlComponentChain; components->insert(otherDoc.data(), component); diff --git a/src/libs/qmljs/qmljsscopebuilder.cpp b/src/libs/qmljs/qmljsscopebuilder.cpp index 18c8dcf1b8c..9ab4381441f 100644 --- a/src/libs/qmljs/qmljsscopebuilder.cpp +++ b/src/libs/qmljs/qmljsscopebuilder.cpp @@ -69,6 +69,8 @@ void ScopeBuilder::setQmlScopeObject(Node *node) const ObjectValue *scopeObject = _doc->bind()->findQmlObject(node); if (scopeObject) { scopeChain.qmlScopeObjects += scopeObject; + } else { + return; // Probably syntax errors, where we're working with a "recovered" AST. } #ifndef NO_DECLARATIVE_BACKEND -- GitLab