diff --git a/Code/Common/otbFilterWatcherBase.cxx b/Code/Common/otbFilterWatcherBase.cxx index 742eb90d370ac5ece85d2ae495e7a9e3a5bf48ca..c3950d302ae7aa32a2b8199df7d83dab8ab7f66a 100644 --- a/Code/Common/otbFilterWatcherBase.cxx +++ b/Code/Common/otbFilterWatcherBase.cxx @@ -25,20 +25,27 @@ namespace otb FilterWatcherBase ::FilterWatcherBase() +: m_Comment("Not watching an object"), + m_Process(0), + m_StartTag(0), + m_EndTag(0), + m_ProgressTag(0), + m_Started(false), + m_Ended(false) { - // Initialize state - m_Comment = "Not watching an object"; - m_Process = 0; } FilterWatcherBase ::FilterWatcherBase(itk::ProcessObject* process, const char *comment) +: m_Comment(comment), + m_Process(process), + m_StartTag(0), + m_EndTag(0), + m_ProgressTag(0), + m_Started(false), + m_Ended(false) { - // Initialize state - m_Process = process; - m_Comment = comment; - // Create a series of commands m_StartFilterCommand = CommandType::New(); m_EndFilterCommand = CommandType::New(); diff --git a/Code/Common/otbFilterWatcherBase.h b/Code/Common/otbFilterWatcherBase.h index ef739e490c713ab76d91a39705275a4fbd4711ae..65e6fe677b2a61d0f2669de3df8fbbd5944a016a 100644 --- a/Code/Common/otbFilterWatcherBase.h +++ b/Code/Common/otbFilterWatcherBase.h @@ -94,13 +94,21 @@ protected: /** Callback method to show the StartEvent */ virtual void StartFilterCallback() { - this->StartFilter(); + if (!m_Started) + { + this->StartFilter(); + m_Started = true; + } } /** Callback method to show the EndEvent */ virtual void EndFilterCallback() { - this->EndFilter(); + if (!m_Ended) + { + this->EndFilter(); + m_Ended = true; + } } /** Callback method to show the ProgressEvent */ @@ -142,6 +150,14 @@ protected: /** Progress observer */ unsigned long m_ProgressTag; + /** Some filters (for ex. persistents) invoke the StartEvent several times + * Work around this by remembering if it was called or not */ + bool m_Started; + + /** Some filters (for ex. persistents) invoke the EndEvent several times + * Work around this by remembering if it was called or not */ + bool m_Ended; + private: };