diff --git a/src/gui/src/CoreInterface.cpp b/src/gui/src/CoreInterface.cpp index 1a917382..4705b8cc 100644 --- a/src/gui/src/CoreInterface.cpp +++ b/src/gui/src/CoreInterface.cpp @@ -17,6 +17,8 @@ #include "CoreInterface.h" +#include "CommandProcess.h" + #include #include #include @@ -83,33 +85,7 @@ QString CoreInterface::run(const QStringList& args, const QString& input) QCoreApplication::applicationDirPath() + "/" + kCoreBinary); - QProcess process; - process.setReadChannel(QProcess::StandardOutput); - process.start(program, args); - bool success = process.waitForStarted(); + CommandProcess commandProcess(program, args, input); + return commandProcess.run(); - QString output, error; - if (success) - { - if (!input.isEmpty()) { - process.write(input.toStdString().c_str()); - } - - if (process.waitForFinished()) { - output = process.readAllStandardOutput().trimmed(); - error = process.readAllStandardError().trimmed(); - } - } - - int code = process.exitCode(); - if (!error.isEmpty() || !success || code != 0) - { - throw std::runtime_error( - QString("Code: %1\nError: %2") - .arg(process.exitCode()) - .arg(error.isEmpty() ? "Unknown" : error) - .toStdString()); - } - - return output; }