aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/libpyside/pysideslot.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside2/libpyside/pysideslot.cpp')
-rw-r--r--sources/pyside2/libpyside/pysideslot.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/sources/pyside2/libpyside/pysideslot.cpp b/sources/pyside2/libpyside/pysideslot.cpp
index 204253aa2..1ec24ab21 100644
--- a/sources/pyside2/libpyside/pysideslot.cpp
+++ b/sources/pyside2/libpyside/pysideslot.cpp
@@ -47,6 +47,8 @@
#include <QtCore/QString>
#include <signature.h>
+using namespace Shiboken;
+
struct SlotData
{
QByteArray name;
@@ -71,11 +73,11 @@ static PyType_Slot PySideSlotType_slots[] = {
{Py_tp_call, (void *)slotCall},
{Py_tp_init, (void *)slotTpInit},
{Py_tp_new, (void *)PyType_GenericNew},
- {Py_tp_dealloc, (void *)object_dealloc},
+ {Py_tp_dealloc, (void *)Sbk_object_dealloc},
{0, 0}
};
static PyType_Spec PySideSlotType_spec = {
- "PySide2.QtCore.Slot",
+ "2:PySide2.QtCore.Slot",
sizeof(PySideSlot),
0,
Py_TPFLAGS_DEFAULT,
@@ -85,9 +87,8 @@ static PyType_Spec PySideSlotType_spec = {
static PyTypeObject *PySideSlotTypeF(void)
{
- static PyTypeObject *type = nullptr;
- if (!type)
- type = (PyTypeObject *)PyType_FromSpec(&PySideSlotType_spec);
+ static PyTypeObject *type = reinterpret_cast<PyTypeObject *>(
+ SbkType_FromSpec(&PySideSlotType_spec));
return type;
}
@@ -137,23 +138,25 @@ PyObject *slotCall(PyObject *self, PyObject *args, PyObject * /* kw */)
callback = PyTuple_GetItem(args, 0);
Py_INCREF(callback);
- if (PyFunction_Check(callback)) {
+ if (Py_TYPE(callback)->tp_call != nullptr) {
PySideSlot *data = reinterpret_cast<PySideSlot *>(self);
if (!data->slotData)
data->slotData = new SlotData;
- if (data->slotData->name.isEmpty())
- data->slotData->name = Shiboken::String::toCString(PepFunction_GetName(callback));
-
+ if (data->slotData->name.isEmpty()) {
+ // PYSIDE-198: Use PyObject_GetAttr instead of PepFunction_GetName to support Nuitka.
+ AutoDecRef funcName(PyObject_GetAttr(callback, PyMagicName::name()));
+ data->slotData->name = String::toCString(funcName);
+ }
const QByteArray returnType = QMetaObject::normalizedType(data->slotData->resultType);
const QByteArray signature =
returnType + ' ' + data->slotData->name + '(' + data->slotData->args + ')';
if (!pySlotName)
- pySlotName = Shiboken::String::fromCString(PYSIDE_SLOT_LIST_ATTR);
+ pySlotName = String::fromCString(PYSIDE_SLOT_LIST_ATTR);
- PyObject *pySignature = Shiboken::String::fromCString(signature);
+ PyObject *pySignature = String::fromCString(signature);
PyObject *signatureList = 0;
if (PyObject_HasAttr(callback, pySlotName)) {
signatureList = PyObject_GetAttr(callback, pySlotName);
@@ -185,7 +188,7 @@ static const char *Slot_SignatureStrings[] = {
void init(PyObject *module)
{
- if (SbkSpecial_Type_Ready(module, PySideSlotTypeF(), Slot_SignatureStrings) < 0)
+ if (InitSignatureStrings(PySideSlotTypeF(), Slot_SignatureStrings) < 0)
return;
Py_INCREF(PySideSlotTypeF());