[PyKDE] Re: Internal Pointers again... Was: Model indexes and internal pointers

Phil Thompson phil at riverbankcomputing.co.uk
Wed Sep 20 08:28:34 BST 2006


> Phil Thompson wrote:
>>> In my case I have wrappers around a scene graph (a tree structure for
>>> computer graphics).  Anytime I call through to C++ and ask the tree
>>> nodes for children or parents, I get a python wrapper back.  This
>>> wrapper is referencing a ref-counted class on the C++ side, but it is
>>> unique as far as python is concerned.  So when I put this into
>>> internalPointer to retrieve later it immediately goes out of scope in
>>> python and is invalid when I try to reference it later.
>>>
>>> If there is any way to make this work I think it would greatly improve
>>> PyQT.
>>
>> It isn't technically possible - unless somebody has a bright idea.
>
> PyQt can return new wrapper every time but all of them pointing to the
> same C++ object, can it?

Not at the moment, but SIP could be changed to make this an option for
specific classes. However, I don't see how it helps - when the C++ object
disappears the Python object won't know and will crash when referencing
it.

Phil




More information about the PyQt mailing list