diff options
author | Niklas Kurkisuo <ext-niklas.kurkisuo@nokia.com> | 2010-12-03 11:50:36 (GMT) |
---|---|---|
committer | David Boddie <david.boddie@nokia.com> | 2011-05-13 13:56:29 (GMT) |
commit | 23267553627ac3c4cbcd918283bee8e665deeff9 (patch) | |
tree | 9301d656c9cd80c81192538231f0731c0b3c7850 /src/xmlpatterns | |
parent | 3d27a19ca009836b812b59c3359db1369d391181 (diff) | |
download | Qt-23267553627ac3c4cbcd918283bee8e665deeff9.zip Qt-23267553627ac3c4cbcd918283bee8e665deeff9.tar.gz Qt-23267553627ac3c4cbcd918283bee8e665deeff9.tar.bz2 |
Fix memory leak in QXmlQuery::setQuery.
There is a circular reference dependency between VariableDeclaration
and the classes EvaluationCache, ExpressionVariableReference and
TemplateParameterReference. By removing the explicitly shared pointer
of VariableDeclaration in these classes the circle is broken and memory
is freed correctly.
Task-number: QT-4106
Integrated-by: David Boddie
Diffstat (limited to 'src/xmlpatterns')
8 files changed, 18 insertions, 18 deletions
diff --git a/src/xmlpatterns/expr/qevaluationcache.cpp b/src/xmlpatterns/expr/qevaluationcache.cpp index 2d1bb56..52f5a46 100644 --- a/src/xmlpatterns/expr/qevaluationcache.cpp +++ b/src/xmlpatterns/expr/qevaluationcache.cpp @@ -47,7 +47,7 @@ template<bool IsForGlobal> EvaluationCache<IsForGlobal>::EvaluationCache(const Expression::Ptr &op, - const VariableDeclaration::Ptr &varDecl, + const VariableDeclaration *varDecl, const VariableSlotID aSlot) : SingleContainer(op) , m_declaration(varDecl) , m_varSlot(aSlot) diff --git a/src/xmlpatterns/expr/qevaluationcache_p.h b/src/xmlpatterns/expr/qevaluationcache_p.h index 86aeaf8..6a2504e 100644 --- a/src/xmlpatterns/expr/qevaluationcache_p.h +++ b/src/xmlpatterns/expr/qevaluationcache_p.h @@ -97,7 +97,7 @@ namespace QPatternist { public: EvaluationCache(const Expression::Ptr &operand, - const VariableDeclaration::Ptr &varDecl, + const VariableDeclaration *varDecl, const VariableSlotID slot); virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const; @@ -124,7 +124,7 @@ namespace QPatternist private: static DynamicContext::Ptr topFocusContext(const DynamicContext::Ptr &context); - const VariableDeclaration::Ptr m_declaration; + const VariableDeclaration *m_declaration; /** * This variable must not be called m_slot. If it so, a compiler bug on * HP-UX-aCC-64 is triggered in the constructor initializor. See the diff --git a/src/xmlpatterns/expr/qexpressionvariablereference.cpp b/src/xmlpatterns/expr/qexpressionvariablereference.cpp index 3b9ecb1..fda87b5 100644 --- a/src/xmlpatterns/expr/qexpressionvariablereference.cpp +++ b/src/xmlpatterns/expr/qexpressionvariablereference.cpp @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE using namespace QPatternist; ExpressionVariableReference::ExpressionVariableReference(const VariableSlotID slotP, - const VariableDeclaration::Ptr &varDecl) : VariableReference(slotP) + const VariableDeclaration *varDecl) : VariableReference(slotP) , m_varDecl(varDecl) { } diff --git a/src/xmlpatterns/expr/qexpressionvariablereference_p.h b/src/xmlpatterns/expr/qexpressionvariablereference_p.h index 40c835e..641be63 100644 --- a/src/xmlpatterns/expr/qexpressionvariablereference_p.h +++ b/src/xmlpatterns/expr/qexpressionvariablereference_p.h @@ -77,7 +77,7 @@ namespace QPatternist { public: ExpressionVariableReference(const VariableSlotID slot, - const VariableDeclaration::Ptr &varDecl); + const VariableDeclaration *varDecl); virtual bool evaluateEBV(const DynamicContext::Ptr &context) const; virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const; @@ -90,9 +90,9 @@ namespace QPatternist virtual ExpressionVisitorResult::Ptr accept(const ExpressionVisitor::Ptr &visitor) const; inline const Expression::Ptr &sourceExpression() const; - inline const VariableDeclaration::Ptr &variableDeclaration() const; + inline const VariableDeclaration *variableDeclaration() const; private: - const VariableDeclaration::Ptr m_varDecl; + const VariableDeclaration *m_varDecl; }; inline const Expression::Ptr &ExpressionVariableReference::sourceExpression() const @@ -100,7 +100,7 @@ namespace QPatternist return m_varDecl->expression(); } - inline const VariableDeclaration::Ptr &ExpressionVariableReference::variableDeclaration() const + inline const VariableDeclaration *ExpressionVariableReference::variableDeclaration() const { return m_varDecl; } diff --git a/src/xmlpatterns/expr/qtemplateparameterreference.cpp b/src/xmlpatterns/expr/qtemplateparameterreference.cpp index 550e39f..15d65f9 100644 --- a/src/xmlpatterns/expr/qtemplateparameterreference.cpp +++ b/src/xmlpatterns/expr/qtemplateparameterreference.cpp @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE using namespace QPatternist; -TemplateParameterReference::TemplateParameterReference(const VariableDeclaration::Ptr &varDecl) : m_varDecl(varDecl) +TemplateParameterReference::TemplateParameterReference(const VariableDeclaration *varDecl) : m_varDecl(varDecl) { } diff --git a/src/xmlpatterns/expr/qtemplateparameterreference_p.h b/src/xmlpatterns/expr/qtemplateparameterreference_p.h index 7eb9562..8fe1aa9 100644 --- a/src/xmlpatterns/expr/qtemplateparameterreference_p.h +++ b/src/xmlpatterns/expr/qtemplateparameterreference_p.h @@ -70,7 +70,7 @@ namespace QPatternist class TemplateParameterReference : public EmptyContainer { public: - TemplateParameterReference(const VariableDeclaration::Ptr &varDecl); + TemplateParameterReference(const VariableDeclaration *varDecl); virtual bool evaluateEBV(const DynamicContext::Ptr &context) const; virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const; @@ -81,10 +81,10 @@ namespace QPatternist virtual Properties properties() const; inline const Expression::Ptr &sourceExpression() const; - inline const VariableDeclaration::Ptr &variableDeclaration() const; + inline const VariableDeclaration *variableDeclaration() const; private: - const VariableDeclaration::Ptr m_varDecl; + const VariableDeclaration *m_varDecl; }; inline const Expression::Ptr &TemplateParameterReference::sourceExpression() const @@ -92,7 +92,7 @@ namespace QPatternist return m_varDecl->expression(); } - inline const VariableDeclaration::Ptr &TemplateParameterReference::variableDeclaration() const + inline const VariableDeclaration *TemplateParameterReference::variableDeclaration() const { return m_varDecl; } diff --git a/src/xmlpatterns/expr/quserfunctioncallsite.cpp b/src/xmlpatterns/expr/quserfunctioncallsite.cpp index 4e81484..65bbeab 100644 --- a/src/xmlpatterns/expr/quserfunctioncallsite.cpp +++ b/src/xmlpatterns/expr/quserfunctioncallsite.cpp @@ -227,7 +227,7 @@ void UserFunctionCallsite::setSource(const UserFunction::Ptr &userFunction, /* Note that we pass in cacheSlotOffset + i here instead of varDecls.at(i)->slot since * we want independent caches for each callsite. */ m_operands[i] = Expression::Ptr(new EvaluationCache<false>(m_operands.at(i), - varDecls.at(i), + varDecls.at(i).data(), cacheSlotOffset + i)); } } diff --git a/src/xmlpatterns/parser/qquerytransformparser.cpp b/src/xmlpatterns/parser/qquerytransformparser.cpp index 4858e11..f937904 100644 --- a/src/xmlpatterns/parser/qquerytransformparser.cpp +++ b/src/xmlpatterns/parser/qquerytransformparser.cpp @@ -988,9 +988,9 @@ static Expression::Ptr pushVariable(const QXmlName name, * In some cases the EvaluationCache instance isn't necessary, but in those cases EvaluationCache * optimizes itself away. */ if(type == VariableDeclaration::ExpressionVariable) - checked = create(new EvaluationCache<false>(checked, var, parseInfo->allocateCacheSlot()), sourceLocator, parseInfo); + checked = create(new EvaluationCache<false>(checked, var.data(), parseInfo->allocateCacheSlot()), sourceLocator, parseInfo); else if(type == VariableDeclaration::GlobalVariable) - checked = create(new EvaluationCache<true>(checked, var, parseInfo->allocateCacheSlot()), sourceLocator, parseInfo); + checked = create(new EvaluationCache<true>(checked, var.data(), parseInfo->allocateCacheSlot()), sourceLocator, parseInfo); var->setExpression(checked); @@ -1042,7 +1042,7 @@ static Expression::Ptr resolveVariable(const QXmlName &name, * mechanism must. */ case VariableDeclaration::ExpressionVariable: { - retval = create(new ExpressionVariableReference(var->slot, var), sourceLocator, parseInfo); + retval = create(new ExpressionVariableReference(var->slot, var.data()), sourceLocator, parseInfo); break; } case VariableDeclaration::FunctionArgument: @@ -1057,7 +1057,7 @@ static Expression::Ptr resolveVariable(const QXmlName &name, } case VariableDeclaration::TemplateParameter: { - retval = create(new TemplateParameterReference(var), sourceLocator, parseInfo); + retval = create(new TemplateParameterReference(var.data()), sourceLocator, parseInfo); break; } case VariableDeclaration::ExternalVariable: |