diff options
Diffstat (limited to 'sources/pyside6/libpyside/globalreceiverv2.cpp')
-rw-r--r-- | sources/pyside6/libpyside/globalreceiverv2.cpp | 73 |
1 files changed, 59 insertions, 14 deletions
diff --git a/sources/pyside6/libpyside/globalreceiverv2.cpp b/sources/pyside6/libpyside/globalreceiverv2.cpp index 8289eaff6..2c75e39e1 100644 --- a/sources/pyside6/libpyside/globalreceiverv2.cpp +++ b/sources/pyside6/libpyside/globalreceiverv2.cpp @@ -9,10 +9,11 @@ #include <autodecref.h> #include <gilstate.h> +#include <pep384ext.h> -#include <QtCore/qhashfunctions.h> #include <QtCore/QMetaMethod> #include <QtCore/QSet> +#include <QtCore/QDebug> #include <cstring> @@ -22,17 +23,9 @@ namespace PySide { -size_t qHash(const GlobalReceiverKey &k, size_t seed) -{ - QtPrivate::QHashCombine hash; - seed = hash(seed, k.object); - seed = hash(seed, k.method); - return seed; -} - class DynamicSlotDataV2 { - Q_DISABLE_COPY(DynamicSlotDataV2) + Q_DISABLE_COPY_MOVE(DynamicSlotDataV2) public: DynamicSlotDataV2(PyObject *callback, GlobalReceiverV2 *parent); ~DynamicSlotDataV2(); @@ -46,6 +39,8 @@ class DynamicSlotDataV2 static void onCallbackDestroyed(void *data); static GlobalReceiverKey key(PyObject *callback); + void formatDebug(QDebug &debug) const; + private: bool m_isMethod; PyObject *m_callback; @@ -56,6 +51,32 @@ class DynamicSlotDataV2 GlobalReceiverV2 *m_parent; }; +void DynamicSlotDataV2::formatDebug(QDebug &debug) const +{ + debug << "method=" << m_isMethod << ", m_callback=" << m_callback; + if (m_callback != nullptr) + debug << '/' << Py_TYPE(m_callback)->tp_name; + debug << ", self=" << m_pythonSelf; + if (m_pythonSelf != nullptr) + debug << '/' << Py_TYPE(m_pythonSelf)->tp_name; + debug << ", m_pyClass=" << m_pyClass; + if (m_pyClass != nullptr) + debug << '/' << Py_TYPE(m_pyClass)->tp_name; + debug << ", signatures=" << m_signatures.keys(); +} + +QDebug operator<<(QDebug debug, const DynamicSlotDataV2 *d) +{ + QDebugStateSaver saver(debug); + debug.noquote(); + debug.nospace(); + debug << "DynamicSlotDataV2("; + if (d) + d->formatDebug(debug); + else + debug << '0'; + debug << ')'; + return debug; } using namespace PySide; @@ -115,7 +136,7 @@ PyObject *DynamicSlotDataV2::callback() //create a callback based on method data if (m_isMethod) - callback = Py_TYPE(m_callback)->tp_descr_get(m_callback, m_pythonSelf, nullptr); + callback = PepExt_Type_CallDescrGet(m_callback, m_pythonSelf, nullptr); else Py_INCREF(callback); @@ -141,7 +162,7 @@ void DynamicSlotDataV2::onCallbackDestroyed(void *data) auto self = reinterpret_cast<DynamicSlotDataV2 *>(data); self->m_weakRef = nullptr; Py_BEGIN_ALLOW_THREADS - SignalManager::instance().deleteGobalReceiver(self->m_parent); + SignalManager::instance().deleteGlobalReceiver(self->m_parent); Py_END_ALLOW_THREADS } @@ -253,9 +274,8 @@ int GlobalReceiverV2::qt_metacall(QMetaObject::Call call, int id, void **args) if (setSenderDynamicProperty) m_receiver->setProperty(senderDynamicProperty, QVariant::fromValue(sender())); - const bool isShortCuit = std::strchr(slot.methodSignature(), '(') == nullptr; Shiboken::AutoDecRef callback(m_data->callback()); - SignalManager::callPythonMetaMethod(slot, args, callback, isShortCuit); + SignalManager::callPythonMetaMethod(slot, args, callback); if (setSenderDynamicProperty) m_receiver->setProperty(senderDynamicProperty, QVariant{}); @@ -275,3 +295,28 @@ int GlobalReceiverV2::qt_metacall(QMetaObject::Call call, int id, void **args) return -1; } + +void GlobalReceiverV2::formatDebug(QDebug &debug) const +{ + debug << "receiver=" << m_receiver << ", slot=" << m_data; + if (isEmpty()) + debug << ", empty"; + else + debug << ", refs=" << m_refs; +}; + +QDebug operator<<(QDebug debug, const GlobalReceiverV2 *g) +{ + QDebugStateSaver saver(debug); + debug.noquote(); + debug.nospace(); + debug << "GlobalReceiverV2("; + if (g) + g->formatDebug(debug); + else + debug << '0'; + debug << ')'; + return debug; +} + +} // namespace PySide |