X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvThreadedFilter.cxx;h=3504b92ba7e3049d53d67168a3b57cd33513ddf5;hb=738107919dc9a056d679e75be0760e3eeae3dd4a;hp=1079b7f3217670cfecb7f4972454a8051e02bbd8;hpb=3e68fff26b5baa4237294e8255a8c360a20af1b3;p=clitk.git diff --git a/vv/vvThreadedFilter.cxx b/vv/vvThreadedFilter.cxx index 1079b7f..3504b92 100644 --- a/vv/vvThreadedFilter.cxx +++ b/vv/vvThreadedFilter.cxx @@ -3,7 +3,7 @@ Authors belong to: - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - Léon Bérard cancer center http://www.centreleonberard.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr This software is distributed WITHOUT ANY WARRANTY; without even @@ -14,7 +14,7 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - ======================================================================-====*/ + ===========================================================================**/ // vv #include "vvThreadedFilter.h" @@ -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(); } //------------------------------------------------------------------------------