From acfbac054c0e5051f7666e34a1562fb35b255448 Mon Sep 17 00:00:00 2001 From: Olivier Langella <olivier.langella@u-psud.fr> Date: Sat, 16 Sep 2017 09:20:49 +0200 Subject: [PATCH] new feature to stop X\!Tandem run process --- src/core/tandem_run/tandembatchprocess.cpp | 14 +++++++++++++- src/core/tandem_run/tandembatchprocess.h | 1 + src/gui/workerthread.cpp | 1 + src/gui/workerthread.h | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/core/tandem_run/tandembatchprocess.cpp b/src/core/tandem_run/tandembatchprocess.cpp index 5d02124c7..6a07083ec 100644 --- a/src/core/tandem_run/tandembatchprocess.cpp +++ b/src/core/tandem_run/tandembatchprocess.cpp @@ -41,6 +41,10 @@ TandemBatchProcess::TandemBatchProcess(WorkMonitorInterface * p_monitor, const T TandemBatchProcess::~TandemBatchProcess() { } + +bool TandemBatchProcess::shouldIstop() { + return false; +} void TandemBatchProcess::writeXmlDatabaseFile (QXmlStreamWriter * p_out) { p_out->setAutoFormatting(true); p_out->writeStartDocument("1.0"); @@ -94,6 +98,9 @@ void TandemBatchProcess::run() { int i=0; _p_monitor->setProgressMaximumValue(_tandem_run_batch._mz_file_list.size()); for (QString mz_file : _tandem_run_batch._mz_file_list) { + if (shouldIstop()) { + throw pappso::PappsoException(QObject::tr("X!Tandem stopped by the user processing %1 sample").arg(mz_file)); + } _p_monitor->message(QObject::tr("running X!Tandem on %1\n").arg(mz_file), i); runOne(mz_file); i++; @@ -209,6 +216,11 @@ void TandemBatchProcess::runOne(const QString & mz_file) { while(xt_process->waitForReadyRead(_max_xt_time_ms)) { _p_monitor->appendText( xt_process->readAll().data()); //data.append(xt_process->readAll()); + if (shouldIstop()) { + xt_process->kill(); + delete xt_process; + throw pappso::PappsoException(QObject::tr("X!Tandem stopped by the user processing %1 sample").arg(mz_file)); + } } /* if (!xt_process->waitForFinished(_max_xt_time_ms)) { @@ -219,11 +231,11 @@ void TandemBatchProcess::runOne(const QString & mz_file) { QProcess::ExitStatus Status = xt_process->exitStatus(); + delete xt_process; if (Status != 0) { // != QProcess::NormalExit throw pappso::PappsoException(QObject::tr("error executing X!Tandem Status != 0 : %1 %2\n%3").arg(_tandem_run_batch._tandem_bin_path).arg(arguments.join(" ").arg(result.data()))); } - delete xt_process; } diff --git a/src/core/tandem_run/tandembatchprocess.h b/src/core/tandem_run/tandembatchprocess.h index 1ce5bb788..0aed96910 100644 --- a/src/core/tandem_run/tandembatchprocess.h +++ b/src/core/tandem_run/tandembatchprocess.h @@ -47,6 +47,7 @@ protected: virtual void prepareXmlDatabaseFile(); private: void runOne(const QString & mz_file); + bool shouldIstop(); protected: QString _preset_file; diff --git a/src/gui/workerthread.cpp b/src/gui/workerthread.cpp index 265325d5a..4919ad087 100644 --- a/src/gui/workerthread.cpp +++ b/src/gui/workerthread.cpp @@ -43,6 +43,7 @@ WorkerThread::WorkerThread(MainWindow * p_main_window) { + _p_main_window = p_main_window; qDebug() << "WorkerThread::WorkerThread begin MainWindow"; _p_work_monitor = new WorkMonitor(); diff --git a/src/gui/workerthread.h b/src/gui/workerthread.h index 007d190b8..d357d710e 100644 --- a/src/gui/workerthread.h +++ b/src/gui/workerthread.h @@ -79,6 +79,7 @@ signals: private: WorkMonitor * _p_work_monitor; + MainWindow * _p_main_window; }; #endif // WORKERTHREAD_H -- GitLab