aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-06-17 13:47:24 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2013-06-17 13:52:24 +0200
commitb7731f69f1e8c1410f860f74481222b4b3752505 (patch)
tree09145305cc69a8add34b3be154dd0c8e4a76d7f1
parent3436b58928b52c1cef643202969159324b8f0850 (diff)
Fix the remaining test failures in the jsonbinding autotest
Skip properties that are function objects when converting a V4 Object to a QJsonObject. For arrays the function object gets replaced with null. Fix the test case for arrays to have the correct expected output. Change-Id: I3ee63935d038e0922e33ac6e64e9c31ecfbd4a7e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r--src/qml/qml/v4/qv4jsonobject.cpp5
-rw-r--r--tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp2
2 files changed, 4 insertions, 3 deletions
diff --git a/src/qml/qml/v4/qv4jsonobject.cpp b/src/qml/qml/v4/qv4jsonobject.cpp
index 1d83a0d2e5..34f4809fd2 100644
--- a/src/qml/qml/v4/qv4jsonobject.cpp
+++ b/src/qml/qml/v4/qv4jsonobject.cpp
@@ -992,7 +992,8 @@ QJsonObject JsonObject::toJsonObject(QV4::Object *o, V4ObjectSet &visitedObjects
break;
QString key = name.toQString();
- result.insert(key, toJsonValue(v, visitedObjects));
+ if (!v.asFunctionObject())
+ result.insert(key, toJsonValue(v, visitedObjects));
}
visitedObjects.remove(o);
@@ -1030,7 +1031,7 @@ QJsonArray JsonObject::toJsonArray(ArrayObject *a, V4ObjectSet &visitedObjects)
quint32 length = a->arrayLength();
for (quint32 i = 0; i < length; ++i) {
Value v = a->getIndexed(i);
- result.append(toJsonValue(v, visitedObjects));
+ result.append(toJsonValue(v.asFunctionObject() ? QV4::Value::nullValue() : v, visitedObjects));
}
visitedObjects.remove(a);
diff --git a/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp b/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp
index e6b056fbd0..aaeecb9fc9 100644
--- a/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp
+++ b/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp
@@ -428,7 +428,7 @@ void tst_qjsonbinding::writeProperty_javascriptExpression_data()
QTest::newRow("object = object with function property")
<< "object" << "{ foo: function() {} }" << "{}";
QTest::newRow("array = array with function property")
- << "array" << "[function() {}]" << "[]";
+ << "array" << "[function() {}]" << "[null]";
// Inherited properties should not be included.
QTest::newRow("value = object with inherited property")