aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlvmemetaobject_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2015-11-25 15:35:38 +0100
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-11-26 19:34:37 +0000
commitdbc147b2e755edab7a8e21f60d17fd1ed03f9bd0 (patch)
tree9f1e283a9ed3ef4fe9c6efd3e100097cdd19e02b /src/qml/qml/qqmlvmemetaobject_p.h
parentdf49f17ed62df5a64345f8dcf57e164695a7366f (diff)
Make property interceptors work on alias properties again
Fixes a regression introduced by change 01c0c0963794f4dd8c3601e8340cc3dc4dec41bd, where interceptors wouldn't work correctly on alias properties. This required some refactoring and splitting out the interceptor handling from the VMEMO into it's own class, as we are now installing bindings directly on the target property of an alias and not on the alias anymore. We now resolve the target property inside the QML object creator and install a interceptor metaobject on the target if required where we can then register the interceptor. Change-Id: I3ebc8f492ce5dcab7acf901711b47336d5182ffa Task-number: QTBUG-49072 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/qml/qqmlvmemetaobject_p.h')
-rw-r--r--src/qml/qml/qqmlvmemetaobject_p.h56
1 files changed, 42 insertions, 14 deletions
diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h
index af0742d2c6..7da44e3b82 100644
--- a/src/qml/qml/qqmlvmemetaobject_p.h
+++ b/src/qml/qml/qqmlvmemetaobject_p.h
@@ -148,17 +148,57 @@ public:
int m_index;
};
+
+class Q_QML_PRIVATE_EXPORT QQmlInterceptorMetaObject : public QAbstractDynamicMetaObject
+{
+public:
+ QQmlInterceptorMetaObject(QObject *obj, QQmlPropertyCache *cache);
+ ~QQmlInterceptorMetaObject();
+
+ void registerInterceptor(int index, int valueIndex, QQmlPropertyValueInterceptor *interceptor);
+
+ static QQmlInterceptorMetaObject *get(QObject *obj);
+
+ virtual QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *o);
+
+ // Used by auto-tests for inspection
+ QQmlPropertyCache *propertyCache() const { return cache; }
+
+protected:
+ virtual int metaCall(QObject *o, QMetaObject::Call c, int id, void **a);
+ bool intercept(QMetaObject::Call c, int id, void **a);
+
+public:
+ QObject *object;
+ QQmlPropertyCache *cache;
+ QBiPointer<QDynamicMetaObjectData, const QMetaObject> parent;
+
+ QQmlPropertyValueInterceptor *interceptors;
+ bool hasAssignedMetaObjectData;
+};
+
+inline QQmlInterceptorMetaObject *QQmlInterceptorMetaObject::get(QObject *obj)
+{
+ if (obj) {
+ if (QQmlData *data = QQmlData::get(obj)) {
+ if (data->hasInterceptorMetaObject)
+ return static_cast<QQmlInterceptorMetaObject *>(QObjectPrivate::get(obj)->metaObject);
+ }
+ }
+
+ return 0;
+}
+
class QQmlVMEVariant;
class QQmlRefCount;
class QQmlVMEMetaObjectEndpoint;
-class Q_QML_PRIVATE_EXPORT QQmlVMEMetaObject : public QAbstractDynamicMetaObject
+class Q_QML_PRIVATE_EXPORT QQmlVMEMetaObject : public QQmlInterceptorMetaObject
{
public:
QQmlVMEMetaObject(QObject *obj, QQmlPropertyCache *cache, const QQmlVMEMetaData *data);
~QQmlVMEMetaObject();
bool aliasTarget(int index, QObject **target, int *coreIndex, int *valueTypeIndex) const;
- void registerInterceptor(int index, int valueIndex, QQmlPropertyValueInterceptor *interceptor);
QV4::ReturnedValue vmeMethod(int index);
quint16 vmeMethodLineNumber(int index);
void setVmeMethod(int index, const QV4::Value &function);
@@ -167,11 +207,6 @@ public:
void connectAliasSignal(int index, bool indexInSignalRange);
- virtual QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *o);
-
- // Used by auto-tests for inspection
- QQmlPropertyCache *propertyCache() const { return cache; }
-
static inline QQmlVMEMetaObject *get(QObject *o);
static QQmlVMEMetaObject *getForProperty(QObject *o, int coreIndex);
static QQmlVMEMetaObject *getForMethod(QObject *o, int coreIndex);
@@ -185,9 +220,7 @@ public:
friend class QQmlVMEVariantQObjectPtr;
friend class QQmlPropertyCache;
- QObject *object;
QQmlGuardedContextData ctxt;
- QQmlPropertyCache *cache;
const QQmlVMEMetaData *metaData;
inline int propOffset() const;
@@ -195,7 +228,6 @@ public:
inline int signalOffset() const;
inline int signalCount() const;
- bool hasAssignedMetaObjectData;
QQmlVMEMetaObjectEndpoint *aliasEndpoints;
QV4::WeakValue properties;
@@ -233,8 +265,6 @@ public:
void connectAlias(int aliasId);
- QQmlPropertyValueInterceptor *interceptors;
-
QV4::PersistentValue *methods;
QV4::ReturnedValue method(int);
@@ -243,8 +273,6 @@ public:
QVariant readPropertyAsVariant(int);
void writeProperty(int, const QVariant &);
- QBiPointer<QDynamicMetaObjectData, const QMetaObject> parent;
-
inline QQmlVMEMetaObject *parentVMEMetaObject() const;
void listChanged(int);