X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvThreadedFilter.cxx;h=0a074f37e312b31ed4528224830a1d8d3ad40217;hb=2b52eef8a31e779c3bd3a3e0d52fb70b8af51486;hp=1079b7f3217670cfecb7f4972454a8051e02bbd8;hpb=3e68fff26b5baa4237294e8255a8c360a20af1b3;p=clitk.git diff --git a/vv/vvThreadedFilter.cxx b/vv/vvThreadedFilter.cxx index 1079b7f..0a074f3 100644 --- a/vv/vvThreadedFilter.cxx +++ b/vv/vvThreadedFilter.cxx @@ -60,9 +60,9 @@ void vvThreadedFilter::Update() this->setTerminationEnabled(true); std::string temp; while (this->isRunning()) { + // try { m_FilterBase = m_Filter->GetFilterBase(); // get filterbase is only set after Update if (m_FilterBase != NULL) { - // m_FilterBase->StopOnErrorOff(); // filter can be interrupted progress.SetProgress(m_FilterBase->GetCurrentStepNumber(), m_FilterBase->GetNumberOfSteps()); if (temp != m_FilterBase->GetCurrentStepName()) { @@ -70,7 +70,7 @@ void vvThreadedFilter::Update() } temp = m_FilterBase->GetCurrentStepName(); } - this->wait(200); // in milisecond + this->wait(200); // in miliseconds qApp->processEvents(); } } @@ -81,7 +81,16 @@ void vvThreadedFilter::Update() void vvThreadedFilter::run() { assert(m_Filter != NULL); - m_Filter->Update(); + try { + m_Filter->Update(); + } + catch(clitk::ExceptionObject e) { + DD("vvThreadedFilter : exceptionobject handeled"); + DD(e.what()); + QApplication::restoreOverrideCursor(); + QMessageBox::information(new QWidget, tr("Error"), e.what()); + } + DD("end RUN"); } //------------------------------------------------------------------------------ @@ -89,16 +98,11 @@ void vvThreadedFilter::run() //------------------------------------------------------------------------------ void vvThreadedFilter::reject() { - // First, say the filter it must stop + // First, say the filter it must stop as soon as possible. We then + // wait that an exception occur in the main thread. if (m_FilterBase != NULL) { - m_FilterBase->SetMustStop(true); + m_FilterBase->Cancel(); } - // Indicate to the user it will stop - QApplication::restoreOverrideCursor(); - QMessageBox::information(new QWidget, tr("Error"), m_FilterBase->GetLastError().c_str()); - // Quit the thread (is it needed ?) - this->quit(); - emit ThreadInterrupted(); } //------------------------------------------------------------------------------