aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Lima <hugo.lima@openbossa.org>2010-03-29 17:08:27 -0300
committerHugo Lima <hugo.lima@openbossa.org>2010-03-30 17:41:34 -0300
commit83f06bf7d0f5b6f32bbb652973f11b6eb60cd2ba (patch)
tree722fd3894b0c89bb830ddc1329d37a5e5859bdfe
parent669a4c45eb61d769bc46c976e2b0c50aed25e80e (diff)
On setParent, when the child is a sequence, do not always call setParent for all elements.
Only do it if the sequence is a native Python sequence.
-rw-r--r--libshiboken/basewrapper.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp
index f780db3ca..0d55ede18 100644
--- a/libshiboken/basewrapper.cpp
+++ b/libshiboken/basewrapper.cpp
@@ -58,8 +58,15 @@ void setParent(PyObject* parent, PyObject* child)
if (!child || child == Py_None || child == parent)
return;
- //Recursive for sequence protocol
- if (PySequence_Check(child)) {
+ /*
+ * setParent is recursive when the child is a native Python sequence, i.e. objects not binded by Shiboken
+ * like tuple and list.
+ *
+ * This "limitation" exists to fix the following problem: A class multiple inherits QObject and QString,
+ * so if you pass this class to someone that takes the ownership, we CAN'T enter in this if, but hey! QString
+ * follows the sequence protocol.
+ */
+ if (PySequence_Check(child) && !isShibokenType(child)) {
Shiboken::AutoDecRef seq(PySequence_Fast(child, 0));
for (int i = 0, max = PySequence_Size(seq); i < max; ++i)
setParent(parent, PySequence_Fast_GET_ITEM(seq.object(), i));