[C++-sig] Fwd: Contructor with "with_custodian_and_ward_postcall"

Renato Araujo renatox at gmail.com
Mon Nov 3 20:15:16 CET 2008


Sorry my last message I sent incomplete :)


I will try again.

First I have a c++ class like this:

struct object
{
     object(object *parent=0)  // if parent !=NULL append this at
parent children list
     ~object() //Destroy all children
};


Is possible implement this using "python::with_custodian_and_ward_postcall"?
I tried some like that:

 qclass_<object_wrapper, boost::noncopyable > ("object", python::init<> ())
   //here i put self will be the ward and arg 2 (parent) will be the
custodian
   //the lifetime of the self will be dependent on the lifetime of the parent
   .def(python::init<object*>()[python::with_custodian_and_ward_postcall<2,1>()])


But in my python code I tried some like that:

o = object()
o2 = object(o)

del o

and this produce this exception during the del operation:
*** glibc detected *** python: free(): invalid pointer: 0x09c89970 ***


More information about the Cplusplus-sig mailing list