diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2010-03-09 12:36:24 (GMT) |
---|---|---|
committer | Kent Hansen <kent.hansen@nokia.com> | 2010-03-10 09:19:10 (GMT) |
commit | 20e2b87b5194abf7e9f08b7c42c030a57e2d6b28 (patch) | |
tree | 11ff01db45da4874b3b92921e159945ab23290a5 /src | |
parent | a0ec41037fcbb686dfc5c4679261bffc5e358fdd (diff) | |
download | Qt-20e2b87b5194abf7e9f08b7c42c030a57e2d6b28.zip Qt-20e2b87b5194abf7e9f08b7c42c030a57e2d6b28.tar.gz Qt-20e2b87b5194abf7e9f08b7c42c030a57e2d6b28.tar.bz2 |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/util/qdeclarativelistmodel.cpp | 7 |
1 files 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); |