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
- BSD See included LICENSE.txt file
- CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
- ======================================================================-====*/
+ ===========================================================================**/
// vv
#include "vvThreadedFilter.h"
vvThreadedFilter::vvThreadedFilter():
QThread()
{
- DD("vvThreadedFilter");
m_Filter = NULL;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvThreadedFilter::SetFilter(clitk::ImageToImageGenericFilterBase * f)
{
- DD("SetFilter");
m_Filter = f;
}
//------------------------------------------------------------------------------
// Show a progress bar while computing
vvProgressDialog progress("Computing ...",100);
+ progress.SetCancelButtonEnabled(true);
connect(&progress, SIGNAL(rejected()), this, SLOT(reject()));
this->start();
this->setTerminationEnabled(true);
std::string temp;
while (this->isRunning()) {
- DD(this->isRunning());
- m_FilterBase = m_Filter->GetFilterBase(); // get filterbase only after Update
+ // try {
+ m_FilterBase = m_Filter->GetFilterBase(); // get filterbase is only set after Update
if (m_FilterBase != NULL) {
progress.SetProgress(m_FilterBase->GetCurrentStepNumber(),
m_FilterBase->GetNumberOfSteps());
}
temp = m_FilterBase->GetCurrentStepName();
}
- this->wait(200); // in milisecond
+ this->wait(200); // in miliseconds
qApp->processEvents();
}
- DD("after loop");
}
//------------------------------------------------------------------------------
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");
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvThreadedFilter::reject()
{
- DD("vvThreadedFilter::reject");
- this->quit();
- // if (m_Filter != NULL) {
-// m_Filter->MustStop();
-// }
- DD("after terminate");
+ // 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->Cancel();
+ }
}
//------------------------------------------------------------------------------