summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-06-16 05:02:51 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-06-16 05:02:51 (GMT)
commit6bc2a137e2b9c508d86047576907956418d292aa (patch)
tree784f9cabd629b8feb4944b9781f5e00795f52793
parent1e5dd7d82d542527ca9e650f78a5e25b6a3ebc41 (diff)
downloadQt-6bc2a137e2b9c508d86047576907956418d292aa.zip
Qt-6bc2a137e2b9c508d86047576907956418d292aa.tar.gz
Qt-6bc2a137e2b9c508d86047576907956418d292aa.tar.bz2
Forward signals from extended objects
This is necessary so that notify signals on properties defined in an extension object operate correctly.
-rw-r--r--src/declarative/qml/qmlmetatype.cpp5
-rw-r--r--src/declarative/qml/qmlproxymetaobject.cpp28
-rw-r--r--src/declarative/qml/qmlproxymetaobject_p.h1
3 files changed, 31 insertions, 3 deletions
diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp
index 3e25ae0..8ce8571 100644
--- a/src/declarative/qml/qmlmetatype.cpp
+++ b/src/declarative/qml/qmlmetatype.cpp
@@ -214,9 +214,12 @@ void QmlTypePrivate::init() const
mo = mo->d.superdata;
}
- for (int ii = 0; ii < m_metaObjects.count(); ++ii)
+ for (int ii = 0; ii < m_metaObjects.count(); ++ii) {
m_metaObjects[ii].propertyOffset =
m_metaObjects.at(ii).metaObject->propertyOffset();
+ m_metaObjects[ii].methodOffset =
+ m_metaObjects.at(ii).metaObject->methodOffset();
+ }
// Calculate hash
QByteArray hashData;
diff --git a/src/declarative/qml/qmlproxymetaobject.cpp b/src/declarative/qml/qmlproxymetaobject.cpp
index 686c6d7..06d8a50 100644
--- a/src/declarative/qml/qmlproxymetaobject.cpp
+++ b/src/declarative/qml/qmlproxymetaobject.cpp
@@ -78,6 +78,7 @@ QmlProxyMetaObject::~QmlProxyMetaObject()
proxies = 0;
}
+#include <QDebug>
int QmlProxyMetaObject::metaCall(QMetaObject::Call c, int id, void **a)
{
if ((c == QMetaObject::ReadProperty ||
@@ -93,8 +94,24 @@ int QmlProxyMetaObject::metaCall(QMetaObject::Call c, int id, void **a)
sizeof(QObject *) * metaObjects->count());
}
- if (!proxies[ii])
- proxies[ii] = data.createFunc(object);
+ if (!proxies[ii]) {
+ QObject *proxy = data.createFunc(object);
+ const QMetaObject *metaObject = proxy->metaObject();
+ proxies[ii] = proxy;
+
+ int localOffset = data.metaObject->methodOffset();
+ int methodOffset = metaObject->methodOffset();
+ int methods = metaObject->methodCount() - methodOffset;
+
+ // ### - Can this be done more optimally?
+ for (int jj = 0; jj < methods; ++jj) {
+ QMetaMethod method =
+ metaObject->method(jj + methodOffset);
+ if (method.methodType() == QMetaMethod::Signal)
+ QMetaObject::connect(proxy, methodOffset + jj,
+ object, localOffset + jj);
+ }
+ }
int proxyOffset = proxies[ii]->metaObject()->propertyOffset();
int proxyId = id - data.propertyOffset + proxyOffset;
@@ -102,6 +119,13 @@ int QmlProxyMetaObject::metaCall(QMetaObject::Call c, int id, void **a)
return proxies[ii]->qt_metacall(c, proxyId, a);
}
}
+ } else if (c == QMetaObject::InvokeMetaMethod &&
+ id >= metaObjects->last().methodOffset) {
+ QMetaMethod m = object->metaObject()->method(id);
+ if (m.methodType() == QMetaMethod::Signal) {
+ QMetaObject::activate(object, id, a);
+ return -1;
+ }
}
if (parent)
diff --git a/src/declarative/qml/qmlproxymetaobject_p.h b/src/declarative/qml/qmlproxymetaobject_p.h
index 0ffa365..c0ce36e 100644
--- a/src/declarative/qml/qmlproxymetaobject_p.h
+++ b/src/declarative/qml/qmlproxymetaobject_p.h
@@ -61,6 +61,7 @@ public:
QMetaObject *metaObject;
CreateFunc createFunc;
int propertyOffset;
+ int methodOffset;
};
QmlProxyMetaObject(QObject *, QList<ProxyData> *);