Phil Thompson wrote:
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.

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.

Right, that can't prevent referencing disappeared C++ object.
However as I understand OP problem, he got Python wrapper goes out of scope while he is keeping C++ ref to it.

My (not mine actually, see boost.python return_internal_reference policy) is to keep C++ object and keep C++ ref to this obj in client prog. SIP will generate a new wrapper obj referencing same C++ obj, so when wrapper goes out of scope it's destroyed but not the C++ object it wraps.

/m

_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

Reply via email to