aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4engine.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-05-06 14:07:29 +0200
committerUlf Hermann <ulf.hermann@qt.io>2022-05-09 11:59:49 +0200
commit2bed3d5f0ff7de2774e8e4a1ea164063e8d5aa0c (patch)
tree6da9d09ce93b5fefec89ef12125d2437b7dbc324 /src/qml/jsruntime/qv4engine.cpp
parent4770ace5e45977d117fee987cc5c7d07beb5c28a (diff)
V4 Engine: Don't try to convert JS functions to other types
When converting a JS value to a variant, if we notice that we get a QJSValue again, there is no point in trying to convert it further. We'll just run into infinite recursion. Pick-to: 6.3 Fixes: QTBUG-102545 Change-Id: I0a40e21287e5460e5e214101aabe8d2b4bf0afad Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4engine.cpp')
-rw-r--r--src/qml/jsruntime/qv4engine.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index c8e0828f18..6ace973124 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -168,7 +168,10 @@ ReturnedValue throwTypeError(const FunctionObject *b, const QV4::Value *, const
template <typename ReturnType>
ReturnType convertJSValueToVariantType(const QJSValue &value)
{
- return value.toVariant().value<ReturnType>();
+ const QVariant variant = value.toVariant();
+ return variant.metaType() == QMetaType::fromType<QJSValue>()
+ ? ReturnType()
+ : variant.value<ReturnType>();
}
struct JSArrayIterator {