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()
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)
parent->add(list);
foreach (const QmlComponentChain *parent, instantiatingComponents)
parent->collect(list);
if (!document)
return;
......@@ -1393,8 +1393,8 @@ void ScopeChain::update()
// the root scope in js files doesn't see instantiating components
if (jsScopes.count() != 1 || !qmlScopeObjects.isEmpty()) {
if (qmlComponentScope) {
foreach (QmlComponentChain *parent, qmlComponentScope->instantiatingComponents)
parent->add(&_all);
foreach (const QmlComponentChain *parent, qmlComponentScope->instantiatingComponents)
parent->collect(&_all);
}
}
......
......@@ -249,15 +249,15 @@ public:
QmlComponentChain();
~QmlComponentChain();
QList<QmlComponentChain *> instantiatingComponents;
QList<const QmlComponentChain *> instantiatingComponents;
Document::Ptr document;
void add(QList<const ObjectValue *> *list) const;
void collect(QList<const ObjectValue *> *list) const;
void clear();
};
const ObjectValue *globalScope;
QSharedPointer<QmlComponentChain> qmlComponentScope;
QSharedPointer<const QmlComponentChain> qmlComponentScope;
QList<const ObjectValue *> qmlScopeObjects;
const ObjectValue *qmlTypes;
QList<const ObjectValue *> jsScopes;
......
......@@ -83,10 +83,11 @@ void Link::initializeScopeChain()
Bind *bind = _doc->bind();
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()) {
componentScopes.insert(_doc.data(), scopeChain.qmlComponentScope.data());
makeComponentChain(_doc, scopeChain.qmlComponentScope.data(), &componentScopes);
componentScopes.insert(_doc.data(), chain);
makeComponentChain(_doc, chain, &componentScopes);
if (const ObjectValue *typeEnvironment = _context->typeEnvironment(_doc.data()))
scopeChain.qmlTypes = typeEnvironment;
......@@ -97,7 +98,7 @@ void Link::initializeScopeChain()
if (_doc->fileName() == fileImport.name) {
ScopeChain::QmlComponentChain *component = new ScopeChain::QmlComponentChain;
componentScopes.insert(otherDoc.data(), component);
scopeChain.qmlComponentScope->instantiatingComponents += component;
chain->instantiatingComponents += component;
makeComponentChain(otherDoc, component, &componentScopes);
}
}
......
Markdown is supported
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