Skip to content
Snippets Groups Projects
Commit 334175b9 authored by Gigg, Martyn Anthony's avatar Gigg, Martyn Anthony
Browse files

Ensure MantidPlot exits with 0 status code on script success.

Refs #9559
parent b9c991e7
No related merge requests found
......@@ -16438,6 +16438,7 @@ void ApplicationWindow::executeScriptFile(const QString & filename, const Script
code += in.readLine() + "\n";
}
Script *runner = scriptingEnv()->newScript(filename, this, Script::NonInteractive);
connect(runner, SIGNAL(finished(const QString &)), this, SLOT(onScriptExecuteSuccess(const QString &)));
connect(runner, SIGNAL(error(const QString &, const QString &, int)), this, SLOT(onScriptExecuteError(const QString &, const QString &, int)));
runner->redirectStdOut(false);
scriptingEnv()->redirectStdOut(false);
......@@ -16459,6 +16460,18 @@ void ApplicationWindow::executeScriptFile(const QString & filename, const Script
delete runner;
}
 
/**
* This is the slot for handing script exits when it returns successfully
*
* @param lineNumber The line number in the script that caused the error.
*/
void ApplicationWindow::onScriptExecuteSuccess(const QString & message)
{
g_log.notice() << message.toStdString() << "\n";
this->setExitCode(0);
this->exitWithPresetCode();
}
/**
* This is the slot for handing script execution errors. It is only
* attached by ::executeScriptFile which is only done in the '-xq'
......
......@@ -230,6 +230,8 @@ public slots:
ApplicationWindow * loadScript(const QString& fn);
/// Runs a script from a file. Mainly useful for automatically running scripts
void executeScriptFile(const QString & filename, const Script::ExecutionMode execMode);
/// Slot to connect the script execution success
void onScriptExecuteSuccess(const QString & message);
/// Slot to connect the script execution errors to
void onScriptExecuteError(const QString & message, const QString & scriptName, int lineNumber);
/// Runs an arbitrary lump of python code, return true/false on success/failure.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment