Commit 88601712 authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS: Make ScopeChain more const-correct.

We don't want people modifying the shared component chain on a
const Context *.
parent f49a8595
...@@ -1370,10 +1370,10 @@ void ScopeChain::QmlComponentChain::clear() ...@@ -1370,10 +1370,10 @@ void ScopeChain::QmlComponentChain::clear()
document = Document::Ptr(0); document = Document::Ptr(0);
} }
void ScopeChain::QmlComponentChain::add(QList<const ObjectValue *> *list) const void ScopeChain::QmlComponentChain::collect(QList<const ObjectValue *> *list) const
{ {
foreach (QmlComponentChain *parent, instantiatingComponents) foreach (const QmlComponentChain *parent, instantiatingComponents)
parent->add(list); parent->collect(list);
if (!document) if (!document)
return; return;
...@@ -1393,8 +1393,8 @@ void ScopeChain::update() ...@@ -1393,8 +1393,8 @@ void ScopeChain::update()
// the root scope in js files doesn't see instantiating components // the root scope in js files doesn't see instantiating components
if (jsScopes.count() != 1 || !qmlScopeObjects.isEmpty()) { if (jsScopes.count() != 1 || !qmlScopeObjects.isEmpty()) {
if (qmlComponentScope) { if (qmlComponentScope) {
foreach (QmlComponentChain *parent, qmlComponentScope->instantiatingComponents) foreach (const QmlComponentChain *parent, qmlComponentScope->instantiatingComponents)
parent->add(&_all); parent->collect(&_all);
} }
} }
......
...@@ -249,15 +249,15 @@ public: ...@@ -249,15 +249,15 @@ public:
QmlComponentChain(); QmlComponentChain();
~QmlComponentChain(); ~QmlComponentChain();
QList<QmlComponentChain *> instantiatingComponents; QList<const QmlComponentChain *> instantiatingComponents;
Document::Ptr document; Document::Ptr document;
void add(QList<const ObjectValue *> *list) const; void collect(QList<const ObjectValue *> *list) const;
void clear(); void clear();
}; };
const ObjectValue *globalScope; const ObjectValue *globalScope;
QSharedPointer<QmlComponentChain> qmlComponentScope; QSharedPointer<const QmlComponentChain> qmlComponentScope;
QList<const ObjectValue *> qmlScopeObjects; QList<const ObjectValue *> qmlScopeObjects;
const ObjectValue *qmlTypes; const ObjectValue *qmlTypes;
QList<const ObjectValue *> jsScopes; QList<const ObjectValue *> jsScopes;
......
...@@ -83,10 +83,11 @@ void Link::initializeScopeChain() ...@@ -83,10 +83,11 @@ void Link::initializeScopeChain()
Bind *bind = _doc->bind(); Bind *bind = _doc->bind();
QHash<Document *, ScopeChain::QmlComponentChain *> componentScopes; QHash<Document *, ScopeChain::QmlComponentChain *> componentScopes;
scopeChain.qmlComponentScope = QSharedPointer<ScopeChain::QmlComponentChain>(new ScopeChain::QmlComponentChain()); ScopeChain::QmlComponentChain *chain = new ScopeChain::QmlComponentChain;
scopeChain.qmlComponentScope = QSharedPointer<const ScopeChain::QmlComponentChain>(chain);
if (_doc->qmlProgram()) { if (_doc->qmlProgram()) {
componentScopes.insert(_doc.data(), scopeChain.qmlComponentScope.data()); componentScopes.insert(_doc.data(), chain);
makeComponentChain(_doc, scopeChain.qmlComponentScope.data(), &componentScopes); makeComponentChain(_doc, chain, &componentScopes);
if (const ObjectValue *typeEnvironment = _context->typeEnvironment(_doc.data())) if (const ObjectValue *typeEnvironment = _context->typeEnvironment(_doc.data()))
scopeChain.qmlTypes = typeEnvironment; scopeChain.qmlTypes = typeEnvironment;
...@@ -97,7 +98,7 @@ void Link::initializeScopeChain() ...@@ -97,7 +98,7 @@ void Link::initializeScopeChain()
if (_doc->fileName() == fileImport.name) { if (_doc->fileName() == fileImport.name) {
ScopeChain::QmlComponentChain *component = new ScopeChain::QmlComponentChain; ScopeChain::QmlComponentChain *component = new ScopeChain::QmlComponentChain;
componentScopes.insert(otherDoc.data(), component); componentScopes.insert(otherDoc.data(), component);
scopeChain.qmlComponentScope->instantiatingComponents += component; chain->instantiatingComponents += component;
makeComponentChain(otherDoc, component, &componentScopes); makeComponentChain(otherDoc, component, &componentScopes);
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment