From 2620ddc6d39c8e339ae28ce2bf3e1611e31f06cb Mon Sep 17 00:00:00 2001 From: spo Date: Wed, 25 May 2016 10:47:08 +0300 Subject: [PATCH] Fix memory leak with shared_ptr in HighModelAPI and ConstructionAPI --- src/ConstructionAPI/ConstructionAPI.i | 4 ++++ src/ModelHighAPI/ModelHighAPI.i | 9 +++++++-- src/ModelHighAPI/ModelHighAPI_swig.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ConstructionAPI/ConstructionAPI.i b/src/ConstructionAPI/ConstructionAPI.i index 5d9a79484..ed3c2172a 100644 --- a/src/ConstructionAPI/ConstructionAPI.i +++ b/src/ConstructionAPI/ConstructionAPI.i @@ -12,6 +12,10 @@ // standard definitions %include "typemaps.i" +%include "std_shared_ptr.i" + +// shared pointers +%shared_ptr(ConstructionAPI_Point) // all supported interfaces %include "ConstructionAPI_Point.h" diff --git a/src/ModelHighAPI/ModelHighAPI.i b/src/ModelHighAPI/ModelHighAPI.i index 413ba1a94..5c6369cb5 100644 --- a/src/ModelHighAPI/ModelHighAPI.i +++ b/src/ModelHighAPI/ModelHighAPI.i @@ -10,9 +10,10 @@ // standard definitions %include "typemaps.i" %include "std_string.i" +%include "std_shared_ptr.i" -// all supported interfaces -%include "ModelHighAPI_Double.h" +// shared pointers +%shared_ptr(ModelHighAPI_Interface) // typemaps %typemap(in) const ModelHighAPI_Double & (ModelHighAPI_Double temp) { @@ -32,3 +33,7 @@ %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Double, const ModelHighAPI_Double & { $1 = (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input) || PyString_Check($input)) ? 1 : 0; } + +// all supported interfaces +%include "ModelHighAPI_Double.h" +%include "ModelHighAPI_Interface.h" diff --git a/src/ModelHighAPI/ModelHighAPI_swig.h b/src/ModelHighAPI/ModelHighAPI_swig.h index f5a8471c9..d4cf88b65 100644 --- a/src/ModelHighAPI/ModelHighAPI_swig.h +++ b/src/ModelHighAPI/ModelHighAPI_swig.h @@ -11,5 +11,6 @@ #include "ModelHighAPI.h" #include "ModelHighAPI_Double.h" + #include "ModelHighAPI_Interface.h" #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_SWIG_H_ */ -- 2.39.2