diff options
author | Dominik Holland <dominik.holland@qt.io> | 2024-03-07 16:56:18 +0100 |
---|---|---|
committer | Dominik Holland <dominik.holland@qt.io> | 2024-05-08 08:16:43 +0000 |
commit | a90d16beda3bf603be0094af5916b1017946f1f4 (patch) | |
tree | 546c3e7925bcab1b0ef9fc6ed83a60e8cb120da4 | |
parent | b537c9ee30d277a5540eec3654d22afa8d64b988 (diff) |
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>
-rw-r--r-- | src/plugins/projectexplorer/runcontrol.cpp | 17 | ||||
-rw-r--r-- | src/plugins/projectexplorer/runcontrol.h | 3 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/plugins/projectexplorer/runcontrol.cpp b/src/plugins/projectexplorer/runcontrol.cpp index 3b601d45cb..6085a72083 100644 --- a/src/plugins/projectexplorer/runcontrol.cpp +++ b/src/plugins/projectexplorer/runcontrol.cpp @@ -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(); diff --git a/src/plugins/projectexplorer/runcontrol.h b/src/plugins/projectexplorer/runcontrol.h index 0c47ff18b6..9428866436 100644 --- a/src/plugins/projectexplorer/runcontrol.h +++ b/src/plugins/projectexplorer/runcontrol.h @@ -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); |