diff options
| author | Christian Tismer <tismer@stackless.com> | 2021-12-21 18:31:53 +0100 |
|---|---|---|
| committer | Christian Tismer <tismer@stackless.com> | 2021-12-23 06:56:06 +0100 |
| commit | 17ff0bc4c5fed1ecd2191be90b5e5f2161160879 (patch) | |
| tree | 1b1a3db4b9452ee4dddbf8b0ca482c30770830a6 /sources/pyside6/libpyside/pysidesignal.cpp | |
| parent | 73bf0e9732cf4945bdd7158d04d29779da55a29b (diff) | |
signal: Fix a segfault when signal is applied to non-QObject
When a signal is created on a normal Python type, this
should be recognized on initialization and rejected.
Instead, this creates a segfault.
[ChangeLog][PySide6] A crash when inserting a signal
into a non-QObject was fixed.
Pick-to: 6.2
Task-number: PYSIDE-229
Task-number: PYSIDE-1675
Change-Id: I7fe1d5482ddfbf09ec1e4708c47693f2ce47c744
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside6/libpyside/pysidesignal.cpp')
| -rw-r--r-- | sources/pyside6/libpyside/pysidesignal.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sources/pyside6/libpyside/pysidesignal.cpp b/sources/pyside6/libpyside/pysidesignal.cpp index 85e976789..a30ea35f8 100644 --- a/sources/pyside6/libpyside/pysidesignal.cpp +++ b/sources/pyside6/libpyside/pysidesignal.cpp @@ -823,8 +823,6 @@ QByteArray getTypeName(PyObject *obType) return QByteArrayLiteral("QString"); if (type == &PyLong_Type) return QByteArrayLiteral("int"); - if (type == &PyLong_Type) - return QByteArrayLiteral("long"); if (type == &PyFloat_Type) return QByteArrayLiteral("double"); if (type == &PyBool_Type) @@ -902,6 +900,15 @@ static void instanceInitialize(PySideSignalInstance *self, PyObject *name, PySid PySideSignalInstance *initialize(PySideSignal *self, PyObject *name, PyObject *object) { + static PyTypeObject *pyQObjectType = Shiboken::Conversions::getPythonTypeObject("QObject*"); + assert(pyQObjectType); + + if (!PyObject_TypeCheck(object, pyQObjectType)) { + PyErr_Format(PyExc_TypeError, "%s cannot be converted to %s", + Py_TYPE(object)->tp_name, pyQObjectType->tp_name); + return nullptr; + } + PySideSignalInstance *instance = PyObject_New(PySideSignalInstance, PySideSignalInstanceTypeF()); instanceInitialize(instance, name, self, object, 0); |
