summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-03-25 05:49:27 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-03-29 02:13:34 (GMT)
commit067d5e0dc318e767a817bdb2bf6f0f647cf49909 (patch)
tree5480733337f260eeeb6836c26bac195b8cafeb87 /src
parent418bd7fa550da97ac27a34c72e75ec7ab0448d78 (diff)
downloadQt-067d5e0dc318e767a817bdb2bf6f0f647cf49909.zip
Qt-067d5e0dc318e767a817bdb2bf6f0f647cf49909.tar.gz
Qt-067d5e0dc318e767a817bdb2bf6f0f647cf49909.tar.bz2
Fix memory leak and clean up deletion.
Diffstat (limited to 'src')
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp13
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);
}
}