diff options
Diffstat (limited to 'sources/pyside6/libpyside')
-rw-r--r-- | sources/pyside6/libpyside/pysideqslotobject_p.cpp | 34 | ||||
-rw-r--r-- | sources/pyside6/libpyside/pysideqslotobject_p.h | 22 | ||||
-rw-r--r-- | sources/pyside6/libpyside/qobjectconnect.cpp | 6 |
3 files changed, 39 insertions, 23 deletions
diff --git a/sources/pyside6/libpyside/pysideqslotobject_p.cpp b/sources/pyside6/libpyside/pysideqslotobject_p.cpp index 914be898a..40b011fcf 100644 --- a/sources/pyside6/libpyside/pysideqslotobject_p.cpp +++ b/sources/pyside6/libpyside/pysideqslotobject_p.cpp @@ -2,28 +2,46 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "pysideqslotobject_p.h" +#include "signalmanager.h" -#include <autodecref.h> #include <gilstate.h> namespace PySide { +PySideQSlotObject::PySideQSlotObject(PyObject *callable, + const QByteArrayList ¶meterTypes, + const char *returnType) : + QtPrivate::QSlotObjectBase(&impl), + m_callable(callable), + m_parameterTypes(parameterTypes), + m_returnType(returnType) +{ + Py_INCREF(callable); +} + +PySideQSlotObject::~PySideQSlotObject() +{ + Shiboken::GilState state; + Py_DECREF(m_callable); +} + +void PySideQSlotObject::call(void **args) +{ + SignalManager::callPythonMetaMethod(m_parameterTypes, m_returnType, args, m_callable); +} + void PySideQSlotObject::impl(int which, QSlotObjectBase *this_, QObject *receiver, void **args, bool *ret) { - auto self = static_cast<PySideQSlotObject *>(this_); + auto *self = static_cast<PySideQSlotObject *>(this_); switch (which) { case Destroy: delete self; break; case Call: - { - Shiboken::GilState state; - Shiboken::AutoDecRef arglist(PyTuple_New(0)); - Shiboken::AutoDecRef ret(PyObject_CallObject(self->callable, arglist)); - break; - } + self->call(args); + break; case Compare: case NumOperations: Q_UNUSED(receiver); diff --git a/sources/pyside6/libpyside/pysideqslotobject_p.h b/sources/pyside6/libpyside/pysideqslotobject_p.h index d7d258505..827f0193c 100644 --- a/sources/pyside6/libpyside/pysideqslotobject_p.h +++ b/sources/pyside6/libpyside/pysideqslotobject_p.h @@ -15,22 +15,18 @@ namespace PySide class PySideQSlotObject : public QtPrivate::QSlotObjectBase { - PyObject *callable; +public: + explicit PySideQSlotObject(PyObject *callable, const QByteArrayList ¶meterTypes, + const char *returnType = nullptr); + ~PySideQSlotObject(); +private: static void impl(int which, QSlotObjectBase *this_, QObject *receiver, void **args, bool *ret); + void call(void **args); -public: - PySideQSlotObject(PyObject *callable) : QtPrivate::QSlotObjectBase(&impl), callable(callable) - { - Py_INCREF(callable); - } - - ~PySideQSlotObject() - { - auto gstate = PyGILState_Ensure(); - Py_DECREF(callable); - PyGILState_Release(gstate); - } + PyObject *m_callable; + const QByteArrayList m_parameterTypes; + const char *m_returnType; }; diff --git a/sources/pyside6/libpyside/qobjectconnect.cpp b/sources/pyside6/libpyside/qobjectconnect.cpp index d0a1a2c50..e27827ce4 100644 --- a/sources/pyside6/libpyside/qobjectconnect.cpp +++ b/sources/pyside6/libpyside/qobjectconnect.cpp @@ -282,7 +282,10 @@ QMetaObject::Connection qobjectConnectCallback(QObject *source, const char *sign PySide::SignalManager &signalManager = PySide::SignalManager::instance(); - auto *slotObject = new PySideQSlotObject(callback); + const QMetaMethod signalMethod = source->metaObject()->method(signalIndex); + auto *slotObject = new PySideQSlotObject(callback, + signalMethod.parameterTypes(), + signalMethod.typeName()); QMetaObject::Connection connection{}; Py_BEGIN_ALLOW_THREADS // PYSIDE-2367, prevent threading deadlocks with connectNotify() @@ -298,7 +301,6 @@ QMetaObject::Connection qobjectConnectCallback(QObject *source, const char *sign if (receiver.usingGlobalReceiver) signalManager.notifyGlobalReceiver(receiver.receiver); - const QMetaMethod signalMethod = source->metaObject()->method(signalIndex); static_cast<FriendlyQObject *>(source)->connectNotify(signalMethod); return connection; } |