diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-05-06 09:57:07 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-05-11 16:25:16 +0200 |
commit | d0c7c7234cb7629fbe7a04944cb5191414cc72b9 (patch) | |
tree | 3daa6be55dcf9d59d72d1dac83d113aa9c9a7556 /src/qml/qml/qqmlvmemetaobject.cpp | |
parent | 83a2e8c101e738d3f3c7810f681b3f0bec4014ee (diff) |
Generalize role selection mechanism from QQuickComboBox
We can have QQmlDelegateModel pick specific roles from model items. That
can easily be done for variant maps, variant hashes, objects and
gadgets. We would like to do it for anything that has a
QMetaAssociation, but as we cannot get to the original type at that
place, it's currently not possible.
The special case about variant maps with exactly one item in variant
lists is clearly insane and therefore not included in the
generalization.
This requires some cleanup in the QQmlGadgetPointerWrapper. Passing the
wrapper itself to QMetaProperty::read() has always been a rather obscure
way of reading from the gadget.
Pick-to: 6.3
Fixes: QTBUG-102983
Change-Id: I84ecef980783e7137aa4d77070ddce47b6ead260
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlvmemetaobject.cpp')
-rw-r--r-- | src/qml/qml/qqmlvmemetaobject.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index dbcb0005d0..cd847903e4 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -359,15 +359,15 @@ bool QQmlInterceptorMetaObject::doIntercept(QMetaObject::Call c, int id, void ** QVariant newValue(metaType, a[0]); valueType->read(object, id); - QVariant prevComponentValue = valueProp.read(valueType); + QVariant prevComponentValue = valueType->readOnGadget(valueProp); valueType->setValue(newValue); - QVariant newComponentValue = valueProp.read(valueType); + QVariant newComponentValue = valueType->readOnGadget(valueProp); // Don't apply the interceptor if the intercepted value has not changed bool updated = false; if (newComponentValue != prevComponentValue) { - valueProp.write(valueType, prevComponentValue); + valueType->writeOnGadget(valueProp, prevComponentValue); valueType->write(object, id, QQmlPropertyData::DontRemoveBinding | QQmlPropertyData::BypassInterceptor); vi->write(newComponentValue); |