Renato Araujo wrote:
Hi all,
I'm trying check if have someone using my object in python, but I got
some problems I think I'm not doing this in the correct way:
First of all, I'm not sure I understand what you are trying to achieve.
Why do you want to manually delete reference-counted objects, instead of
letting Python's runtime do this ?
I have a function like that:
voi MyClass::~MyClass()
{
for(int i=0; i < childCount(); i++)
{
BaseClass *child = child_at(i);
python::object py_obj(pyhton::ptr(child)); //I can't this
without ptr because my object no have copy constructor
//Whats happen here?? ^^^
By default, the object would be passed by-value, i.e. a copy would be
made, and assigned to the python wrapper object.
python::ptr() is basically a marker to tell boost.python to copy
by-reference (by-pointer, as it stands) instead.
- How this work when the object already exists? and
whats happen when the object not exists?
In both cases, I believe a new python wrapper object is created. This,
of course, is problematic if the object is already ref-counted
elsewhere, since now you have got two reference counters, both
attempting to delete the object once they drop down to 0.
- There is a better way to verify if already have a
python object associate with my child c++ object?
I don't think there is any way to get from the wrapped object to the
wrapper, as I don't know of any place that would provide this mapping.
Regards,
Stefan
--
...ich hab' noch einen Koffer in Berlin...
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig