From 20e2b87b5194abf7e9f08b7c42c030a57e2d6b28 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 9 Mar 2010 13:36:24 +0100 Subject: Use index-based approach for iterating over JS array properties Using QScriptValueIterator means that non-index properties of the array will be processed (such as "length" or "foo"), which is something we don't want. Reviewed-by: Aaron Kennedy --- src/declarative/util/qdeclarativelistmodel.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index e3f26d7..b968ca5 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -284,12 +284,11 @@ void ModelNode::setObjectValue(const QScriptValue& valuemap) { } void ModelNode::setListValue(const QScriptValue& valuelist) { - QScriptValueIterator it(valuelist); + int size = valuelist.property(QString::fromLatin1("length")).toInt32(); values.clear(); - while (it.hasNext()) { - it.next(); + for (int i = 0; i < size; ++i) { ModelNode *value = new ModelNode; - QScriptValue v = it.value(); + QScriptValue v = valuelist.property(i); if (v.isArray()) { value->isArray = true; value->setListValue(v); -- cgit v0.12