aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libs/qmljs/qmljsinterpreter.cpp12
-rw-r--r--src/libs/qmljs/qmljsinterpreter.h6
-rw-r--r--src/libs/qmljs/qmljslink.cpp8
3 files changed, 15 insertions, 11 deletions
diff --git a/src/libs/qmljs/qmljsinterpreter.cpp b/src/libs/qmljs/qmljsinterpreter.cpp
index 9bd5d7dcca9..eedcf519e8b 100644
--- a/src/libs/qmljs/qmljsinterpreter.cpp
+++ b/src/libs/qmljs/qmljsinterpreter.cpp
@@ -1392,15 +1392,17 @@ void ScopeChain::update()
// the root scope in js files doesn't see instantiating components
if (jsScopes.count() != 1 || !qmlScopeObjects.isEmpty()) {
- foreach (QmlComponentChain *parent, qmlComponentScope.instantiatingComponents)
- parent->add(&_all);
+ if (qmlComponentScope) {
+ foreach (QmlComponentChain *parent, qmlComponentScope->instantiatingComponents)
+ parent->add(&_all);
+ }
}
ObjectValue *root = 0;
ObjectValue *ids = 0;
- if (qmlComponentScope.document) {
- root = qmlComponentScope.document->bind()->rootObjectValue();
- ids = qmlComponentScope.document->bind()->idEnvironment();
+ if (qmlComponentScope && qmlComponentScope->document) {
+ root = qmlComponentScope->document->bind()->rootObjectValue();
+ ids = qmlComponentScope->document->bind()->idEnvironment();
}
if (root && !qmlScopeObjects.contains(root))
diff --git a/src/libs/qmljs/qmljsinterpreter.h b/src/libs/qmljs/qmljsinterpreter.h
index 5ec91c009d5..67222cd3b02 100644
--- a/src/libs/qmljs/qmljsinterpreter.h
+++ b/src/libs/qmljs/qmljsinterpreter.h
@@ -242,8 +242,10 @@ class QMLJS_EXPORT ScopeChain
public:
ScopeChain();
- struct QmlComponentChain
+ class QmlComponentChain
{
+ Q_DISABLE_COPY(QmlComponentChain)
+ public:
QmlComponentChain();
~QmlComponentChain();
@@ -255,7 +257,7 @@ public:
};
const ObjectValue *globalScope;
- QmlComponentChain qmlComponentScope;
+ QSharedPointer<QmlComponentChain> qmlComponentScope;
QList<const ObjectValue *> qmlScopeObjects;
const ObjectValue *qmlTypes;
QList<const ObjectValue *> jsScopes;
diff --git a/src/libs/qmljs/qmljslink.cpp b/src/libs/qmljs/qmljslink.cpp
index 12b4497b9c8..ffc8edf3804 100644
--- a/src/libs/qmljs/qmljslink.cpp
+++ b/src/libs/qmljs/qmljslink.cpp
@@ -83,10 +83,10 @@ void Link::initializeScopeChain()
Bind *bind = _doc->bind();
QHash<Document *, ScopeChain::QmlComponentChain *> componentScopes;
+ scopeChain.qmlComponentScope = QSharedPointer<ScopeChain::QmlComponentChain>(new ScopeChain::QmlComponentChain());
if (_doc->qmlProgram()) {
- scopeChain.qmlComponentScope.clear();
- componentScopes.insert(_doc.data(), &scopeChain.qmlComponentScope);
- makeComponentChain(_doc, &scopeChain.qmlComponentScope, &componentScopes);
+ componentScopes.insert(_doc.data(), scopeChain.qmlComponentScope.data());
+ makeComponentChain(_doc, scopeChain.qmlComponentScope.data(), &componentScopes);
if (const ObjectValue *typeEnvironment = _context->typeEnvironment(_doc.data()))
scopeChain.qmlTypes = typeEnvironment;
@@ -97,7 +97,7 @@ void Link::initializeScopeChain()
if (_doc->fileName() == fileImport.name) {
ScopeChain::QmlComponentChain *component = new ScopeChain::QmlComponentChain;
componentScopes.insert(otherDoc.data(), component);
- scopeChain.qmlComponentScope.instantiatingComponents += component;
+ scopeChain.qmlComponentScope->instantiatingComponents += component;
makeComponentChain(otherDoc, component, &componentScopes);
}
}