Skip to content

Commit

Permalink
better handle cancelling plugins in PluginRunner
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhendricks committed Dec 11, 2023
1 parent 1dea25f commit 1b1ea15
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Dialogs/PluginRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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()) {
Expand Down Expand Up @@ -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();
}
Expand All @@ -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()
Expand Down

0 comments on commit 1b1ea15

Please sign in to comment.