aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4qobjectwrapper.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-03-24 15:36:37 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2021-03-25 21:25:28 +0100
commitd009c0088bac6da4d775345a60e33fee22af22ce (patch)
treece420925f16f6fea77f9b6ee5e47e81b86011e4c /src/qml/jsruntime/qv4qobjectwrapper.cpp
parent3ce1ee554b7c9cb9200a88071cb2d9e45dda90c0 (diff)
QV4::Engine::toVariant: Use metatype instead of metatype id
This way, we can avoid the costly id to metatype lookup in case where we actually need the full metatype. Task-number: QTBUG-88766 Change-Id: Ibe29b323007f00d2f8d1807fb9b64f9a8f87e807 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4qobjectwrapper.cpp')
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index 25d92596c9..4fb5851e42 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -617,9 +617,9 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, QQmlP
} else {
QVariant v;
if (property->isQList())
- v = scope.engine->toVariant(value, qMetaTypeId<QList<QObject *> >());
+ v = scope.engine->toVariant(value, QMetaType::fromType<QList<QObject *> >());
else
- v = scope.engine->toVariant(value, propType);
+ v = scope.engine->toVariant(value, property->propType());
QQmlRefPointer<QQmlContextData> callingQmlContext = scope.engine->callingQmlContext();
if (!QQmlPropertyPrivate::write(object, *property, v, callingQmlContext)) {
@@ -1524,7 +1524,7 @@ static int MatchScore(const QV4::Value &actual, QMetaType conversionMetaType)
if (obj->as<QV4::VariantObject>()) {
if (conversionType == qMetaTypeId<QVariant>())
return 0;
- if (obj->engine()->toVariant(actual, -1).metaType() == conversionMetaType)
+ if (obj->engine()->toVariant(actual, QMetaType {}).metaType() == conversionMetaType)
return 0;
else
return 10;
@@ -1547,7 +1547,7 @@ static int MatchScore(const QV4::Value &actual, QMetaType conversionMetaType)
}
if (obj->as<QV4::QQmlValueTypeWrapper>()) {
- const QVariant v = obj->engine()->toVariant(actual, -1);
+ const QVariant v = obj->engine()->toVariant(actual, QMetaType {});
if (v.userType() == conversionType)
return 0;
else if (v.canConvert(conversionMetaType))
@@ -1895,7 +1895,7 @@ bool CallArgument::fromValue(QMetaType metaType, QV4::ExecutionEngine *engine, c
else if (!value.isNull() && !value.isUndefined()) // null and undefined are nullptr
return false;
} else if (callType == qMetaTypeId<QVariant>()) {
- qvariantPtr = new (&allocData) QVariant(scope.engine->toVariant(value, -1));
+ qvariantPtr = new (&allocData) QVariant(scope.engine->toVariant(value, QMetaType {}));
type = callType;
} else if (callType == qMetaTypeId<QList<QObject*> >()) {
qlistPtr = new (&allocData) QList<QObject *>();
@@ -1986,7 +1986,7 @@ bool CallArgument::fromValue(QMetaType metaType, QV4::ExecutionEngine *engine, c
type = -1;
QQmlEnginePrivate *ep = engine->qmlEngine() ? QQmlEnginePrivate::get(engine->qmlEngine()) : nullptr;
- QVariant v = scope.engine->toVariant(value, callType);
+ QVariant v = scope.engine->toVariant(value, metaType);
const QMetaType callMetaType(callType);
if (v.metaType() == callMetaType) {