[C++-sig] Extracting and returning a c++ object from python and garbage collection
William Ladwig
wladwig at wdtinc.com
Wed Aug 20 00:03:03 CEST 2008
I looked at the Py++ code and tried it out (it's similar to how I tried it originally) and it also throws a "dangling pointer" exception from the interpreter. I was able to keep it from crashing by extracting a ReqInput reference and then creating a new ReqInput by copying the extracted one. It's not very efficient unfortunately, but it might be the only way to do this. Thanks again for your help.
std::auto_ptr<ReqInput> convToReqInput()
{
object py_ob = this->get_override("toMapleInputArray")();
ReqInput& r_arr = extract<ReqInput&>(py_ob);
std::auto_ptr<ReqInput> r(new ReqInput(r_arr));
return r;
}
Bill
More information about the Cplusplus-sig
mailing list