forked from qt-creator/qt-creator
RunControl: Add more helper functions to SimpleTargetRunner
Allow to disable the forwarding of stdout and stderr and provide access to the underlying Process. This can be used when stdout and stderr need to be forwarded to other RunWorkers. Change-Id: I7fb789defe8a57831fcaf312fc7b500affdf2f61 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -1264,6 +1264,7 @@ public:
|
||||
|
||||
bool m_stopReported = false;
|
||||
bool m_stopForced = false;
|
||||
bool m_suppressDefaultStdOutHandling = false;
|
||||
|
||||
void forwardStarted();
|
||||
void forwardDone();
|
||||
@@ -1372,6 +1373,9 @@ void SimpleTargetRunnerPrivate::handleDone()
|
||||
|
||||
void SimpleTargetRunnerPrivate::handleStandardOutput()
|
||||
{
|
||||
if (m_suppressDefaultStdOutHandling)
|
||||
return;
|
||||
|
||||
const QByteArray data = m_process.readAllRawStandardOutput();
|
||||
const QString msg = m_outputCodec->toUnicode(
|
||||
data.constData(), data.length(), &m_outputCodecState);
|
||||
@@ -1380,6 +1384,9 @@ void SimpleTargetRunnerPrivate::handleStandardOutput()
|
||||
|
||||
void SimpleTargetRunnerPrivate::handleStandardError()
|
||||
{
|
||||
if (m_suppressDefaultStdOutHandling)
|
||||
return;
|
||||
|
||||
const QByteArray data = m_process.readAllRawStandardError();
|
||||
const QString msg = m_outputCodec->toUnicode(
|
||||
data.constData(), data.length(), &m_errorCodecState);
|
||||
@@ -1571,6 +1578,16 @@ void SimpleTargetRunner::setProcessMode(Utils::ProcessMode processMode)
|
||||
d->m_process.setProcessMode(processMode);
|
||||
}
|
||||
|
||||
Process *SimpleTargetRunner::process() const
|
||||
{
|
||||
return &d->m_process;
|
||||
}
|
||||
|
||||
void SimpleTargetRunner::suppressDefaultStdOutHandling()
|
||||
{
|
||||
d->m_suppressDefaultStdOutHandling = true;
|
||||
}
|
||||
|
||||
void SimpleTargetRunner::forceRunOnHost()
|
||||
{
|
||||
const FilePath executable = d->m_command.executable();
|
||||
|
@@ -27,6 +27,7 @@ class Icon;
|
||||
class MacroExpander;
|
||||
class OutputLineParser;
|
||||
class ProcessRunData;
|
||||
class Process;
|
||||
} // Utils
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -271,7 +272,9 @@ protected:
|
||||
void setEnvironment(const Utils::Environment &environment);
|
||||
void setWorkingDirectory(const Utils::FilePath &workingDirectory);
|
||||
void setProcessMode(Utils::ProcessMode processMode);
|
||||
Utils::Process *process() const;
|
||||
|
||||
void suppressDefaultStdOutHandling();
|
||||
void forceRunOnHost();
|
||||
void addExtraData(const QString &key, const QVariant &value);
|
||||
|
||||
|
Reference in New Issue
Block a user