aboutsummaryrefslogtreecommitdiffstats
path: root/libpyside
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-06-28 11:39:04 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:54:30 -0300
commitb385e0c3edd0d9e99665cebbd8ee37055594d838 (patch)
tree1966b631eafd5de7ccf3bf266f0d0318a6394817 /libpyside
parent0d0981309edf7cf067d7485e89a2ce3993389604 (diff)
Fixed propagation of properties for user-defined types.
Fixes bug #897. Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'libpyside')
-rw-r--r--libpyside/pysideproperty.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/libpyside/pysideproperty.cpp b/libpyside/pysideproperty.cpp
index 5f11d36d8..b1cb19c4e 100644
--- a/libpyside/pysideproperty.cpp
+++ b/libpyside/pysideproperty.cpp
@@ -136,6 +136,7 @@ static void qpropertyMetaCall(PySideProperty* pp, PyObject* self, QMetaObject::C
}
}
+
static PyObject* qpropertyTpNew(PyTypeObject* subtype, PyObject* args, PyObject* kwds)
{
PySideProperty* me = reinterpret_cast<PySideProperty*>(subtype->tp_alloc(subtype, 0));
@@ -193,6 +194,27 @@ void qpropertyFree(void *self)
} // extern "C"
+namespace {
+
+static PyObject* getFromType(PyTypeObject* type, PyObject* name)
+{
+ PyObject* attr = 0;
+ attr = PyDict_GetItem(type->tp_dict, name);
+ if (!attr) {
+ PyObject* bases = type->tp_bases;
+ int size = PyTuple_GET_SIZE(bases);
+ for(int i=0; i < size; i++) {
+ PyObject* base = PyTuple_GET_ITEM(bases, i);
+ attr = getFromType(reinterpret_cast<PyTypeObject*>(base), name);
+ if (attr)
+ return attr;
+ }
+ }
+ return attr;
+}
+
+} //namespace
+
namespace PySide { namespace Property {
@@ -275,9 +297,7 @@ PySideProperty* getObject(PyObject* source, PyObject* name)
attr = PyDict_GetItem(dict, name);
}
- if (!attr)
- attr = PyDict_GetItem(source->ob_type->tp_dict, name);
-
+ attr = getFromType(source->ob_type, name);
if (attr && isPropertyType(attr)) {
Py_INCREF(attr);
return reinterpret_cast<PySideProperty*>(attr);