[PyQt] Re: SIP bug with object lifetime

Giovanni Bajo rasky at develer.com
Mon May 14 17:30:10 BST 2007


On 5/14/2007 1:14 PM, Phil Thompson 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?

>> I wonder: can't you just apply it automatically to all cases where you
>> create a wrapper for an already existing C++ object that was never
>> wrapped before? How can't that be wrong?
> 
> Because you would be making the (possibly incorrect) assumption that the new 
> one was a child of self.

What about asking for its parent, then? And if the parent is not wrapped 
in Python, creating a wrapper for it and asking again for its parent 
(etc. etc.)?
-- 
Giovanni Bajo



More information about the PyQt mailing list