From f22ae0f5f18a354bf3addd8023ad8b8810e42bac Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Tue, 2 Aug 2011 15:41:22 +1000 Subject: [PATCH] Fix some memory leaks in the compiler Task-number: QTBUG-17770 Change-Id: I6d9d357bf529a9a3f414182fb6a818ddedda8e18 Reviewed-on: http://codereview.qt.nokia.com/2487 Reviewed-by: Qt Sanity Bot Reviewed-by: Michael Brasser --- src/declarative/qml/qdeclarativebinding.cpp | 2 ++ src/declarative/qml/qdeclarativeexpression.cpp | 2 ++ .../declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp index d817990..9a69a6b 100644 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ b/src/declarative/qml/qdeclarativebinding.cpp @@ -243,6 +243,8 @@ QDeclarativeBinding::createBinding(Identifier id, QObject *obj, QDeclarativeCont cdata = typeData->compiledData(); } QDeclarativeBinding *rv = cdata ? new QDeclarativeBinding(cdata->primitives.at(id), true, obj, ctxtdata, url, lineNumber, parent) : 0; + if (cdata) + cdata->release(); if (typeData) typeData->release(); return rv; diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp index a24d469..4f6a719 100644 --- a/src/declarative/qml/qdeclarativeexpression.cpp +++ b/src/declarative/qml/qdeclarativeexpression.cpp @@ -256,6 +256,8 @@ QDeclarativeExpression::QDeclarativeExpression(const QDeclarativeScriptString &s else defaultConstruction = true; + if (cdata) + cdata->release(); if (typeData) typeData->release(); } diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index ba1aaca..d04b38b 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -688,6 +688,8 @@ void tst_qdeclarativeecmascript::attachedProperties() QCOMPARE(object->property("b").toInt(), 26); QCOMPARE(object->property("c").toInt(), 26); QCOMPARE(object->property("d").toInt(), 26); + + delete object; } { -- 2.7.4