Fixed segmentation fault libpyside's signalUpdateSource function.
This function is called when an object is instantiated, and it will go through the class attributes looking for signals and what else is relevant. If the user has set a new attribute in the constructor before the call to its parent QObject-like __init__ method, a segmentation fault would ensue. This commit fixes this condition and also adds an unit test. Reviewed by Hugo Parente <hugo.lima@openbossa.org> Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
This commit is contained in:
parent
16579322f1
commit
dedc78b3fe
3 changed files with 31 additions and 1 deletions
|
|
@ -225,7 +225,7 @@ void signalUpdateSource(PyObject* source)
|
|||
for(int i = 0, iMax = PyList_GET_SIZE(attrs.object()); i < iMax; ++i) {
|
||||
PyObject *attrName = PyList_GET_ITEM(attrs.object(), i);
|
||||
Shiboken::AutoDecRef attr(PyObject_GetAttr(reinterpret_cast<PyObject*>(source->ob_type), attrName));
|
||||
if (attr->ob_type == &Signal_Type) {
|
||||
if (!attr.isNull() && attr->ob_type == &Signal_Type) {
|
||||
Shiboken::AutoDecRef signalInstance((PyObject*)PyObject_New(SignalInstanceData, &SignalInstance_Type));
|
||||
signal_instance_initialize(signalInstance, attrName, reinterpret_cast<SignalData*>(attr.object()), source, 0);
|
||||
PyObject_SetAttr(source, attrName, signalInstance);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue