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

BUG: use smart pointer to manage the default callback

parent 31f81c07
......@@ -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
......
......@@ -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>
......
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