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

Fix a memory leak with the QmlJS scope chain.

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