[PyQt] Parent child relationship: child survives parent
Volker Pilipp
volker.pilipp at dectris.com
Fri Jul 12 08:30:46 BST 2013
I've got a little bit confused about ownership of objects in SIP As
far as I understand, if ParentObject owns ChildObject, the destruction
of ChildObject is left to c++ i.e. the c++ destructor of ParentObject
is expected to destruct ChildObject. This behaviour may result in a
seg fault if the python programmer does not make sure that ChildObject
goes out of scope before ParentObject does. Indeed, there are many
scenarios where this may happen accidentally.
That's what I would like to have: The ChildObject keeps a reference
on ParentObject that is released during destruction of ChildObject,
where the Python destructor of ChildObject must not call the c++
destructor of the wrapped c++ instance (this is done during
destruction of ParentObject).
I am wondering if this behavior is possible to achieve in SIP.
More information about the PyQt
mailing list