From c4addf7d0e91cd39b636a88772ae9543f11e2c8c Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 7 Jun 2021 15:28:54 +0200 Subject: Pass QMetaType by value rather than by ID in more places This saves us some ping-pong between the IDs and the QMetaTypes, and avoids possible ambiguities if multiple metatypes are registered for the same C++ type. Change-Id: I81cec94a9cd05d69927dc884f65574f0ab2ddc22 Reviewed-by: Maximilian Goldstein Reviewed-by: Fabian Kosmale --- src/qml/jsruntime/qv4sequenceobject.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/qml/jsruntime/qv4sequenceobject.cpp') diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 0523d740fb..e7063b05a4 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -605,7 +605,9 @@ ReturnedValue SequencePrototype::method_sort(const FunctionObject *b, const Valu return o.asReturnedValue(); } -ReturnedValue SequencePrototype::newSequence(QV4::ExecutionEngine *engine, int sequenceType, QObject *object, int propertyIndex, bool readOnly, bool *succeeded) +ReturnedValue SequencePrototype::newSequence( + QV4::ExecutionEngine *engine, QMetaType sequenceType, QObject *object, + int propertyIndex, bool readOnly, bool *succeeded) { QV4::Scope scope(engine); // This function is called when the property is a QObject Q_PROPERTY of @@ -613,9 +615,7 @@ ReturnedValue SequencePrototype::newSequence(QV4::ExecutionEngine *engine, int s // (as well as object ptr + property index for updated-read and write-back) // and so access/mutate avoids variant conversion. - - const QQmlType qmlType = QQmlMetaType::qmlType( - sequenceType, QQmlMetaType::TypeIdCategory::MetaType); + const QQmlType qmlType = QQmlMetaType::qmlType(sequenceType); if (qmlType.isSequentialContainer()) { *succeeded = true; QV4::ScopedObject obj(scope, engine->memoryManager->allocate( @@ -633,8 +633,7 @@ ReturnedValue SequencePrototype::fromVariant( return fromData(engine, v.metaType(), v.constData(), succeeded); } -ReturnedValue SequencePrototype::fromData( - ExecutionEngine *engine, const QMetaType &type, const void *data, bool *succeeded) +ReturnedValue SequencePrototype::fromData(ExecutionEngine *engine, QMetaType type, const void *data, bool *succeeded) { QV4::Scope scope(engine); // This function is called when assigning a sequence value to a normal JS var @@ -642,8 +641,7 @@ ReturnedValue SequencePrototype::fromData( // Access and mutation is extremely fast since it will not need to modify any // QObject property. - const QQmlType qmlType = QQmlMetaType::qmlType( - type.id(), QQmlMetaType::TypeIdCategory::MetaType); + const QQmlType qmlType = QQmlMetaType::qmlType(type); if (qmlType.isSequentialContainer()) { *succeeded = true; QV4::ScopedObject obj(scope, engine->memoryManager->allocate(qmlType, data)); @@ -660,7 +658,7 @@ QVariant SequencePrototype::toVariant(Object *object) return object->as()->toVariant(); } -QVariant SequencePrototype::toVariant(const QV4::Value &array, int typeHint, bool *succeeded) +QVariant SequencePrototype::toVariant(const QV4::Value &array, QMetaType typeHint, bool *succeeded) { *succeeded = true; @@ -671,7 +669,7 @@ QVariant SequencePrototype::toVariant(const QV4::Value &array, int typeHint, boo QV4::Scope scope(array.as()->engine()); QV4::ScopedArrayObject a(scope, array); - const QQmlType type = QQmlMetaType::qmlType(typeHint, QQmlMetaType::TypeIdCategory::MetaType); + const QQmlType type = QQmlMetaType::qmlType(typeHint); if (type.isSequentialContainer()) { const QMetaSequence *meta = type.priv()->extraData.ld; const QMetaType containerMetaType(type.priv()->typeId); -- cgit v1.2.1