Commit fcb6c498 authored by Christian Kamm's avatar Christian Kamm

Fix a memory leak with the QmlJS scope chain.

parent 28e348ac
......@@ -731,6 +731,25 @@ ScopeChain::ScopeChain()
{
}
ScopeChain::QmlComponentChain::QmlComponentChain()
: rootObject(0), ids(0)
{
}
ScopeChain::QmlComponentChain::~QmlComponentChain()
{
qDeleteAll(instantiatingComponents);
}
void ScopeChain::QmlComponentChain::clear()
{
qDeleteAll(instantiatingComponents);
instantiatingComponents.clear();
rootObject = 0;
functionScopes.clear();
ids = 0;
}
void ScopeChain::QmlComponentChain::add(QList<const ObjectValue *> *list) const
{
foreach (QmlComponentChain *parent, instantiatingComponents)
......
......@@ -229,9 +229,8 @@ public:
struct QmlComponentChain
{
QmlComponentChain()
: rootObject(0), ids(0)
{}
QmlComponentChain();
~QmlComponentChain();
QList<QmlComponentChain *> instantiatingComponents;
const ObjectValue *rootObject;
......@@ -239,6 +238,7 @@ public:
const ObjectValue *ids;
void add(QList<const ObjectValue *> *list) const;
void clear();
};
const ObjectValue *globalScope;
......
......@@ -48,6 +48,7 @@ void Link::scopeChainAt(Document::Ptr doc, const QList<Node *> &astPath)
if (doc->qmlProgram()) {
_context->setLookupMode(Context::QmlLookup);
scopeChain.qmlComponentScope.clear();
makeComponentChain(doc, &scopeChain.qmlComponentScope, &componentScopes);
if (const ObjectValue *typeEnvironment = _context->typeEnvironment(doc.data()))
......
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