Renato Araujo wrote:
Thanks for your points, I will try explain my problem better:

In my library I have a parent->child control then when the parent is
deleted all children is deleted too.

but in python I would like change this behavior, if there is some
python object using my child I will not delete this object.

I see. What if your parent held its children via shared_ptr<> objects ? If you then export the child's type with shared_ptr<> as HeldType, i.e.

class_<BaseClass, shared_ptr<BaseClass>, ...>

you should get what you want, since now all the communication across the language boundary is using shared_ptr<>, and the ref counts are correctly shared. With that, when the Python wrapper itself gets deleted by the Python runtime, it will decrement the shared_ptr<> counter you passed it. As your parents do the same, they can happily coexist with python references to the same objects.

HTH,
      Stefan

--

     ...ich hab' noch einen Koffer in Berlin...

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to