summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-06-05 14:48:52 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-06-05 14:56:53 (GMT)
commit9691523b796c6acc6a837a5f5a34fef16aa74c48 (patch)
tree355174d4b7fa66aeac721caa01d98ca3616768cf /src
parentff9497f82d605688453e2f027bab7c719048f0d2 (diff)
downloadQt-9691523b796c6acc6a837a5f5a34fef16aa74c48.zip
Qt-9691523b796c6acc6a837a5f5a34fef16aa74c48.tar.gz
Qt-9691523b796c6acc6a837a5f5a34fef16aa74c48.tar.bz2
have QScriptValue::toVariant() convert Array objects to QVariantLists
Converting the array to its string representation is not very useful. Now round-trip conversion will work as well. Reviewed-by: Ariya Hidayat
Diffstat (limited to 'src')
-rw-r--r--src/script/qscriptvalue.cpp1
-rw-r--r--src/script/qscriptvalueimpl.cpp2
2 files changed, 3 insertions, 0 deletions
diff --git a/src/script/qscriptvalue.cpp b/src/script/qscriptvalue.cpp
index a253985..f72d1db 100644
--- a/src/script/qscriptvalue.cpp
+++ b/src/script/qscriptvalue.cpp
@@ -904,6 +904,7 @@ qsreal QScriptValue::toInteger() const
\row \o QObject Object \o A QVariant containing a pointer to the QObject.
\row \o Date Object \o A QVariant containing the date value (toDateTime()).
\row \o RegExp Object \o A QVariant containing the regular expression value (toRegExp()).
+ \row \o Array Object \o The array is converted to a QVariantList.
\row \o Object \o If the value is primitive, then the result is converted to a QVariant according to the above rules; otherwise, an invalid QVariant is returned.
\endtable
diff --git a/src/script/qscriptvalueimpl.cpp b/src/script/qscriptvalueimpl.cpp
index a890839..7c7b711 100644
--- a/src/script/qscriptvalueimpl.cpp
+++ b/src/script/qscriptvalueimpl.cpp
@@ -339,6 +339,8 @@ QVariant QScriptValueImpl::toVariant() const
if (isQObject())
return qVariantFromValue(toQObject());
#endif
+ if (isArray())
+ return QScriptEnginePrivate::variantListFromArray(*this);
QScriptValueImpl v = engine()->toPrimitive(*this);
if (!v.isObject())