Fix memory leak in ListModel custom parser
authorBea Lam <bea.lam@nokia.com>
Thu, 25 Aug 2011 07:03:10 +0000 (17:03 +1000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 25 Aug 2011 22:37:45 +0000 (00:37 +0200)
ModelNodes created by the parser for ListElement definitions were not
deleted.

(cherry picked from commit c1491c356f3cca92a359468ce37f38bc1873eec4)

Task-number: QTBUG-21084
Change-Id: Ic55a054bb8e30cdabd11080e4f827df5deb1a014
Reviewed-on: http://codereview.qt.nokia.com/3567
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>

src/declarative/util/qdeclarativelistmodel.cpp
src/qtquick1/util/qdeclarativelistmodel.cpp

index 15d87c8..da841c1 100644 (file)
@@ -932,6 +932,7 @@ void QDeclarativeListModelParser::setCustomData(QObject *obj, const QByteArray &
     QDeclarativeListModel *rv = static_cast<QDeclarativeListModel *>(obj);
 
     ModelNode *root = new ModelNode(rv->m_nested);
+    rv->m_nested->m_ownsRoot = true;
     rv->m_nested->_root = root;
     QStack<ModelNode *> nodes;
     nodes << root;
index d5aa75b..08e15c5 100644 (file)
@@ -787,6 +787,7 @@ void QDeclarative1ListModelParser::setCustomData(QObject *obj, const QByteArray
     QDeclarative1ListModel *rv = static_cast<QDeclarative1ListModel *>(obj);
 
     ModelNode *root = new ModelNode(rv->m_nested);
+    rv->m_nested->m_ownsRoot = true;
     rv->m_nested->_root = root;
     QStack<ModelNode *> nodes;
     nodes << root;