diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-06-07 15:28:54 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-06-09 14:47:13 +0200 |
commit | c4addf7d0e91cd39b636a88772ae9543f11e2c8c (patch) | |
tree | a82c384a019573365ab357767972d5344abed495 /src/qml/jsruntime/qv4sequenceobject.cpp | |
parent | e5383a5d5dd02afdbe94b380394fd88d8320e35a (diff) | |
download | qtdeclarative-c4addf7d0e91cd39b636a88772ae9543f11e2c8c.tar.gz |
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 <max.goldstein@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4sequenceobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4sequenceobject.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
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<QV4Sequence>( @@ -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<QV4Sequence>(qmlType, data)); @@ -660,7 +658,7 @@ QVariant SequencePrototype::toVariant(Object *object) return object->as<QV4Sequence>()->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<Object>()->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); |