Commit 63417576 authored by Cédric Traizet's avatar Cédric Traizet

ENH: use smart pointer to manage the watcher list

parent d79bbf76
......@@ -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));
}
}
}
......@@ -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;
......
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