From f09517bd9c907698a05ee92ccf158a06db3340b8 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Wed, 8 Aug 2012 14:53:45 +1000 Subject: Ensure that copy sequences can be passed as arguments Previously, automatic conversion from JS array to sequence copy resource was not performed in the case where the array was passed as a parameter to a QObject function invocation. This commit adds code to check if the parameter type is a sequence type - and if so, and if the value is a variantlist, we convert it to a sequence of the appropriate type. Change-Id: I3cc3e2f95604bc71d1d8d237e1acffa1e03b78ba Reviewed-by: Glenn Watson --- tests/auto/qml/qqmlecmascript/testtypes.cpp | 30 ++++++----------------------- 1 file changed, 6 insertions(+), 24 deletions(-) (limited to 'tests/auto/qml/qqmlecmascript/testtypes.cpp') diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp index 9669e371de..a0bdbb6156 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.cpp +++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp @@ -225,35 +225,17 @@ public: { return stringList; } - Q_INVOKABLE QList integers(QVariant v) const + Q_INVOKABLE QList integers(QList v) const { - QList intList; - QList vList = v.toList(); - for (int i=0 ; i < vList.size() ; ++i) { - int iv = vList[i].toInt(); - intList.append(iv); - } - return intList; + return v; } - Q_INVOKABLE QList reals(QVariant v) const + Q_INVOKABLE QList reals(QList v) const { - QList realList; - QList vList = v.toList(); - for (int i=0 ; i < vList.size() ; ++i) { - qreal fv = vList[i].toReal(); - realList.append(fv); - } - return realList; + return v; } - Q_INVOKABLE QList bools(QVariant v) const + Q_INVOKABLE QList bools(QList v) const { - QList boolList; - QList vList = v.toList(); - for (int i=0 ; i < vList.size() ; ++i) { - bool bv = vList[i].toBool(); - boolList.append(bv); - } - return boolList; + return v; } }; -- cgit v1.2.3