Boost logo

Boost Users :

Subject: Re: [Boost-users] [python] Ownership of python objects.
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2009-09-24 17:23:47


On Wed, Sep 23, 2009 at 4:54 AM, Germán Diago <germandiago_at_[hidden]> wrote:
> Hello. I'm trying to do the following thing:
>
> 1.- Create an object
> 2.- Put it in an scene (for a game)
> 3.- To be able to delete it from the scene (this is done from C++)
>
> My problem is that if I do the following:
>
> p = Object("blabla")
> Scene.addToScene("myobject", p)
>
> //Here, the object is deleted by C++, which is causing problems
> p.removeFromScene("myobject")
>
>
> I know a workaround for this. It would be to make a wrapper for
> objects created from python
> and not deleting the object if it was created from there.
>
> But I would like if there is some other (more general) way to avoid
> this. Thanks in advance.

If you are using Boost.Python, it contains policies for defining which
side owns which and how some things are linked to other things, use
those and it will handle all that properly.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net