diff --git a/Modules/Core/Common/include/otbStandardOneLineFilterWatcher.h b/Modules/Core/Common/include/otbStandardOneLineFilterWatcher.h index 68b8173b81d77eb075361012530c5b88876a7b2a..9b49904d563a136617421067e20c6064f0471b5e 100644 --- a/Modules/Core/Common/include/otbStandardOneLineFilterWatcher.h +++ b/Modules/Core/Common/include/otbStandardOneLineFilterWatcher.h @@ -68,7 +68,7 @@ public: StandardOneLineFilterWatcher(); /** Destrucotr */ - virtual ~StandardOneLineFilterWatcher(); + virtual ~StandardOneLineFilterWatcher() =default; /** Get/Set number of stars */ void SetStars(int count) @@ -115,7 +115,7 @@ private: /** A default callback created in the constructor and deleted in the * destructor. */ - PrintCallbackType * m_DefaultCallback; + std::shared_ptr<PrintCallbackType> m_DefaultCallback; }; } // end namespace otb diff --git a/Modules/Core/Common/include/otbStandardOneLineFilterWatcher.hxx b/Modules/Core/Common/include/otbStandardOneLineFilterWatcher.hxx index 129ccefa6bf4edc5c8863d936d9085a5d9c5e6bb..db25082dceeb7ac5950bba520ca9c87a70c5e171 100644 --- a/Modules/Core/Common/include/otbStandardOneLineFilterWatcher.hxx +++ b/Modules/Core/Common/include/otbStandardOneLineFilterWatcher.hxx @@ -38,8 +38,8 @@ StandardOneLineFilterWatcher<PrintCallbackType> m_CurrentNbStars(-1), m_CoutIsConsole( System::IsInteractive(1) ) { - m_DefaultCallback = new PrintCallbackType; - m_Callback = m_DefaultCallback; + m_DefaultCallback = std::make_shared<PrintCallbackType>() ; + m_Callback = m_DefaultCallback.get(); } template<class PrintCallbackType> @@ -51,8 +51,8 @@ StandardOneLineFilterWatcher<PrintCallbackType> m_CurrentNbStars(-1), m_CoutIsConsole( System::IsInteractive(1) ) { - m_DefaultCallback = new PrintCallbackType; - m_Callback = m_DefaultCallback; + m_DefaultCallback = std::make_shared<PrintCallbackType>() ; + m_Callback = m_DefaultCallback.get(); } template<class PrintCallbackType> @@ -64,15 +64,8 @@ StandardOneLineFilterWatcher<PrintCallbackType> m_CurrentNbStars(-1), m_CoutIsConsole( System::IsInteractive(1) ) { - m_DefaultCallback = new PrintCallbackType; - m_Callback = m_DefaultCallback; -} - -template<class PrintCallbackType> -StandardOneLineFilterWatcher<PrintCallbackType> -::~StandardOneLineFilterWatcher() -{ - delete m_DefaultCallback; + m_DefaultCallback = std::make_shared<PrintCallbackType>() ; + m_Callback = m_DefaultCallback.get(); } template<class PrintCallbackType>