summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2010-03-09 12:36:24 (GMT)
committerKent Hansen <kent.hansen@nokia.com>2010-03-10 09:19:10 (GMT)
commit20e2b87b5194abf7e9f08b7c42c030a57e2d6b28 (patch)
tree11ff01db45da4874b3b92921e159945ab23290a5 /src
parenta0ec41037fcbb686dfc5c4679261bffc5e358fdd (diff)
downloadQt-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.cpp7
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);