aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4runtime.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-06-26 11:06:22 +0200
committerUlf Hermann <ulf.hermann@qt.io>2023-06-26 20:43:02 +0200
commitcae23efe45ee92b41b7899a28d4d1d7d1048584d (patch)
tree81d6dc6ace29644073457b76aaffa96ff0f0b628 /src/qml/jsruntime/qv4runtime.cpp
parent9eb6240ebd0b7f52ec49aba757a8c355b25203e0 (diff)
QML: Use new coerce() method also for 'as' casts
Casting via QVariant is unreliable and inefficient. toVariant() is not required to produce the type we are requesting. Amends commit 05f56d7c78754855c643470ad4e8dfd35c96f927. Change-Id: Idabcac7420155649692ec589d637dd9ee3016716 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4runtime.cpp')
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 500d1ae0ba..be5de62243 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -381,12 +381,8 @@ QV4::ReturnedValue Runtime::As::call(ExecutionEngine *engine, const Value &lval,
return Encode::null();
// Try to convert the value type
- if (Scoped<QQmlTypeWrapper> typeWrapper(scope, rval); typeWrapper) {
- const QMetaType metaType = typeWrapper->d()->type().typeId();
- const QVariant result = engine->toVariant(lval, metaType);
- if (result.metaType() == metaType)
- return engine->metaTypeToJS(metaType, result.constData());
- }
+ if (Scoped<QQmlTypeWrapper> typeWrapper(scope, rval); typeWrapper)
+ return coerce(engine, lval, typeWrapper->d()->type(), false);
return Encode::undefined();
}