I'm dealing with the problem of C++ reference counting again, so I want to come up with a solution to this problem once and for all. Does anyone have a good pattern for wrapping C++ smartpointers with SIP?
Thanks, Arve On Fri, Jun 13, 2008 at 3:33 PM, Giovanni Bajo <[EMAIL PROTECTED]> wrote: > 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 [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
