diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-03-25 05:49:27 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-03-29 02:13:34 (GMT) |
commit | 067d5e0dc318e767a817bdb2bf6f0f647cf49909 (patch) | |
tree | 5480733337f260eeeb6836c26bac195b8cafeb87 /src/declarative/util/qdeclarativelistmodel.cpp | |
parent | 418bd7fa550da97ac27a34c72e75ec7ab0448d78 (diff) | |
download | Qt-067d5e0dc318e767a817bdb2bf6f0f647cf49909.zip Qt-067d5e0dc318e767a817bdb2bf6f0f647cf49909.tar.gz Qt-067d5e0dc318e767a817bdb2bf6f0f647cf49909.tar.bz2 |
Fix memory leak and clean up deletion.
Diffstat (limited to 'src/declarative/util/qdeclarativelistmodel.cpp')
-rw-r--r-- | src/declarative/util/qdeclarativelistmodel.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 3904458..1a28176 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -1250,14 +1250,9 @@ ModelNode::ModelNode() ModelNode::~ModelNode() { - ModelNode *node; - - QList<ModelNode *> nodeValues = properties.values(); - for (int ii = 0; ii < nodeValues.count(); ++ii) { - node = nodeValues[ii]; - if (node) { delete node; node = 0; } - } + qDeleteAll(properties.values()); + ModelNode *node; for (int ii = 0; ii < values.count(); ++ii) { node = qvariant_cast<ModelNode *>(values.at(ii)); if (node) { delete node; node = 0; } @@ -1279,7 +1274,9 @@ void ModelNode::setObjectValue(const QScriptValue& valuemap) { } else { value->values << v.toVariant(); } - properties.insert(it.name(),value); + if (properties.contains(it.name())) + delete properties[it.name()]; + properties.insert(it.name(), value); } } |