diff --git a/Modules/Wrappers/SWIG/src/otbPythonLogOutput.i b/Modules/Wrappers/SWIG/src/otbPythonLogOutput.i index 34b0f99214225898d7c53447cb0503b6f6c60bdd..2dac6aa7c889ffd1488783f101365c6bf169c158 100644 --- a/Modules/Wrappers/SWIG/src/otbPythonLogOutput.i +++ b/Modules/Wrappers/SWIG/src/otbPythonLogOutput.i @@ -85,6 +85,7 @@ public: static ProgressReporterManager_Pointer New(); virtual void Delete(); + void DeleteWatcherList(); void SetLogOutputCallback(otb::LogOutputCallback* callback); itkCommand* GetAddProcessCommand(); diff --git a/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.cxx b/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.cxx index 89ea154a4387642a86e318c21506a5105e6db651..0e231beefdd83c44f521a7deedd209f4f35915ec 100644 --- a/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.cxx +++ b/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.cxx @@ -31,6 +31,21 @@ ProgressReporterManager::ProgressReporterManager() m_AddProcessCommand->SetCallbackFunction(this, &ProgressReporterManager::LinkWatchers); } +ProgressReporterManager::~ProgressReporterManager() +{ + this->DeleteWatcherList(); +} + +void ProgressReporterManager::DeleteWatcherList() +{ + //Delete all stored progress reporter + for (auto watcher: m_WatcherList) + { + delete watcher; + } + m_WatcherList.clear(); +} + void ProgressReporterManager::LinkWatchers(itk::Object* itkNotUsed(caller), const itk::EventObject& event) { if (typeid(otb::Wrapper::AddProcessToWatchEvent) == typeid(event)) diff --git a/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.h b/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.h index e1aaf0d1f86398b94b1440d3fbc4ae1055a8bdfe..4900aed18b732d04757be31fe0fede1b51a5afc7 100644 --- a/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.h +++ b/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.h @@ -70,12 +70,15 @@ public: return m_AddProcessCommand.GetPointer(); } + /** Delete all watchers */ + void DeleteWatcherList(); + protected: /** Default constructor */ ProgressReporterManager(); /** Destructor. */ - virtual ~ProgressReporterManager() = default; + virtual ~ProgressReporterManager(); /** Load the watchers for internal progress and writing progress report. */ void LinkWatchers(itk::Object* caller, const itk::EventObject& event);