diff options
author | Thomas Hartmann <thomas.hartmann@qt.io> | 2024-03-20 11:33:37 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2024-03-22 18:11:41 +0100 |
commit | c7995e6aa3643e5da76ae32ce1e1166fd6f81b0e (patch) | |
tree | 4554adad51fe8cb635e0acdef44602cd70d1ccf2 /src/qml/qml | |
parent | 4a660da8d33beaec91286dca2affb012420bf84b (diff) |
QQmlGadgetPtrWrapper: Consider QVariant as possible type
If the type is QVariant, we have to store and retrieve the member as-is,
instead of wrapping and unwrapping it.
Pick-to: 6.7
Fixes: QTBUG-123484
Change-Id: I01ac33158236b0f1082744aafa86108225b68392
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/qqmlvaluetype.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/qml/qml/qqmlvaluetype.cpp b/src/qml/qml/qqmlvaluetype.cpp index 428ce9b697..4088d6e6c4 100644 --- a/src/qml/qml/qqmlvaluetype.cpp +++ b/src/qml/qml/qqmlvaluetype.cpp @@ -55,16 +55,25 @@ void QQmlGadgetPtrWrapper::write( QVariant QQmlGadgetPtrWrapper::value() const { Q_ASSERT(m_gadgetPtr); - return QVariant(metaType(), m_gadgetPtr); + + const QMetaType m = metaType(); + return m == QMetaType::fromType<QVariant>() + ? *static_cast<const QVariant *>(m_gadgetPtr) + : QVariant(m, m_gadgetPtr); } void QQmlGadgetPtrWrapper::setValue(const QVariant &value) { Q_ASSERT(m_gadgetPtr); - Q_ASSERT(metaType() == value.metaType()); - const QQmlValueType *type = valueType(); - type->destruct(m_gadgetPtr); - type->construct(m_gadgetPtr, value.constData()); + + const QMetaType m = metaType(); + m.destruct(m_gadgetPtr); + if (m == QMetaType::fromType<QVariant>()) { + m.construct(m_gadgetPtr, &value); + } else { + Q_ASSERT(m == value.metaType()); + m.construct(m_gadgetPtr, value.constData()); + } } int QQmlGadgetPtrWrapper::metaCall(QMetaObject::Call type, int id, void **argv) |