aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlvmemetaobject.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-02-09 10:25:05 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2021-05-04 22:07:06 +0200
commita0d74b122a06f97fde95c1cc6974c83c3d6996b8 (patch)
treeb85e39e40ad5e26247913cf91d34e24badb42ed0 /src/qml/qml/qqmlvmemetaobject.cpp
parentc04cec25c31917b4373db833cca079e39c7d036c (diff)
QQmlPropertyValueInterceptor: Add binding interception support
With the new property system, it is not enough to only intercept writes; we also need the ability to intercept calls to the bindable interface. This is done by adding a new bindable virtual method QQmlPropertyValueInterceptor. The default implementation does not do any interception at all for now. This allows us to keep the existing interceptors for now, and to port them step by step. Once all interceptors in Qt are ported, we can make the method in the interface pure virtual. Task-number: QTBUG-90999 Change-Id: I697658a1cd9a5204805a444e0d949213ba71b91c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlvmemetaobject.cpp')
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index 7e6e4b1ef3..e7248b038a 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -312,8 +312,9 @@ int QQmlInterceptorMetaObject::metaCall(QObject *o, QMetaObject::Call c, int id,
bool QQmlInterceptorMetaObject::intercept(QMetaObject::Call c, int id, void **a)
{
- if (c == QMetaObject::WriteProperty && interceptors &&
- !(*reinterpret_cast<int*>(a[3]) & QQmlPropertyData::BypassInterceptor)) {
+ if ( ( (c == QMetaObject::WriteProperty &&
+ !(*reinterpret_cast<int*>(a[3]) & QQmlPropertyData::BypassInterceptor)) || c == QMetaObject::BindableProperty )
+ && interceptors ) {
for (QQmlPropertyValueInterceptor *vi = interceptors; vi; vi = vi->m_next) {
if (vi->m_propertyIndex.coreIndex() != id)
@@ -324,7 +325,8 @@ bool QQmlInterceptorMetaObject::intercept(QMetaObject::Call c, int id, void **a)
const QMetaType metaType = data->propertyCache->property(id)->propType();
if (metaType.isValid()) {
- if (valueIndex != -1) {
+ if (valueIndex != -1 && c == QMetaObject::WriteProperty) {
+ // TODO: handle intercepting bindable properties for value types?
QQmlGadgetPtrWrapper *valueType = QQmlGadgetPtrWrapper::instance(
data->context->engine(), metaType);
Q_ASSERT(valueType);
@@ -381,9 +383,13 @@ bool QQmlInterceptorMetaObject::intercept(QMetaObject::Call c, int id, void **a)
if (updated)
return true;
- } else {
+ } else if (c == QMetaObject::WriteProperty) {
vi->write(QVariant(metaType, a[0]));
return true;
+ } else {
+ object->qt_metacall(c, id, a);
+ QUntypedBindable target = *reinterpret_cast<QUntypedBindable *>(a[0]);
+ return vi->bindable(reinterpret_cast<QUntypedBindable *>(a[0]), target);
}
}
}