Skip to content
Snippets Groups Projects
Commit d7344ce3 authored by Julien Malik's avatar Julien Malik
Browse files

BUG: fix FilterWatcher to avoid calling the start/end callback several times

parent d4821622
No related branches found
No related tags found
No related merge requests found
......@@ -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();
......
......@@ -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:
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment