From 83f06bf7d0f5b6f32bbb652973f11b6eb60cd2ba Mon Sep 17 00:00:00 2001 From: Hugo Lima Date: Mon, 29 Mar 2010 17:08:27 -0300 Subject: 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. --- libshiboken/basewrapper.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'libshiboken/basewrapper.cpp') 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)); -- cgit v1.2.3