Merge branch 'master-fix-vector-shared_ptr'
* master-fix-vector-shared_ptr: fixing memleak of shared_ptr objects in python with creating a [wrapped] vector<shared_ptr<Foo>> from a list of shared_ptr<Bar> where Bar is derived from Foo.
This commit is contained in:
commit
339d427910
1 changed files with 16 additions and 6 deletions
|
|
@ -45,13 +45,23 @@ namespace swig {
|
||||||
template <class Type>
|
template <class Type>
|
||||||
struct traits_asptr {
|
struct traits_asptr {
|
||||||
static int asptr(PyObject *obj, Type **val) {
|
static int asptr(PyObject *obj, Type **val) {
|
||||||
Type *p = 0;
|
if (val) {
|
||||||
swig_type_info *descriptor = type_info<Type>();
|
Type *p = 0;
|
||||||
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
|
swig_type_info *descriptor = type_info<Type>();
|
||||||
if (SWIG_IsOK(res)) {
|
int newmem = 0;
|
||||||
if (val) *val = p;
|
int res = descriptor ? SWIG_ConvertPtrAndOwn(obj, (void **)&p, descriptor, 0, &newmem) : SWIG_ERROR;
|
||||||
|
if (SWIG_IsOK(res)) {
|
||||||
|
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||||
|
res |= SWIG_NEWOBJMASK;
|
||||||
|
}
|
||||||
|
*val = p;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
} else {
|
||||||
|
swig_type_info *descriptor = type_info<Type>();
|
||||||
|
int res = descriptor ? SWIG_ConvertPtr(obj, 0, descriptor, 0) : SWIG_ERROR;
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue