On 6/13/2008 3:16 PM, Arve Knudsen wrote:

In our C++ application we typically use smartpointers to manage
pointers automatically, but there's the problem of transferring such
objects to Python. What I'd like to do is pass smartpointers to
Python, so that one plays along with the C++ memory management scheme,
but treat these as their managed objects (i.e., not having to worry
about the presence of smartpointers). Is there a typical pattern for
accomplishing this, or should I go about it completely differently?

One idea that comes to mind is to increment the smart-pointer counter when the Python wrapper is created and decrement it when the Python wrapper is destroyed. This would allow the Python code to keep the object in life by itself, even though the Python refcount would of course be different from the C++ refcount.

I have no idea how to implement this with SIP though; maybe Phil will chime in.
--
Giovanni Bajo
Develer S.r.l.
http://www.develer.com
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to