From 1b1ea15d1c224a17772a2fbec2ec3c9131a94360 Mon Sep 17 00:00:00 2001 From: Kevin Hendricks Date: Mon, 11 Dec 2023 09:53:33 -0500 Subject: [PATCH] better handle cancelling plugins in PluginRunner --- src/Dialogs/PluginRunner.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Dialogs/PluginRunner.cpp b/src/Dialogs/PluginRunner.cpp index f27774e3f0..66bd2c983e 100644 --- a/src/Dialogs/PluginRunner.cpp +++ b/src/Dialogs/PluginRunner.cpp @@ -62,7 +62,7 @@ PluginRunner::PluginRunner(TabManager *tabMgr, QWidget *parent) m_pluginName(""), m_pluginOutput(""), m_algorithm(""), - m_result("failed"), + m_result(""), m_xhtml_net_change(0), m_ready(false) @@ -434,10 +434,12 @@ void PluginRunner::processOutput() m_pluginOutput = m_pluginOutput + newbytedata; } + void PluginRunner::pluginFinished(int exitcode, QProcess::ExitStatus exitstatus) { if (exitstatus == QProcess::CrashExit) { ui.textEdit->append(tr("Launcher process crashed")); + m_result = "crashed"; } // launcher exiting properly does not mean target plugin succeeded or failed // we need to parse the response xml to find the true result of target plugin @@ -448,6 +450,10 @@ void PluginRunner::pluginFinished(int exitcode, QProcess::ExitStatus exitstatus) ui.progressBar->setRange(0,100); ui.progressBar->setValue(100); + if (m_result == "crashed" || + m_result == "failed" || + m_result == "cancelled") return; + ui.statusLbl->setText(tr("Status: finished")); if (!processResultXML()) { @@ -584,6 +590,8 @@ void PluginRunner::reject() void PluginRunner::cancelPlugin() { // qDebug() << "in cancelPlugin()"; + m_result = "cancelled"; + if (m_process.state() == QProcess::Running) { m_process.terminate(); } @@ -602,7 +610,7 @@ void PluginRunner::cancelPlugin() ui.textEdit->append(tr("Plugin cancelled")); ui.statusLbl->setText(tr("Status: cancelled")); ui.cancelButton->setEnabled(false); - m_result = "failed"; + m_result = "cancelled"; } bool PluginRunner::processResultXML()