diff --git a/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.cxx b/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.cxx index e3a6ac541739b337fea15b1597a186b559031042..ff53453bbeac70dbf42b17a5d8c091bbe0d1e55c 100644 --- a/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.cxx +++ b/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.cxx @@ -38,11 +38,6 @@ ProgressReporterManager::~ProgressReporterManager() void ProgressReporterManager::DeleteWatcherList() { - //Delete all stored progress reporter - for (auto watcher: m_WatcherList) - { - delete watcher; - } m_WatcherList.clear(); } @@ -52,9 +47,9 @@ void ProgressReporterManager::LinkWatchers(itk::Object* itkNotUsed(caller), cons { const Wrapper::AddProcessToWatchEvent* eventToWatch = dynamic_cast<const Wrapper::AddProcessToWatchEvent*>(&event); - auto watch = new WatcherType(eventToWatch->GetProcess(), eventToWatch->GetProcessDescription()); + auto watch = std::make_unique< WatcherType>(eventToWatch->GetProcess(), eventToWatch->GetProcessDescription()); watch->SetCallback(m_Callback); - m_WatcherList.push_back(watch); + m_WatcherList.push_back(std::move(watch)); } } } diff --git a/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.h b/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.h index ec15926fd20ad0b91ac238f0fbc1b7e61b0e4c1b..59d0cafd26b5ad962290553f9f2d9d013dd5cbad 100644 --- a/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.h +++ b/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.h @@ -27,6 +27,8 @@ #include "otbSwigPrintCallback.h" #include "otbStandardOneLineFilterWatcher.h" +#include <memory> + namespace otb { @@ -54,7 +56,7 @@ public: typedef StandardOneLineFilterWatcher<CallbackType> WatcherType; /** Filter watcher list type */ - typedef std::vector<WatcherType *> WatcherListType; + typedef std::vector<std::unique_ptr <WatcherType> > WatcherListType; /** Command Member */ typedef itk::MemberCommand<Self> AddProcessCommandType;