diff options
author | Robert Griebl <robert.griebl@pelagicore.com> | 2015-01-08 15:48:28 +0100 |
---|---|---|
committer | Robert Griebl <robert.griebl@pelagicore.com> | 2015-01-08 15:59:44 +0100 |
commit | e9398ba4e7512ae53e617dcb3a3577c14b43fe7d (patch) | |
tree | 4abb7d3d0160cfe6bef085449714b8554ff3d88d | |
parent | a03c5699af133272daad5303956768893e6695bf (diff) | |
download | qtquick1-e9398ba4e7512ae53e617dcb3a3577c14b43fe7d.tar.gz |
Fix empty arrays in QML 1
Commit 9cbb6fa added a regression, where empty arrays would produce errors
in QML 1.
Change-Id: Ie5c784d5ec921d1ca69084750ed37fc2e273bbef
Task-number: QTBUG-43656
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r-- | src/declarative/qml/qdeclarativeengine.cpp | 2 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 682c8267..14f3c95c 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -2125,6 +2125,8 @@ QVariant QDeclarativeEnginePrivate::scriptValueToVariant(const QScriptValue &val if (val.isArray()) { int length = val.property(QLatin1String("length")).toInt32(); + if (!length) + containsQObjects = true; for (int ii = 0; ii < length; ++ii) { if (val.property(ii).isQObject()) { containsQObjects = true; diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 9eef4c74..779c1d2e 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -438,6 +438,12 @@ void tst_qdeclarativeecmascript::arrayExpressions() QCOMPARE(list2.at(1), QVariant(2)); QCOMPARE(list2.at(2), QVariant(QString("foo"))); QCOMPARE(list2.at(3), QVariant(QString("bar"))); + + MyExpression expr3(&context, "[]"); + result = expr3.evaluate(); + QCOMPARE(result.userType(), qMetaTypeId<QList<QObject *> >()); + QList<QObject *> list3 = qvariant_cast<QList<QObject *> >(result); + QCOMPARE(list3.count(), 0); } // Tests that modifying a context property will reevaluate expressions |