[PyQt] Smartpointer to Python

Phil Thompson phil at riverbankcomputing.com
Mon May 26 13:37:43 BST 2008


On Monday 26 May 2008 1:10:11 pm Arve Knudsen wrote:
> Hi
>
> Reading the SIP documentation I can't find any info on how C++ objects
> are deleted (returned to the heap) from Python, only that their
> destructor is called.

...when the Python object is garbage collected and if the C++ object is owned 
by Python.

> Does this mean that when returning new'ed 
> pointers  to Python they should be managed by smartpointers? If so, is
> there any mechanism in SIP for treating smartpointers as objects of
> their managed type from Python?

SIP effectively implements its own smartpointer mechanism - so long as the C++ 
type has a virtual dtor and the C++ object is created from Python.

Phil


More information about the PyQt mailing list