[PyQt] Re: SIP bug with object lifetime

Phil Thompson phil at riverbankcomputing.co.uk
Sun May 20 15:20:18 BST 2007

On Friday 18 May 2007 7:08 pm, Giovanni Bajo wrote:
> On 5/14/2007 7:10 PM, Giovanni Bajo wrote:
> >>>>>> If the new /Transfer/ function annotation were to be applied to
> >>>>>> viewport() then a gc association would be established between
> >>>>>> viewport
> >>>>>> and ql with the ql Python object having a reference to the viewport
> >>>>>> Python object. This would prevent viewport (and also o) from being
> >>>>>> garbage collected until ql was.
> >>>>>
> >>>>> What about queryList()/findChildren()? In my original code, the
> >>>>> C++-allocated instance was accessed through a queryList() call. It's
> >>>>> basically the same (getting a reference to a C++ instance never seen
> >>>>> before by Python), but I guess the annotation won't be enough...
> >>>
> >>> You didn't answer this: is the annotation going to work also for the
> >>> queryList() / findChildren() case?
> >>
> >> It would work if it was applied - but I haven't applied it to PyQt4.
> >> I've applied it to those methods that are known to return an
> >> internally generated instance.
> >
> > findChildren() might or might not return an internally generated
> > instance, depending... on the instance. I guess that needs to be handled
> > in hand-generated code, right?
> Sorry for being dense, but I still don't understand what I should do for
> code that accesses C++-generated objects through findChildren() and add
> attributes to them.

This should all work in tonight's PyQt4 snapshot. I needed to convince myself 
that SIP would do the right thing.


More information about the PyQt mailing list