From d1d08a134d2b22b91150a70a1ec23f576bb38398 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 2 Oct 2018 15:28:19 +0200 Subject: libpyside: Port DynamicQMetaObject to QMetaObjectBuilder Qt 5 introduces a new class QMetaObjectBuilder for generating dynamic meta objects for use cases like QML. It provides an API to add methods, properties and info and a factory method toMetaObject() to obtain a QMetaObject snapshot reflecting the changes. Replace the DynamicQMetaObject aggregated by TypeUserData by a class MetaObjectBuilder wrapping a QMetaObjectBuilder with dirty-handling. The code to create the binary data of the QMetaObject can then be removed. For plain Qt objects, the wrapped base meta object will be returned (which fixes the bug). Task-number: PYSIDE-784 Change-Id: Id8a54570aff36c75fe0f3bf2d297a12d02cd773a Reviewed-by: Alexandru Croitor --- sources/pyside2/libpyside/globalreceiverv2.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'sources/pyside2/libpyside/globalreceiverv2.cpp') diff --git a/sources/pyside2/libpyside/globalreceiverv2.cpp b/sources/pyside2/libpyside/globalreceiverv2.cpp index a1a695759..43ce50a75 100644 --- a/sources/pyside2/libpyside/globalreceiverv2.cpp +++ b/sources/pyside2/libpyside/globalreceiverv2.cpp @@ -160,10 +160,8 @@ int DynamicSlotDataV2::id(const char* signature) const int DynamicSlotDataV2::addSlot(const char* signature) { int index = id(signature); - if (index == -1) { - DynamicQMetaObject *dmo = const_cast(reinterpret_cast(m_parent->metaObject())); - index = m_signatures[signature] = dmo->addSlot(signature); - } + if (index == -1) + index = m_signatures[signature] = m_parent->metaObjectBuilder().addSlot(signature); return index; } @@ -202,7 +200,7 @@ GlobalReceiverV2::GlobalReceiverV2(PyObject *callback, SharedMap map) : DESTROY_SIGNAL_ID = QObject::staticMetaObject.indexOfSignal("destroyed(QObject*)"); if (DESTROY_SLOT_ID == 0) - DESTROY_SLOT_ID = m_metaObject.indexOfSlot(RECEIVER_DESTROYED_SLOT_NAME); + DESTROY_SLOT_ID = m_metaObject.indexOfMethod(QMetaMethod::Slot, RECEIVER_DESTROYED_SLOT_NAME); } @@ -306,7 +304,7 @@ QByteArray GlobalReceiverV2::hash(PyObject* callback) const QMetaObject* GlobalReceiverV2::metaObject() const { - return m_metaObject.update(); + return const_cast(this)->m_metaObject.update(); } int GlobalReceiverV2::qt_metacall(QMetaObject::Call call, int id, void** args) -- cgit v1.2.3