Commit 2ff20938 authored by Burlen Loring's avatar Burlen Loring

fix memory leaks of SENSEI classes wrapped by SWIG to Python

* Added delobject driective and newfree typemap for wrapped classes.
* Exposed the base class memory management methods in wrapped language.
* Make sure that class names include namespace, otherwise SWIG gets
  confused.
* removed some debugging code from the newton mini-app
parent 7acae1db
......@@ -414,9 +414,3 @@ if __name__ == '__main__':
# finish up
adaptor.finalize()
status('run complete\n')
del ic
ic = None
del adaptor
adaptor = None
del comm
comm = None
......@@ -53,8 +53,17 @@ VTK classes defined in your project.
%{
#include <derived_t##.h>
%}
%feature("ref") derived_t "$this->Register(nullptr);"
%feature("unref") derived_t "$this->UnRegister(nullptr);"
%newobject derived_t##::New();
%feature("ref") sensei::##derived_t "$this->Register(nullptr);"
%feature("unref") sensei::##derived_t "$this->UnRegister(nullptr);"
%newobject sensei::##derived_t##::New();
%delobject sensei::##derived_t##::Delete();
%typemap(newfree) sensei::##derived_t* "$1->UnRegister(nullptr);"
%include <derived_t##.h>
%extend sensei::##derived_t
{
void Register(vtkObjectBase *obj){ $self->vtkObjectBase::Register(obj); }
void UnRegister(vtkObjectBase *obj){ $self->vtkObjectBase::UnRegister(obj); }
void Delete(){ $self->vtkObjectBase::Delete(); }
int GetReferenceCount(){ return $self->vtkObjectBase::GetReferenceCount(); }
}
%enddef
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment