From 95bbc7a1e281a81d26d4073a6e71d29e1779df6f Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sat, 30 Nov 2019 12:58:06 +0100 Subject: [PATCH] GUI: Print and log messages when addon execution fails (#2408) This adds an entry to the "Analysis Log" and prints a message via `qWarning()` when the execution of an addon fails because either the process failed to finish normally (for example if python binary is not found) or because the script has issues (for example because of an unhandled exception). --- gui/checkthread.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/gui/checkthread.cpp b/gui/checkthread.cpp index 26cc2bbc6..551eed382 100644 --- a/gui/checkthread.cpp +++ b/gui/checkthread.cpp @@ -313,7 +313,22 @@ void CheckThread::runAddonsAndTools(const ImportProject::FileSettings *fileSetti process.setProcessEnvironment(env); } process.start(python, args); - process.waitForFinished(); + if (!process.waitForFinished()) { + const QString errMsg("ERROR: Process '" + python + " " + args.join(" ") + + "' did not finish successfully: " + process.errorString()); + qWarning() << errMsg; + mResult.reportOut(errMsg.toStdString()); + } + const QByteArray errout = process.readAllStandardError(); + if (process.exitCode() != 0 && !errout.isEmpty()) { + const QString errMsg("ERROR: Process '" + python + " " + args.join(" ") + + "' failed with error code " + + QString::number(process.exitCode()) + ": '" + + process.errorString() + + "'\nError output: " + errout); + qWarning() << errMsg; + mResult.reportOut(errMsg.toStdString()); + } const QString output(process.readAllStandardOutput()); QFile f(dumpFile + '-' + addon + "-results"); if (f.open(QIODevice::WriteOnly | QIODevice::Text)) {