diff options
author | Renato Filho <renato.filho@openbossa.org> | 2011-07-11 18:55:54 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:54:35 -0300 |
commit | dc5ef0b998fefddf873304b54b13c34d874e0740 (patch) | |
tree | fae65282f8398c66c33dad64e924167c64c78f4a /libpyside | |
parent | ae0e33ff72bc8ff4394370edcbb6d608b01a5d7f (diff) |
Increment reference for functions used on QtCore.Property.
Fix bug #899.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Hugo Parente Lima <hugo.pl@gmail.com>
Diffstat (limited to 'libpyside')
-rw-r--r-- | libpyside/pysideproperty.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/libpyside/pysideproperty.cpp b/libpyside/pysideproperty.cpp index b1cb19c4e..b3f517836 100644 --- a/libpyside/pysideproperty.cpp +++ b/libpyside/pysideproperty.cpp @@ -169,6 +169,7 @@ int qpropertyTpInit(PyObject* self, PyObject* args, PyObject* kwds) return 0; } + pData->typeName = PySide::Signal::getTypeName(type); if (!pData->typeName) @@ -176,17 +177,38 @@ int qpropertyTpInit(PyObject* self, PyObject* args, PyObject* kwds) else if (pData->constant && (pData->fset || pData->notify)) PyErr_SetString(PyExc_TypeError, "A constant property cannot have a WRITE method or a NOTIFY signal."); - return PyErr_Occurred() ? -1 : 1; + if (!PyErr_Occurred()) { + Py_XINCREF(pData->fget); + Py_XINCREF(pData->fset); + Py_XINCREF(pData->freset); + Py_XINCREF(pData->fdel); + Py_XINCREF(pData->notify); + return 1; + } else { + pData->fget = 0; + pData->fset = 0; + pData->freset = 0; + pData->fdel = 0; + pData->notify = 0; + return -1; + } } void qpropertyFree(void *self) { PyObject *pySelf = reinterpret_cast<PyObject*>(self); PySideProperty *data = reinterpret_cast<PySideProperty*>(self); + PySidePropertyPrivate* pData = data->d; + + Py_XDECREF(pData->fget); + Py_XDECREF(pData->fset); + Py_XDECREF(pData->freset); + Py_XDECREF(pData->fdel); + Py_XDECREF(pData->notify); - free(data->d->typeName); - free(data->d->doc); - free(data->d->notifySignature); + free(pData->typeName); + free(pData->doc); + free(pData->notifySignature); delete data->d; pySelf->ob_type->tp_base->tp_free(self); } |