From 0f61bdc04f81657ebc01b04a40fe933f4424328e Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 30 Apr 2021 17:50:30 +0200 Subject: [PATCH] Utils: Base TerminalControllingProcess on QtcProcess This here is a step towards making SynchronousProcess interface more similar to QtcProcess with the final goal of unifying them. TerminalControllingProcess is just an implementation details of SynchronousProcess, which in turn is mostly used in Android and VcsCommand, e.g. for 'git blame' (good test...) In the light of 04b20a1a46818b84efbfb11d8cb3c6a8613f608f / QTCREATORBUG-21547 and the potential need to bisect later this here is a first baby step. Change-Id: I48e57d9fdb7c37eb0d2a5c5eef8643d6be97c3cc Reviewed-by: Orgad Shaneh --- src/libs/utils/synchronousprocess.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/libs/utils/synchronousprocess.cpp b/src/libs/utils/synchronousprocess.cpp index fa6cf77556f..f23415cd3f0 100644 --- a/src/libs/utils/synchronousprocess.cpp +++ b/src/libs/utils/synchronousprocess.cpp @@ -88,7 +88,8 @@ namespace Utils { static Q_LOGGING_CATEGORY(processLog, "qtc.utils.synchronousprocess", QtWarningMsg); // A special QProcess derivative allowing for terminal control. -class TerminalControllingProcess : public QProcess { +class TerminalControllingProcess : public QtcProcess +{ public: TerminalControllingProcess(); @@ -391,7 +392,7 @@ void SynchronousProcess::setStdErrBufferedSignalsEnabled(bool v) QStringList SynchronousProcess::environment() const { - return d->m_process.environment(); + return d->m_process.environment().toStringList(); } bool SynchronousProcess::timeOutMessageBoxEnabled() const @@ -406,7 +407,7 @@ void SynchronousProcess::setTimeOutMessageBoxEnabled(bool v) void SynchronousProcess::setEnvironment(const QStringList &e) { - d->m_process.setEnvironment(e); + d->m_process.setEnvironment(Environment(e)); } void SynchronousProcess::setProcessEnvironment(const QProcessEnvironment &environment) @@ -479,15 +480,15 @@ SynchronousProcessResponse SynchronousProcess::run(const CommandLine &cmd, // using QProcess::start() and passing program, args and OpenMode results in a different // quoting of arguments than using QProcess::setArguments() beforehand and calling start() // only with the OpenMode - d->m_process.setProgram(cmd.executable().toString()); - d->m_process.setArguments(cmd.splitArguments()); + d->m_process.setCommand(cmd); if (!writeData.isEmpty()) { connect(&d->m_process, &QProcess::started, this, [this, writeData] { d->m_process.write(writeData); d->m_process.closeWriteChannel(); }); } - d->m_process.start(writeData.isEmpty() ? QIODevice::ReadOnly : QIODevice::ReadWrite); + d->m_process.setOpenMode(writeData.isEmpty() ? QIODevice::ReadOnly : QIODevice::ReadWrite); + d->m_process.start(); // On Windows, start failure is triggered immediately if the // executable cannot be found in the path. Do not start the @@ -521,7 +522,9 @@ SynchronousProcessResponse SynchronousProcess::runBlocking(const CommandLine &cm d->clearForRun(); d->m_binary = cmd.executable(); - d->m_process.start(cmd.executable().toString(), cmd.splitArguments(), QIODevice::ReadOnly); + d->m_process.setOpenMode(QIODevice::ReadOnly); + d->m_process.setCommand(cmd); + d->m_process.start(); if (!d->m_process.waitForStarted(d->m_maxHangTimerCount * 1000)) { d->m_result.result = SynchronousProcessResponse::StartFailed; return d->m_result;