From: Bea Lam Date: Thu, 25 Aug 2011 07:03:10 +0000 (+1000) Subject: Fix memory leak in ListModel custom parser X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=6dd1ab81e1c7943053feea321b6f7774b688ee5d;p=konrad%2Fqtdeclarative.git Fix memory leak in ListModel custom parser 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 Reviewed-by: Michael Brasser --- diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 15d87c8..da841c1 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -932,6 +932,7 @@ void QDeclarativeListModelParser::setCustomData(QObject *obj, const QByteArray & QDeclarativeListModel *rv = static_cast(obj); ModelNode *root = new ModelNode(rv->m_nested); + rv->m_nested->m_ownsRoot = true; rv->m_nested->_root = root; QStack nodes; nodes << root; diff --git a/src/qtquick1/util/qdeclarativelistmodel.cpp b/src/qtquick1/util/qdeclarativelistmodel.cpp index d5aa75b..08e15c5 100644 --- a/src/qtquick1/util/qdeclarativelistmodel.cpp +++ b/src/qtquick1/util/qdeclarativelistmodel.cpp @@ -787,6 +787,7 @@ void QDeclarative1ListModelParser::setCustomData(QObject *obj, const QByteArray QDeclarative1ListModel *rv = static_cast(obj); ModelNode *root = new ModelNode(rv->m_nested); + rv->m_nested->m_ownsRoot = true; rv->m_nested->_root = root; QStack nodes; nodes << root;