Utils: Make process results accessible through QtcProcess object

The result is fully stored in the object anyway. Using the extra
SynchronousProcessResponse structure only causes copies of
the data and complicates access on the user side in
a lot of cases.

The result bits are now also accessible individually.

There's obvious room for follow-up changes on the topic, e.g.
ShellCommand::runCommand's parameter list could shrink to
just a SynchronousProcess parameter.

Change-Id: I45aa7eb23832340be06905929280c012e1217263
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2021-05-12 14:25:50 +02:00
parent f23b27ded6
commit 55f768e1b0
54 changed files with 747 additions and 706 deletions

View File

@@ -418,10 +418,10 @@ QString PluginManager::systemInformation()
QString result; QString result;
CommandLine qtDiag(HostOsInfo::withExecutableSuffix( CommandLine qtDiag(HostOsInfo::withExecutableSuffix(
QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qtdiag")); QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qtdiag"));
SynchronousProcess qtdiagProc; SynchronousProcess qtDiagProc;
const SynchronousProcessResponse response = qtdiagProc.runBlocking(qtDiag); qtDiagProc.runBlocking(qtDiag);
if (response.result == SynchronousProcessResponse::Finished) if (qtDiagProc.result() == QtcProcess::Finished)
result += response.allOutput() + "\n"; result += qtDiagProc.allOutput() + "\n";
result += "Plugin information:\n\n"; result += "Plugin information:\n\n";
auto longestSpec = std::max_element(d->pluginSpecs.cbegin(), d->pluginSpecs.cend(), auto longestSpec = std::max_element(d->pluginSpecs.cbegin(), d->pluginSpecs.cend(),
[](const PluginSpec *left, const PluginSpec *right) { [](const PluginSpec *left, const PluginSpec *right) {

View File

@@ -46,10 +46,10 @@ QString BuildableHelperLibrary::qtChooserToQmakePath(const QString &path)
const QString toolDir = QLatin1String("QTTOOLDIR=\""); const QString toolDir = QLatin1String("QTTOOLDIR=\"");
SynchronousProcess proc; SynchronousProcess proc;
proc.setTimeoutS(1); proc.setTimeoutS(1);
SynchronousProcessResponse response = proc.runBlocking({path, {"-print-env"}}); proc.runBlocking({path, {"-print-env"}});
if (response.result != SynchronousProcessResponse::Finished) if (proc.result() != QtcProcess::Finished)
return QString(); return QString();
const QString output = response.stdOut(); const QString output = proc.stdOut();
int pos = output.indexOf(toolDir); int pos = output.indexOf(toolDir);
if (pos == -1) if (pos == -1)
return QString(); return QString();
@@ -130,13 +130,13 @@ QString BuildableHelperLibrary::qtVersionForQMake(const QString &qmakePath)
SynchronousProcess qmake; SynchronousProcess qmake;
qmake.setTimeoutS(5); qmake.setTimeoutS(5);
SynchronousProcessResponse response = qmake.runBlocking({qmakePath, {"--version"}}); qmake.runBlocking({qmakePath, {"--version"}});
if (response.result != SynchronousProcessResponse::Finished) { if (qmake.result() != QtcProcess::Finished) {
qWarning() << response.exitMessage(qmakePath, 5); qWarning() << qmake.exitMessage(qmakePath, 5);
return QString(); return QString();
} }
const QString output = response.allOutput(); const QString output = qmake.allOutput();
static const QRegularExpression regexp("(QMake version:?)[\\s]*([\\d.]*)", static const QRegularExpression regexp("(QMake version:?)[\\s]*([\\d.]*)",
QRegularExpression::CaseInsensitiveOption); QRegularExpression::CaseInsensitiveOption);
const QRegularExpressionMatch match = regexp.match(output); const QRegularExpressionMatch match = regexp.match(output);

View File

@@ -151,10 +151,10 @@ QString BinaryVersionToolTipEventFilter::toolVersion(const CommandLine &cmd)
return QString(); return QString();
SynchronousProcess proc; SynchronousProcess proc;
proc.setTimeoutS(1); proc.setTimeoutS(1);
SynchronousProcessResponse response = proc.runBlocking(cmd); proc.runBlocking(cmd);
if (response.result != SynchronousProcessResponse::Finished) if (proc.result() != QtcProcess::Finished)
return QString(); return QString();
return response.allOutput(); return proc.allOutput();
} }
// Extends BinaryVersionToolTipEventFilter to prepend the existing pathchooser // Extends BinaryVersionToolTipEventFilter to prepend the existing pathchooser

View File

@@ -73,6 +73,19 @@ static Q_LOGGING_CATEGORY(processLog, "qtc.utils.synchronousprocess", QtWarningM
static std::function<void(QtcProcess &)> s_remoteRunProcessHook; static std::function<void(QtcProcess &)> s_remoteRunProcessHook;
/* Result of SynchronousProcess execution */
class SynchronousProcessResponse
{
public:
void clear();
QtcProcess::Result result = QtcProcess::StartFailed;
int exitCode = -1;
QByteArray rawStdOut;
QByteArray rawStdErr;
};
// Data for one channel buffer (stderr/stdout) // Data for one channel buffer (stderr/stdout)
class ChannelBuffer : public QObject class ChannelBuffer : public QObject
{ {
@@ -112,7 +125,7 @@ public:
void slotError(QProcess::ProcessError); void slotError(QProcess::ProcessError);
void clearForRun(); void clearForRun();
SynchronousProcessResponse::Result interpretExitCode(int exitCode); QtcProcess::Result interpretExitCode(int exitCode);
QtcProcess *q; QtcProcess *q;
QTextCodec *m_codec = QTextCodec::codecForLocale(); QTextCodec *m_codec = QTextCodec::codecForLocale();
@@ -139,19 +152,17 @@ void QtcProcessPrivate::clearForRun()
m_stdErr.clearForRun(); m_stdErr.clearForRun();
m_stdErr.codec = m_codec; m_stdErr.codec = m_codec;
m_result.clear(); m_result.clear();
m_result.codec = m_codec;
m_startFailure = false; m_startFailure = false;
m_binary = {}; m_binary = {};
} }
SynchronousProcessResponse::Result QtcProcessPrivate::interpretExitCode(int exitCode) QtcProcess::Result QtcProcessPrivate::interpretExitCode(int exitCode)
{ {
if (m_exitCodeInterpreter) if (m_exitCodeInterpreter)
return m_exitCodeInterpreter(exitCode); return m_exitCodeInterpreter(exitCode);
// default: // default:
return exitCode ? SynchronousProcessResponse::FinishedError return exitCode ? QtcProcess::FinishedError : QtcProcess::Finished;
: SynchronousProcessResponse::Finished;
} }
} // Internal } // Internal
@@ -459,6 +470,21 @@ QString QtcProcess::normalizeNewlines(const QString &text)
return res; return res;
} }
QtcProcess::Result QtcProcess::result() const
{
return d->m_result.result;
}
void QtcProcess::setResult(Result result)
{
d->m_result.result = result;
}
int QtcProcess::exitCode() const
{
return d->m_result.exitCode;
}
// Path utilities // Path utilities
@@ -576,19 +602,19 @@ QString QtcProcess::locateBinary(const QString &binary)
// ----------- SynchronousProcessResponse // ----------- SynchronousProcessResponse
void SynchronousProcessResponse::clear() void SynchronousProcessResponse::clear()
{ {
result = StartFailed; result = QtcProcess::StartFailed;
exitCode = -1; exitCode = -1;
rawStdOut.clear(); rawStdOut.clear();
rawStdErr.clear(); rawStdErr.clear();
} }
QString SynchronousProcessResponse::exitMessage(const QString &binary, int timeoutS) const QString QtcProcess::exitMessage(const QString &binary, int timeoutS) const
{ {
switch (result) { switch (result()) {
case Finished: case Finished:
return QtcProcess::tr("The command \"%1\" finished successfully.").arg(QDir::toNativeSeparators(binary)); return QtcProcess::tr("The command \"%1\" finished successfully.").arg(QDir::toNativeSeparators(binary));
case FinishedError: case FinishedError:
return QtcProcess::tr("The command \"%1\" terminated with exit code %2.").arg(QDir::toNativeSeparators(binary)).arg(exitCode); return QtcProcess::tr("The command \"%1\" terminated with exit code %2.").arg(QDir::toNativeSeparators(binary)).arg(exitCode());
case TerminatedAbnormally: case TerminatedAbnormally:
return QtcProcess::tr("The command \"%1\" terminated abnormally.").arg(QDir::toNativeSeparators(binary)); return QtcProcess::tr("The command \"%1\" terminated abnormally.").arg(QDir::toNativeSeparators(binary));
case StartFailed: case StartFailed:
@@ -600,19 +626,19 @@ QString SynchronousProcessResponse::exitMessage(const QString &binary, int timeo
return QString(); return QString();
} }
QByteArray SynchronousProcessResponse::allRawOutput() const QByteArray QtcProcess::allRawOutput() const
{ {
if (!rawStdOut.isEmpty() && !rawStdErr.isEmpty()) { if (!d->m_result.rawStdOut.isEmpty() && !d->m_result.rawStdErr.isEmpty()) {
QByteArray result = rawStdOut; QByteArray result = d->m_result.rawStdOut;
if (!result.endsWith('\n')) if (!result.endsWith('\n'))
result += '\n'; result += '\n';
result += rawStdErr; result += d->m_result.rawStdErr;
return result; return result;
} }
return !rawStdOut.isEmpty() ? rawStdOut : rawStdErr; return !d->m_result.rawStdOut.isEmpty() ? d->m_result.rawStdOut : d->m_result.rawStdErr;
} }
QString SynchronousProcessResponse::allOutput() const QString QtcProcess::allOutput() const
{ {
const QString out = stdOut(); const QString out = stdOut();
const QString err = stdErr(); const QString err = stdErr();
@@ -627,21 +653,32 @@ QString SynchronousProcessResponse::allOutput() const
return !out.isEmpty() ? out : err; return !out.isEmpty() ? out : err;
} }
QString SynchronousProcessResponse::stdOut() const QString QtcProcess::stdOut() const
{ {
return QtcProcess::normalizeNewlines(codec->toUnicode(rawStdOut)); return normalizeNewlines(d->m_codec->toUnicode(d->m_result.rawStdOut));
} }
QString SynchronousProcessResponse::stdErr() const QString QtcProcess::stdErr() const
{ {
return QtcProcess::normalizeNewlines(codec->toUnicode(rawStdErr)); return normalizeNewlines(d->m_codec->toUnicode(d->m_result.rawStdErr));
} }
QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug str, const SynchronousProcessResponse& r) QByteArray QtcProcess::rawStdOut() const
{
return d->m_result.rawStdOut;
}
QByteArray QtcProcess::rawStdErr() const
{
return d->m_result.rawStdErr;
}
QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug str, const QtcProcess &r)
{ {
QDebug nsp = str.nospace(); QDebug nsp = str.nospace();
nsp << "SynchronousProcessResponse: result=" << r.result << " ex=" << r.exitCode << '\n' nsp << "QtcProcess: result="
<< r.rawStdOut.size() << " bytes stdout, stderr=" << r.rawStdErr << '\n'; << r.d->m_result.result << " ex=" << r.exitCode() << '\n'
<< r.d->m_result.rawStdOut.size() << " bytes stdout, stderr=" << r.d->m_result.rawStdErr << '\n';
return str; return str;
} }
@@ -748,7 +785,7 @@ static bool isGuiThread()
} }
#endif #endif
SynchronousProcessResponse QtcProcess::run(const CommandLine &cmd, const QByteArray &writeData) void QtcProcess::run(const CommandLine &cmd, const QByteArray &writeData)
{ {
// FIXME: Implement properly // FIXME: Implement properly
if (cmd.executable().needsDevice()) { if (cmd.executable().needsDevice()) {
@@ -759,18 +796,15 @@ SynchronousProcessResponse QtcProcess::run(const CommandLine &cmd, const QByteAr
waitForFinished(); waitForFinished();
SynchronousProcessResponse res; d->m_result.result = QtcProcess::Finished;
res.result = SynchronousProcessResponse::Finished; d->m_result.exitCode = exitCode();
res.exitCode = exitCode(); d->m_result.rawStdOut = readAllStandardOutput();
res.rawStdOut = readAllStandardOutput(); d->m_result.rawStdErr = readAllStandardError();
res.rawStdErr = readAllStandardError(); return;
return res;
}; };
qCDebug(processLog).noquote() << "Starting:" << cmd.toUserOutput(); qCDebug(processLog).noquote() << "Starting:" << cmd.toUserOutput();
ExecuteOnDestruction logResult([this] { ExecuteOnDestruction logResult([this] { qCDebug(processLog) << *this; });
qCDebug(processLog) << d->m_result;
});
d->clearForRun(); d->clearForRun();
@@ -810,11 +844,9 @@ SynchronousProcessResponse QtcProcess::run(const CommandLine &cmd, const QByteAr
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
#endif #endif
} }
return d->m_result;
} }
SynchronousProcessResponse QtcProcess::runBlocking(const CommandLine &cmd) void QtcProcess::runBlocking(const CommandLine &cmd)
{ {
// FIXME: Implement properly // FIXME: Implement properly
if (cmd.executable().needsDevice()) { if (cmd.executable().needsDevice()) {
@@ -825,18 +857,15 @@ SynchronousProcessResponse QtcProcess::runBlocking(const CommandLine &cmd)
waitForFinished(); waitForFinished();
SynchronousProcessResponse res; d->m_result.result = QtcProcess::Finished;
res.result = SynchronousProcessResponse::Finished; d->m_result.exitCode = exitCode();
res.exitCode = exitCode(); d->m_result.rawStdOut = readAllStandardOutput();
res.rawStdOut = readAllStandardOutput(); d->m_result.rawStdErr = readAllStandardError();
res.rawStdErr = readAllStandardError(); return;
return res;
}; };
qCDebug(processLog).noquote() << "Starting blocking:" << cmd.toUserOutput(); qCDebug(processLog).noquote() << "Starting blocking:" << cmd.toUserOutput();
ExecuteOnDestruction logResult([this] { ExecuteOnDestruction logResult([this] { qCDebug(processLog) << *this; });
qCDebug(processLog) << d->m_result;
});
d->clearForRun(); d->clearForRun();
@@ -845,12 +874,12 @@ SynchronousProcessResponse QtcProcess::runBlocking(const CommandLine &cmd)
setCommand(cmd); setCommand(cmd);
start(); start();
if (!waitForStarted(d->m_maxHangTimerCount * 1000)) { if (!waitForStarted(d->m_maxHangTimerCount * 1000)) {
d->m_result.result = SynchronousProcessResponse::StartFailed; d->m_result.result = QtcProcess::StartFailed;
return d->m_result; return;
} }
closeWriteChannel(); closeWriteChannel();
if (!waitForFinished(d->m_maxHangTimerCount * 1000)) { if (!waitForFinished(d->m_maxHangTimerCount * 1000)) {
d->m_result.result = SynchronousProcessResponse::Hang; d->m_result.result = QtcProcess::Hang;
terminate(); terminate();
if (!waitForFinished(1000)) { if (!waitForFinished(1000)) {
kill(); kill();
@@ -859,12 +888,12 @@ SynchronousProcessResponse QtcProcess::runBlocking(const CommandLine &cmd)
} }
if (state() != QProcess::NotRunning) if (state() != QProcess::NotRunning)
return d->m_result; return;
d->m_result.exitCode = exitCode(); d->m_result.exitCode = exitCode();
if (d->m_result.result == SynchronousProcessResponse::StartFailed) { if (d->m_result.result == QtcProcess::StartFailed) {
if (exitStatus() != QProcess::NormalExit) if (exitStatus() != QProcess::NormalExit)
d->m_result.result = SynchronousProcessResponse::TerminatedAbnormally; d->m_result.result = QtcProcess::TerminatedAbnormally;
else else
d->m_result.result = d->interpretExitCode(d->m_result.exitCode); d->m_result.result = d->interpretExitCode(d->m_result.exitCode);
} }
@@ -873,8 +902,6 @@ SynchronousProcessResponse QtcProcess::runBlocking(const CommandLine &cmd)
d->m_result.rawStdOut = d->m_stdOut.rawData; d->m_result.rawStdOut = d->m_stdOut.rawData;
d->m_result.rawStdErr = d->m_stdErr.rawData; d->m_result.rawStdErr = d->m_stdErr.rawData;
return d->m_result;
} }
void QtcProcess::setStdOutCallback(const std::function<void (const QString &)> &callback) void QtcProcess::setStdOutCallback(const std::function<void (const QString &)> &callback)
@@ -897,7 +924,7 @@ void QtcProcessPrivate::slotTimeout()
m_waitingForUser = false; m_waitingForUser = false;
if (terminate) { if (terminate) {
q->stopProcess(); q->stopProcess();
m_result.result = SynchronousProcessResponse::Hang; m_result.result = QtcProcess::Hang;
} else { } else {
m_hangTimerCount = 0; m_hangTimerCount = 0;
} }
@@ -920,8 +947,8 @@ void QtcProcessPrivate::slotFinished(int exitCode, QProcess::ExitStatus e)
break; break;
case QProcess::CrashExit: case QProcess::CrashExit:
// Was hang detected before and killed? // Was hang detected before and killed?
if (m_result.result != SynchronousProcessResponse::Hang) if (m_result.result != QtcProcess::Hang)
m_result.result = SynchronousProcessResponse::TerminatedAbnormally; m_result.result = QtcProcess::TerminatedAbnormally;
m_result.exitCode = -1; m_result.exitCode = -1;
break; break;
} }
@@ -934,8 +961,8 @@ void QtcProcessPrivate::slotError(QProcess::ProcessError e)
if (debug) if (debug)
qDebug() << Q_FUNC_INFO << e; qDebug() << Q_FUNC_INFO << e;
// Was hang detected before and killed? // Was hang detected before and killed?
if (m_result.result != SynchronousProcessResponse::Hang) if (m_result.result != QtcProcess::Hang)
m_result.result = SynchronousProcessResponse::StartFailed; m_result.result = QtcProcess::StartFailed;
m_startFailure = true; m_startFailure = true;
m_eventLoop.quit(); m_eventLoop.quit();
} }

View File

@@ -44,10 +44,14 @@ class Environment;
namespace Internal { class QtcProcessPrivate; } namespace Internal { class QtcProcessPrivate; }
/* Result of SynchronousProcess execution */ class QTCREATOR_UTILS_EXPORT QtcProcess : public QProcess
class QTCREATOR_UTILS_EXPORT SynchronousProcessResponse
{ {
Q_OBJECT
public: public:
QtcProcess(QObject *parent = nullptr);
~QtcProcess();
enum Result { enum Result {
// Finished with return code 0 // Finished with return code 0
Finished, Finished,
@@ -60,35 +64,6 @@ public:
// Hang, no output after time out // Hang, no output after time out
Hang }; Hang };
void clear();
// Helper to format an exit message.
QString exitMessage(const QString &binary, int timeoutS) const;
QByteArray allRawOutput() const;
QString allOutput() const;
QString stdOut() const;
QString stdErr() const;
Result result = StartFailed;
int exitCode = -1;
QByteArray rawStdOut;
QByteArray rawStdErr;
QTextCodec *codec = QTextCodec::codecForLocale();
};
using ExitCodeInterpreter = std::function<SynchronousProcessResponse::Result(int /*exitCode*/)>;
class QTCREATOR_UTILS_EXPORT QtcProcess : public QProcess
{
Q_OBJECT
public:
QtcProcess(QObject *parent = nullptr);
~QtcProcess();
void setEnvironment(const Environment &env); void setEnvironment(const Environment &env);
const Environment &environment() const; const Environment &environment() const;
@@ -109,12 +84,12 @@ public:
void setCodec(QTextCodec *c); void setCodec(QTextCodec *c);
void setTimeOutMessageBoxEnabled(bool); void setTimeOutMessageBoxEnabled(bool);
void setExitCodeInterpreter(const ExitCodeInterpreter &interpreter); void setExitCodeInterpreter(const std::function<QtcProcess::Result(int)> &interpreter);
// Starts a nested event loop and runs the command // Starts a nested event loop and runs the command
SynchronousProcessResponse run(const CommandLine &cmd, const QByteArray &writeData = {}); void run(const CommandLine &cmd, const QByteArray &writeData = {});
// Starts the command blocking the UI fully // Starts the command blocking the UI fully
SynchronousProcessResponse runBlocking(const CommandLine &cmd); void runBlocking(const CommandLine &cmd);
void setStdOutCallback(const std::function<void(const QString &)> &callback); void setStdOutCallback(const std::function<void(const QString &)> &callback);
void setStdErrCallback(const std::function<void(const QString &)> &callback); void setStdErrCallback(const std::function<void(const QString &)> &callback);
@@ -129,6 +104,24 @@ public:
static QString normalizeNewlines(const QString &text); static QString normalizeNewlines(const QString &text);
Result result() const;
void setResult(Result result);
QByteArray allRawOutput() const;
QString allOutput() const;
QString stdOut() const;
QString stdErr() const;
QByteArray rawStdOut() const;
QByteArray rawStdErr() const;
int exitCode() const;
// Helper to format an exit message.
QString exitMessage(const QString &binary, int timeoutS) const;
// Helpers to find binaries. Do not use it for other path variables // Helpers to find binaries. Do not use it for other path variables
// and file types. // and file types.
static QString locateBinary(const QString &binary); static QString locateBinary(const QString &binary);
@@ -139,13 +132,17 @@ private:
void setupChildProcess() override; void setupChildProcess() override;
#endif #endif
friend class SynchronousProcess; friend class SynchronousProcess;
friend QDebug operator<<(QDebug str, const QtcProcess &r);
Internal::QtcProcessPrivate *d = nullptr; Internal::QtcProcessPrivate *d = nullptr;
void setProcessEnvironment(const QProcessEnvironment &environment) = delete; void setProcessEnvironment(const QProcessEnvironment &environment) = delete;
QProcessEnvironment processEnvironment() const = delete; QProcessEnvironment processEnvironment() const = delete;
}; };
QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug str, const SynchronousProcessResponse &); using ExitCodeInterpreter = std::function<QtcProcess::Result(int /*exitCode*/)>;
QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug str, const QtcProcess &);
class QTCREATOR_UTILS_EXPORT SynchronousProcess : public QtcProcess class QTCREATOR_UTILS_EXPORT SynchronousProcess : public QtcProcess
{ {

View File

@@ -273,13 +273,13 @@ void ShellCommand::run(QFutureInterface<void> &future)
d->m_lastExecSuccess = true; d->m_lastExecSuccess = true;
for (int j = 0; j < count; j++) { for (int j = 0; j < count; j++) {
const Internal::ShellCommandPrivate::Job &job = d->m_jobs.at(j); const Internal::ShellCommandPrivate::Job &job = d->m_jobs.at(j);
SynchronousProcessResponse resp SynchronousProcess proc;
= runCommand(job.command, job.timeoutS, job.workingDirectory, runCommand(proc, job.command, job.timeoutS, job.workingDirectory,
job.exitCodeInterpreter); job.exitCodeInterpreter);
stdOut += resp.stdOut(); stdOut += proc.stdOut();
stdErr += resp.stdErr(); stdErr += proc.stdErr();
d->m_lastExecExitCode = resp.exitCode; d->m_lastExecExitCode = proc.exitCode();
d->m_lastExecSuccess = resp.result == SynchronousProcessResponse::Finished; d->m_lastExecSuccess = proc.result() == QtcProcess::Finished;
if (!d->m_lastExecSuccess) if (!d->m_lastExecSuccess)
break; break;
} }
@@ -306,17 +306,16 @@ void ShellCommand::run(QFutureInterface<void> &future)
this->deleteLater(); this->deleteLater();
} }
SynchronousProcessResponse ShellCommand::runCommand(const CommandLine &command, int timeoutS, void ShellCommand::runCommand(SynchronousProcess &proc,
const QString &workingDirectory, const CommandLine &command, int timeoutS,
const ExitCodeInterpreter &interpreter) const QString &workingDirectory,
const ExitCodeInterpreter &interpreter)
{ {
SynchronousProcessResponse response;
const QString dir = workDirectory(workingDirectory); const QString dir = workDirectory(workingDirectory);
if (command.executable().isEmpty()) { if (command.executable().isEmpty()) {
response.result = SynchronousProcessResponse::StartFailed; proc.setResult(QtcProcess::StartFailed);
return response; return;
} }
QSharedPointer<OutputProxy> proxy(d->m_proxyFactory()); QSharedPointer<OutputProxy> proxy(d->m_proxyFactory());
@@ -327,32 +326,30 @@ SynchronousProcessResponse ShellCommand::runCommand(const CommandLine &command,
if ((d->m_flags & FullySynchronously) if ((d->m_flags & FullySynchronously)
|| (!(d->m_flags & NoFullySync) || (!(d->m_flags & NoFullySync)
&& QThread::currentThread() == QCoreApplication::instance()->thread())) { && QThread::currentThread() == QCoreApplication::instance()->thread())) {
response = runFullySynchronous(command, proxy, timeoutS, dir, interpreter); runFullySynchronous(proc, command, proxy, timeoutS, dir, interpreter);
} else { } else {
response = runSynchronous(command, proxy, timeoutS, dir, interpreter); runSynchronous(proc, command, proxy, timeoutS, dir, interpreter);
} }
if (!d->m_aborted) { if (!d->m_aborted) {
// Success/Fail message in appropriate window? // Success/Fail message in appropriate window?
if (response.result == SynchronousProcessResponse::Finished) { if (proc.result() == QtcProcess::Finished) {
if (d->m_flags & ShowSuccessMessage) if (d->m_flags & ShowSuccessMessage)
emit proxy->appendMessage(response.exitMessage(command.executable().toUserOutput(), timeoutS)); emit proxy->appendMessage(proc.exitMessage(command.executable().toUserOutput(), timeoutS));
} else if (!(d->m_flags & SuppressFailMessage)) { } else if (!(d->m_flags & SuppressFailMessage)) {
emit proxy->appendError(response.exitMessage(command.executable().toUserOutput(), timeoutS)); emit proxy->appendError(proc.exitMessage(command.executable().toUserOutput(), timeoutS));
} }
} }
return response;
} }
SynchronousProcessResponse ShellCommand::runFullySynchronous(const CommandLine &cmd, void ShellCommand::runFullySynchronous(SynchronousProcess &process,
QSharedPointer<OutputProxy> proxy, const CommandLine &cmd,
int timeoutS, QSharedPointer<OutputProxy> proxy,
const QString &workingDirectory, int timeoutS,
const ExitCodeInterpreter &interpreter) const QString &workingDirectory,
const ExitCodeInterpreter &interpreter)
{ {
// Set up process // Set up process
SynchronousProcess process;
if (d->m_disableUnixTerminal) if (d->m_disableUnixTerminal)
process.setDisableUnixTerminal(); process.setDisableUnixTerminal();
const QString dir = workDirectory(workingDirectory); const QString dir = workDirectory(workingDirectory);
@@ -366,14 +363,14 @@ SynchronousProcessResponse ShellCommand::runFullySynchronous(const CommandLine &
process.setTimeoutS(timeoutS); process.setTimeoutS(timeoutS);
process.setExitCodeInterpreter(interpreter); process.setExitCodeInterpreter(interpreter);
SynchronousProcessResponse resp = process.runBlocking(cmd); process.runBlocking(cmd);
if (!d->m_aborted) { if (!d->m_aborted) {
const QString stdErr = resp.stdErr(); const QString stdErr = process.stdErr();
if (!stdErr.isEmpty() && !(d->m_flags & SuppressStdErr)) if (!stdErr.isEmpty() && !(d->m_flags & SuppressStdErr))
emit proxy->append(stdErr); emit proxy->append(stdErr);
const QString stdOut = resp.stdOut(); const QString stdOut = process.stdOut();
if (!stdOut.isEmpty() && d->m_flags & ShowStdOut) { if (!stdOut.isEmpty() && d->m_flags & ShowStdOut) {
if (d->m_flags & SilentOutput) if (d->m_flags & SilentOutput)
emit proxy->appendSilently(stdOut); emit proxy->appendSilently(stdOut);
@@ -381,17 +378,15 @@ SynchronousProcessResponse ShellCommand::runFullySynchronous(const CommandLine &
emit proxy->append(stdOut); emit proxy->append(stdOut);
} }
} }
return resp;
} }
SynchronousProcessResponse ShellCommand::runSynchronous(const CommandLine &cmd, void ShellCommand::runSynchronous(SynchronousProcess &process,
QSharedPointer<OutputProxy> proxy, const CommandLine &cmd,
int timeoutS, QSharedPointer<OutputProxy> proxy,
const QString &workingDirectory, int timeoutS,
const ExitCodeInterpreter &interpreter) const QString &workingDirectory,
const ExitCodeInterpreter &interpreter)
{ {
SynchronousProcess process;
process.setExitCodeInterpreter(interpreter); process.setExitCodeInterpreter(interpreter);
connect(this, &ShellCommand::terminate, &process, &SynchronousProcess::stopProcess); connect(this, &ShellCommand::terminate, &process, &SynchronousProcess::stopProcess);
process.setEnvironment(processEnvironment()); process.setEnvironment(processEnvironment());
@@ -438,7 +433,7 @@ SynchronousProcessResponse ShellCommand::runSynchronous(const CommandLine &cmd,
process.setTimeoutS(timeoutS); process.setTimeoutS(timeoutS);
process.setExitCodeInterpreter(interpreter); process.setExitCodeInterpreter(interpreter);
return process.run(cmd); process.run(cmd);
} }
const QVariant &ShellCommand::cookie() const const QVariant &ShellCommand::cookie() const

View File

@@ -142,10 +142,11 @@ public:
// This is called once per job in a thread. // This is called once per job in a thread.
// When called from the UI thread it will execute fully synchronously, so no signals will // When called from the UI thread it will execute fully synchronously, so no signals will
// be triggered! // be triggered!
virtual SynchronousProcessResponse runCommand(const CommandLine &command, virtual void runCommand(Utils::SynchronousProcess &process,
int timeoutS, const CommandLine &command,
const QString &workingDirectory = QString(), int timeoutS,
const ExitCodeInterpreter &interpreter = {}); const QString &workingDirectory = QString(),
const ExitCodeInterpreter &interpreter = {});
void cancel(); void cancel();
@@ -167,15 +168,17 @@ private:
void run(QFutureInterface<void> &future); void run(QFutureInterface<void> &future);
// Run without a event loop in fully blocking mode. No signals will be delivered. // Run without a event loop in fully blocking mode. No signals will be delivered.
SynchronousProcessResponse runFullySynchronous(const CommandLine &cmd, void runFullySynchronous(SynchronousProcess &proc,
QSharedPointer<OutputProxy> proxy, const CommandLine &cmd,
int timeoutS, const QString &workingDirectory, QSharedPointer<OutputProxy> proxy,
const ExitCodeInterpreter &interpreter = {}); int timeoutS, const QString &workingDirectory,
const ExitCodeInterpreter &interpreter = {});
// Run with an event loop. Signals will be delivered. // Run with an event loop. Signals will be delivered.
SynchronousProcessResponse runSynchronous(const CommandLine &cmd, void runSynchronous(SynchronousProcess &proc,
QSharedPointer<OutputProxy> proxy, const CommandLine &cmd,
int timeoutS, const QString &workingDirectory, QSharedPointer<OutputProxy> proxy,
const ExitCodeInterpreter &interpreter = {}); int timeoutS, const QString &workingDirectory,
const ExitCodeInterpreter &interpreter = {});
class Internal::ShellCommandPrivate *const d; class Internal::ShellCommandPrivate *const d;
}; };

View File

@@ -70,10 +70,10 @@ bool AndroidAvdManager::avdManagerCommand(const AndroidConfig &config, const QSt
Environment env = AndroidConfigurations::toolsEnvironment(config); Environment env = AndroidConfigurations::toolsEnvironment(config);
proc.setEnvironment(env); proc.setEnvironment(env);
qCDebug(avdManagerLog) << "Running AVD Manager command:" << cmd.toUserOutput(); qCDebug(avdManagerLog) << "Running AVD Manager command:" << cmd.toUserOutput();
SynchronousProcessResponse response = proc.runBlocking(cmd); proc.runBlocking(cmd);
if (response.result == Utils::SynchronousProcessResponse::Finished) { if (proc.result() == Utils::QtcProcess::Finished) {
if (output) if (output)
*output = response.allOutput(); *output = proc.allOutput();
return true; return true;
} }
return false; return false;
@@ -199,10 +199,10 @@ bool AndroidAvdManager::removeAvd(const QString &name) const
{ {
const CommandLine command(m_config.avdManagerToolPath(), {"delete", "avd", "-n", name}); const CommandLine command(m_config.avdManagerToolPath(), {"delete", "avd", "-n", name});
qCDebug(avdManagerLog) << "Running command (removeAvd):" << command.toUserOutput(); qCDebug(avdManagerLog) << "Running command (removeAvd):" << command.toUserOutput();
Utils::SynchronousProcess proc; SynchronousProcess proc;
proc.setTimeoutS(5); proc.setTimeoutS(5);
const Utils::SynchronousProcessResponse response = proc.runBlocking(command); proc.runBlocking(command);
return response.result == Utils::SynchronousProcessResponse::Finished && response.exitCode == 0; return proc.result() == QtcProcess::Finished && proc.exitCode() == 0;
} }
static void avdConfigEditManufacturerTag(const QString &avdPathStr, bool recoverMode = false) static void avdConfigEditManufacturerTag(const QString &avdPathStr, bool recoverMode = false)
@@ -350,10 +350,10 @@ bool AndroidAvdManager::isAvdBooted(const QString &device) const
qCDebug(avdManagerLog) << "Running command (isAvdBooted):" << command.toUserOutput(); qCDebug(avdManagerLog) << "Running command (isAvdBooted):" << command.toUserOutput();
SynchronousProcess adbProc; SynchronousProcess adbProc;
adbProc.setTimeoutS(10); adbProc.setTimeoutS(10);
const SynchronousProcessResponse response = adbProc.runBlocking(command); adbProc.runBlocking(command);
if (response.result != Utils::SynchronousProcessResponse::Finished) if (adbProc.result() != QtcProcess::Finished)
return false; return false;
QString value = response.allOutput().trimmed(); QString value = adbProc.allOutput().trimmed();
return value == "stopped"; return value == "stopped";
} }

View File

@@ -1007,14 +1007,13 @@ QAbstractItemModel *AndroidBuildApkStep::keystoreCertificates()
const QStringList params = {"-list", "-v", "-keystore", m_keystorePath.toUserOutput(), const QStringList params = {"-list", "-v", "-keystore", m_keystorePath.toUserOutput(),
"-storepass", m_keystorePasswd, "-J-Duser.language=en"}; "-storepass", m_keystorePasswd, "-J-Duser.language=en"};
Utils::SynchronousProcess keytoolProc; SynchronousProcess keytoolProc;
keytoolProc.setTimeoutS(30); keytoolProc.setTimeoutS(30);
const SynchronousProcessResponse response keytoolProc.run({AndroidConfigurations::currentConfig().keytoolPath(), params});
= keytoolProc.run({AndroidConfigurations::currentConfig().keytoolPath(), params}); if (keytoolProc.result() > QtcProcess::FinishedError)
if (response.result > Utils::SynchronousProcessResponse::FinishedError)
QMessageBox::critical(nullptr, tr("Error"), tr("Failed to run keytool.")); QMessageBox::critical(nullptr, tr("Error"), tr("Failed to run keytool."));
else else
model = new CertificatesModel(response.stdOut(), this); model = new CertificatesModel(keytoolProc.stdOut(), this);
return model; return model;
} }

View File

@@ -159,10 +159,10 @@ namespace {
SynchronousProcess proc; SynchronousProcess proc;
proc.setProcessChannelMode(QProcess::MergedChannels); proc.setProcessChannelMode(QProcess::MergedChannels);
proc.setTimeoutS(30); proc.setTimeoutS(30);
SynchronousProcessResponse response = proc.runBlocking({executable, {shell}}); proc.runBlocking({executable, {shell}});
if (response.result != SynchronousProcessResponse::Finished) if (proc.result() != QtcProcess::Finished)
return true; return true;
return !response.allOutput().contains("x86-64"); return !proc.allOutput().contains("x86-64");
} }
} }
return false; return false;
@@ -561,14 +561,14 @@ QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(const FilePath &adbTo
SynchronousProcess adbProc; SynchronousProcess adbProc;
adbProc.setTimeoutS(30); adbProc.setTimeoutS(30);
CommandLine cmd{adbToolPath, {"devices"}}; CommandLine cmd{adbToolPath, {"devices"}};
SynchronousProcessResponse response = adbProc.runBlocking(cmd); adbProc.runBlocking(cmd);
if (response.result != SynchronousProcessResponse::Finished) { if (adbProc.result() != QtcProcess::Finished) {
if (error) if (error)
*error = QApplication::translate("AndroidConfiguration", "Could not run: %1") *error = QApplication::translate("AndroidConfiguration", "Could not run: %1")
.arg(cmd.toUserOutput()); .arg(cmd.toUserOutput());
return devices; return devices;
} }
QStringList adbDevs = response.allOutput().split('\n', Qt::SkipEmptyParts); QStringList adbDevs = adbProc.allOutput().split('\n', Qt::SkipEmptyParts);
if (adbDevs.empty()) if (adbDevs.empty())
return devices; return devices;
@@ -629,11 +629,11 @@ QString AndroidConfig::getDeviceProperty(const FilePath &adbToolPath, const QStr
SynchronousProcess adbProc; SynchronousProcess adbProc;
adbProc.setTimeoutS(10); adbProc.setTimeoutS(10);
SynchronousProcessResponse response = adbProc.runBlocking(cmd); adbProc.runBlocking(cmd);
if (response.result != SynchronousProcessResponse::Finished) if (adbProc.result() != QtcProcess::Finished)
return QString(); return QString();
return response.allOutput(); return adbProc.allOutput();
} }
int AndroidConfig::getSDKVersion(const FilePath &adbToolPath, const QString &device) int AndroidConfig::getSDKVersion(const FilePath &adbToolPath, const QString &device)
@@ -726,11 +726,11 @@ QStringList AndroidConfig::getAbis(const FilePath &adbToolPath, const QString &d
arguments << "shell" << "getprop" << "ro.product.cpu.abilist"; arguments << "shell" << "getprop" << "ro.product.cpu.abilist";
SynchronousProcess adbProc; SynchronousProcess adbProc;
adbProc.setTimeoutS(10); adbProc.setTimeoutS(10);
SynchronousProcessResponse response = adbProc.runBlocking({adbToolPath, arguments}); adbProc.runBlocking({adbToolPath, arguments});
if (response.result != SynchronousProcessResponse::Finished) if (adbProc.result() != QtcProcess::Finished)
return result; return result;
QString output = response.allOutput().trimmed(); QString output = adbProc.allOutput().trimmed();
if (!output.isEmpty()) { if (!output.isEmpty()) {
QStringList result = output.split(QLatin1Char(',')); QStringList result = output.split(QLatin1Char(','));
if (!result.isEmpty()) if (!result.isEmpty())
@@ -748,11 +748,11 @@ QStringList AndroidConfig::getAbis(const FilePath &adbToolPath, const QString &d
SynchronousProcess abiProc; SynchronousProcess abiProc;
abiProc.setTimeoutS(10); abiProc.setTimeoutS(10);
SynchronousProcessResponse abiResponse = abiProc.runBlocking({adbToolPath, arguments}); abiProc.runBlocking({adbToolPath, arguments});
if (abiResponse.result != SynchronousProcessResponse::Finished) if (abiProc.result() != QtcProcess::Finished)
return result; return result;
QString abi = abiResponse.allOutput().trimmed(); QString abi = abiProc.allOutput().trimmed();
if (abi.isEmpty()) if (abi.isEmpty())
break; break;
result << abi; result << abi;

View File

@@ -198,11 +198,12 @@ void AndroidCreateKeystoreCertificate::buttonBoxAccepted()
SynchronousProcess genKeyCertProc; SynchronousProcess genKeyCertProc;
genKeyCertProc.setTimeoutS(15); genKeyCertProc.setTimeoutS(15);
SynchronousProcessResponse response = genKeyCertProc.run(command); genKeyCertProc.run(command);
if (response.result != Utils::SynchronousProcessResponse::Finished || response.exitCode != 0) { if (genKeyCertProc.result() != QtcProcess::Finished || genKeyCertProc.exitCode() != 0) {
QMessageBox::critical(this, tr("Error"), QMessageBox::critical(this, tr("Error"),
response.exitMessage(command.executable().toString(), 15) + '\n' + response.allOutput()); genKeyCertProc.exitMessage(command.executable().toString(), 15)
+ '\n' + genKeyCertProc.allOutput());
return; return;
} }
accept(); accept();

View File

@@ -481,9 +481,9 @@ void AndroidDeployQtStep::runCommand(const CommandLine &command)
buildProc.setTimeoutS(2 * 60); buildProc.setTimeoutS(2 * 60);
emit addOutput(tr("Package deploy: Running command \"%1\".").arg(command.toUserOutput()), emit addOutput(tr("Package deploy: Running command \"%1\".").arg(command.toUserOutput()),
OutputFormat::NormalMessage); OutputFormat::NormalMessage);
SynchronousProcessResponse response = buildProc.run(command); buildProc.run(command);
if (response.result != SynchronousProcessResponse::Finished || response.exitCode != 0) { if (buildProc.result() != QtcProcess::Finished || buildProc.exitCode() != 0) {
const QString error = response.exitMessage(command.executable().toString(), 2 * 60); const QString error = buildProc.exitMessage(command.executable().toString(), 2 * 60);
emit addOutput(error, OutputFormat::ErrorMessage); emit addOutput(error, OutputFormat::ErrorMessage);
TaskHub::addTask(DeploymentTask(Task::Error, error)); TaskHub::addTask(DeploymentTask(Task::Error, error));
} }

View File

@@ -538,8 +538,8 @@ bool AndroidManager::checkKeystorePassword(const QString &keystorePath, const QS
{"-list", "-keystore", keystorePath, "--storepass", keystorePasswd}); {"-list", "-keystore", keystorePath, "--storepass", keystorePasswd});
SynchronousProcess proc; SynchronousProcess proc;
proc.setTimeoutS(10); proc.setTimeoutS(10);
SynchronousProcessResponse response = proc.run(cmd); proc.run(cmd);
return (response.result == SynchronousProcessResponse::Finished && response.exitCode == 0); return proc.result() == QtcProcess::Finished && proc.exitCode() == 0;
} }
bool AndroidManager::checkCertificatePassword(const QString &keystorePath, const QString &keystorePasswd, const QString &alias, const QString &certificatePasswd) bool AndroidManager::checkCertificatePassword(const QString &keystorePath, const QString &keystorePasswd, const QString &alias, const QString &certificatePasswd)
@@ -554,9 +554,8 @@ bool AndroidManager::checkCertificatePassword(const QString &keystorePath, const
SynchronousProcess proc; SynchronousProcess proc;
proc.setTimeoutS(10); proc.setTimeoutS(10);
SynchronousProcessResponse response proc.run({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
= proc.run({AndroidConfigurations::currentConfig().keytoolPath(), arguments}); return proc.result() == QtcProcess::Finished && proc.exitCode() == 0;
return response.result == SynchronousProcessResponse::Finished && response.exitCode == 0;
} }
bool AndroidManager::checkCertificateExists(const QString &keystorePath, bool AndroidManager::checkCertificateExists(const QString &keystorePath,
@@ -568,9 +567,8 @@ bool AndroidManager::checkCertificateExists(const QString &keystorePath,
SynchronousProcess proc; SynchronousProcess proc;
proc.setTimeoutS(10); proc.setTimeoutS(10);
SynchronousProcessResponse response proc.run({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
= proc.run({AndroidConfigurations::currentConfig().keytoolPath(), arguments}); return proc.result() == QtcProcess::Finished && proc.exitCode() == 0;
return response.result == SynchronousProcessResponse::Finished && response.exitCode == 0;
} }
using GradleProperties = QMap<QByteArray, QByteArray>; using GradleProperties = QMap<QByteArray, QByteArray>;
@@ -724,15 +722,15 @@ SdkToolResult AndroidManager::runCommand(const CommandLine &command,
SynchronousProcess cmdProc; SynchronousProcess cmdProc;
cmdProc.setTimeoutS(timeoutS); cmdProc.setTimeoutS(timeoutS);
qCDebug(androidManagerLog) << "Running command (sync):" << command.toUserOutput(); qCDebug(androidManagerLog) << "Running command (sync):" << command.toUserOutput();
SynchronousProcessResponse response = cmdProc.run(command, writeData); cmdProc.run(command, writeData);
cmdResult.m_stdOut = response.stdOut().trimmed(); cmdResult.m_stdOut = cmdProc.stdOut().trimmed();
cmdResult.m_stdErr = response.stdErr().trimmed(); cmdResult.m_stdErr = cmdProc.stdErr().trimmed();
cmdResult.m_success = response.result == SynchronousProcessResponse::Finished; cmdResult.m_success = cmdProc.result() == QtcProcess::Finished;
qCDebug(androidManagerLog) << "Command finshed (sync):" << command.toUserOutput() qCDebug(androidManagerLog) << "Command finshed (sync):" << command.toUserOutput()
<< "Success:" << cmdResult.m_success << "Success:" << cmdResult.m_success
<< "Output:" << response.allRawOutput(); << "Output:" << cmdProc.allRawOutput();
if (!cmdResult.success()) if (!cmdResult.success())
cmdResult.m_exitMessage = response.exitMessage(command.executable().toString(), timeoutS); cmdResult.m_exitMessage = cmdProc.exitMessage(command.executable().toString(), timeoutS);
return cmdResult; return cmdResult;
} }

View File

@@ -137,7 +137,9 @@ static void findProcessPID(QFutureInterface<qint64> &fi, QStringList selector,
chrono::high_resolution_clock::time_point start = chrono::high_resolution_clock::now(); chrono::high_resolution_clock::time_point start = chrono::high_resolution_clock::now();
do { do {
QThread::msleep(200); QThread::msleep(200);
const auto out = SynchronousProcess().runBlocking({adbPath, args}).allRawOutput(); SynchronousProcess proc;
proc.runBlocking({adbPath, args});
const QByteArray out = proc.allRawOutput();
if (preNougat) { if (preNougat) {
processPID = extractPID(out, packageName); processPID = extractPID(out, packageName);
} else { } else {

View File

@@ -149,10 +149,10 @@ static bool sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
proc.setEnvironment(AndroidConfigurations::toolsEnvironment(config)); proc.setEnvironment(AndroidConfigurations::toolsEnvironment(config));
proc.setTimeoutS(timeout); proc.setTimeoutS(timeout);
proc.setTimeOutMessageBoxEnabled(true); proc.setTimeOutMessageBoxEnabled(true);
SynchronousProcessResponse response = proc.run({config.sdkManagerToolPath(), newArgs}); proc.run({config.sdkManagerToolPath(), newArgs});
if (output) if (output)
*output = response.allOutput(); *output = proc.allOutput();
return response.result == SynchronousProcessResponse::Finished; return proc.result() == QtcProcess::Finished;
} }
/*! /*!
@@ -189,15 +189,15 @@ static void sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
QObject::connect(&sdkManager, &AndroidSdkManager::cancelActiveOperations, QObject::connect(&sdkManager, &AndroidSdkManager::cancelActiveOperations,
&proc, &SynchronousProcess::stopProcess); &proc, &SynchronousProcess::stopProcess);
} }
SynchronousProcessResponse response = proc.run({config.sdkManagerToolPath(), newArgs}); proc.run({config.sdkManagerToolPath(), newArgs});
if (assertionFound) { if (assertionFound) {
output.success = false; output.success = false;
output.stdOutput = response.stdOut(); output.stdOutput = proc.stdOut();
output.stdError = QCoreApplication::translate("Android::Internal::AndroidSdkManager", output.stdError = QCoreApplication::translate("Android::Internal::AndroidSdkManager",
"The operation requires user interaction. " "The operation requires user interaction. "
"Use the \"sdkmanager\" command-line tool."); "Use the \"sdkmanager\" command-line tool.");
} else { } else {
output.success = response.result == SynchronousProcessResponse::Finished; output.success = proc.result() == QtcProcess::Finished;
} }
} }

View File

@@ -111,10 +111,9 @@ static Macros dumpPredefinedMacros(const FilePath &compiler, const QStringList &
cmd.addArg("--predef_macros"); cmd.addArg("--predef_macros");
cmd.addArg(outpath); cmd.addArg(outpath);
const SynchronousProcessResponse response = cpp.runBlocking(cmd); cpp.runBlocking(cmd);
if (response.result != SynchronousProcessResponse::Finished if (cpp.result() != QtcProcess::Finished || cpp.exitCode() != 0) {
|| response.exitCode != 0) { qWarning() << cpp.exitMessage(cmd.toUserOutput(), 10);
qWarning() << response.exitMessage(cmd.toUserOutput(), 10);
return {}; return {};
} }
@@ -157,11 +156,11 @@ static HeaderPaths dumpHeaderPaths(const FilePath &compiler, const Id languageId
cmd.addArg("."); cmd.addArg(".");
// Note: Response should retutn an error, just don't check on errors. // Note: Response should retutn an error, just don't check on errors.
const SynchronousProcessResponse response = cpp.runBlocking(cmd); cpp.runBlocking(cmd);
HeaderPaths headerPaths; HeaderPaths headerPaths;
const QByteArray output = response.allOutput().toUtf8(); const QByteArray output = cpp.allOutput().toUtf8();
for (auto pos = 0; pos < output.size(); ++pos) { for (auto pos = 0; pos < output.size(); ++pos) {
const int searchIndex = output.indexOf("searched:", pos); const int searchIndex = output.indexOf("searched:", pos);
if (searchIndex == -1) if (searchIndex == -1)

View File

@@ -140,8 +140,8 @@ static Macros dumpMcsPredefinedMacros(const FilePath &compiler, const Environmen
cpp.setTimeoutS(10); cpp.setTimeoutS(10);
const CommandLine cmd(compiler, {fakeIn.fileName()}); const CommandLine cmd(compiler, {fakeIn.fileName()});
const SynchronousProcessResponse response = cpp.runBlocking(cmd); cpp.runBlocking(cmd);
QString output = response.allOutput(); QString output = cpp.allOutput();
Macros macros; Macros macros;
QTextStream stream(&output); QTextStream stream(&output);
QString line; QString line;
@@ -269,8 +269,8 @@ static Macros dumpC166PredefinedMacros(const FilePath &compiler, const Environme
}; };
const CommandLine cmd(compiler, {fakeIn.fileName()}); const CommandLine cmd(compiler, {fakeIn.fileName()});
const SynchronousProcessResponse response = cpp.runBlocking(cmd); cpp.runBlocking(cmd);
const QString output = response.allOutput(); const QString output = cpp.allOutput();
extractMacros(output); extractMacros(output);
return macros; return macros;
} }
@@ -286,14 +286,13 @@ static Macros dumpArmPredefinedMacros(const FilePath &compiler, const QStringLis
args.push_back("--list-macros"); args.push_back("--list-macros");
const CommandLine cmd(compiler, args); const CommandLine cmd(compiler, args);
const SynchronousProcessResponse response = cpp.runBlocking(cmd); cpp.runBlocking(cmd);
if (response.result != SynchronousProcessResponse::Finished if (cpp.result() != QtcProcess::Finished || cpp.exitCode() != 0) {
|| response.exitCode != 0) { qWarning() << cpp.exitMessage(compiler.toString(), 10);
qWarning() << response.exitMessage(compiler.toString(), 10);
return {}; return {};
} }
const QByteArray output = response.allOutput().toUtf8(); const QByteArray output = cpp.allOutput().toUtf8();
return Macro::toMacros(output); return Macro::toMacros(output);
} }

View File

@@ -93,14 +93,13 @@ static Macros dumpPredefinedMacros(const FilePath &compiler, const Environment &
const CommandLine cmd(compiler, {compilerTargetFlag(abi), "-dM", "-E", fakeIn.fileName()}); const CommandLine cmd(compiler, {compilerTargetFlag(abi), "-dM", "-E", fakeIn.fileName()});
const SynchronousProcessResponse response = cpp.runBlocking(cmd); cpp.runBlocking(cmd);
if (response.result != SynchronousProcessResponse::Finished if (cpp.result() != QtcProcess::Finished || cpp.exitCode() != 0) {
|| response.exitCode != 0) { qWarning() << cpp.exitMessage(compiler.toString(), 10);
qWarning() << response.exitMessage(compiler.toString(), 10);
return {}; return {};
} }
const QByteArray output = response.allOutput().toUtf8(); const QByteArray output = cpp.allOutput().toUtf8();
return Macro::toMacros(output); return Macro::toMacros(output);
} }
@@ -116,14 +115,13 @@ static HeaderPaths dumpHeaderPaths(const FilePath &compiler, const Environment &
const CommandLine cmd(compiler, {compilerTargetFlag(abi), "--print-search-dirs"}); const CommandLine cmd(compiler, {compilerTargetFlag(abi), "--print-search-dirs"});
const SynchronousProcessResponse response = cpp.runBlocking(cmd); cpp.runBlocking(cmd);
if (response.result != SynchronousProcessResponse::Finished if (cpp.result() != QtcProcess::Finished || cpp.exitCode() != 0) {
|| response.exitCode != 0) { qWarning() << cpp.exitMessage(compiler.toString(), 10);
qWarning() << response.exitMessage(compiler.toString(), 10);
return {}; return {};
} }
QString output = response.allOutput(); QString output = cpp.allOutput();
HeaderPaths headerPaths; HeaderPaths headerPaths;
QTextStream in(&output); QTextStream in(&output);
QString line; QString line;

View File

@@ -150,9 +150,10 @@ bool BazaarClient::synchronousUncommit(const QString &workingDir,
<< revisionSpec(revision) << revisionSpec(revision)
<< extraOptions; << extraOptions;
const SynchronousProcessResponse result = vcsFullySynchronousExec(workingDir, args); SynchronousProcess proc;
VcsOutputWindow::append(result.stdOut()); vcsFullySynchronousExec(proc, workingDir, args);
return result.result == SynchronousProcessResponse::Finished; VcsOutputWindow::append(proc.stdOut());
return proc.result() == QtcProcess::Finished;
} }
void BazaarClient::commit(const QString &repositoryRoot, const QStringList &files, void BazaarClient::commit(const QString &repositoryRoot, const QStringList &files,
@@ -190,10 +191,11 @@ bool BazaarClient::managesFile(const QString &workingDirectory, const QString &f
QStringList args(QLatin1String("status")); QStringList args(QLatin1String("status"));
args << fileName; args << fileName;
const SynchronousProcessResponse result = vcsFullySynchronousExec(workingDirectory, args); SynchronousProcess proc;
if (result.result != SynchronousProcessResponse::Finished) vcsFullySynchronousExec(proc, workingDirectory, args);
if (proc.result() != QtcProcess::Finished)
return false; return false;
return result.rawStdOut.startsWith("unknown"); return proc.rawStdOut().startsWith("unknown");
} }
void BazaarClient::view(const QString &source, const QString &id, const QStringList &extraOptions) void BazaarClient::view(const QString &source, const QString &id, const QStringList &extraOptions)
@@ -231,8 +233,8 @@ ExitCodeInterpreter BazaarClient::exitCodeInterpreter(VcsCommandTag cmd) const
{ {
if (cmd == DiffCommand) { if (cmd == DiffCommand) {
return [](int code) { return [](int code) {
return (code < 0 || code > 2) ? SynchronousProcessResponse::FinishedError return (code < 0 || code > 2) ? QtcProcess::FinishedError
: SynchronousProcessResponse::Finished; : QtcProcess::Finished;
}; };
} }
return {}; return {};

View File

@@ -84,15 +84,15 @@ static int parseVersion(const QString &text)
static int updateVersionHelper(const Utils::FilePath &command) static int updateVersionHelper(const Utils::FilePath &command)
{ {
Utils::SynchronousProcess process; Utils::SynchronousProcess process;
Utils::SynchronousProcessResponse response = process.runBlocking({command, {"--version"}}); process.runBlocking({command, {"--version"}});
if (response.result != Utils::SynchronousProcessResponse::Finished) if (process.result() != Utils::QtcProcess::Finished)
return 0; return 0;
// Astyle prints the version on stdout or stderr, depending on platform // Astyle prints the version on stdout or stderr, depending on platform
const int version = parseVersion(response.stdOut().trimmed()); const int version = parseVersion(process.stdOut().trimmed());
if (version != 0) if (version != 0)
return version; return version;
return parseVersion(response.stdErr().trimmed()); return parseVersion(process.stdErr().trimmed());
} }
void ArtisticStyleSettings::updateVersion() void ArtisticStyleSettings::updateVersion()
@@ -181,8 +181,8 @@ void ArtisticStyleSettings::createDocumentationFile() const
{ {
Utils::SynchronousProcess process; Utils::SynchronousProcess process;
process.setTimeoutS(2); process.setTimeoutS(2);
Utils::SynchronousProcessResponse response = process.runBlocking({command(), {"-h"}}); process.runBlocking({command(), {"-h"}});
if (response.result != Utils::SynchronousProcessResponse::Finished) if (process.result() != Utils::QtcProcess::Finished)
return; return;
QFile file(documentationFilePath()); QFile file(documentationFilePath());
@@ -200,7 +200,7 @@ void ArtisticStyleSettings::createDocumentationFile() const
stream.writeStartElement(Constants::DOCUMENTATION_XMLROOT); stream.writeStartElement(Constants::DOCUMENTATION_XMLROOT);
// astyle writes its output to 'error'... // astyle writes its output to 'error'...
const QStringList lines = response.stdErr().split(QLatin1Char('\n')); const QStringList lines = process.stdErr().split(QLatin1Char('\n'));
QStringList keys; QStringList keys;
QStringList docu; QStringList docu;
for (QString line : lines) { for (QString line : lines) {

View File

@@ -150,9 +150,8 @@ void UncrustifySettings::createDocumentationFile() const
{ {
Utils::SynchronousProcess process; Utils::SynchronousProcess process;
process.setTimeoutS(2); process.setTimeoutS(2);
Utils::SynchronousProcessResponse response process.runBlocking({command(), {"--show-config"}});
= process.runBlocking({command(), {"--show-config"}}); if (process.result() != Utils::QtcProcess::Finished)
if (response.result != Utils::SynchronousProcessResponse::Finished)
return; return;
QFile file(documentationFilePath()); QFile file(documentationFilePath());
@@ -169,7 +168,7 @@ void UncrustifySettings::createDocumentationFile() const
stream.writeComment("Created " + QDateTime::currentDateTime().toString(Qt::ISODate)); stream.writeComment("Created " + QDateTime::currentDateTime().toString(Qt::ISODate));
stream.writeStartElement(Constants::DOCUMENTATION_XMLROOT); stream.writeStartElement(Constants::DOCUMENTATION_XMLROOT);
const QStringList lines = response.allOutput().split(QLatin1Char('\n')); const QStringList lines = process.allOutput().split(QLatin1Char('\n'));
const int totalLines = lines.count(); const int totalLines = lines.count();
for (int i = 0; i < totalLines; ++i) { for (int i = 0; i < totalLines; ++i) {
const QString &line = lines.at(i); const QString &line = lines.at(i);

View File

@@ -108,9 +108,8 @@ bool ClangToolRunner::supportsVFSOverlay() const
auto it = vfsCapabilities.find(m_executable); auto it = vfsCapabilities.find(m_executable);
if (it == vfsCapabilities.end()) { if (it == vfsCapabilities.end()) {
Utils::SynchronousProcess p; Utils::SynchronousProcess p;
Utils::SynchronousProcessResponse response = p.runBlocking( p.runBlocking(Utils::CommandLine(m_executable, {"--help"}));
Utils::CommandLine(m_executable, {"--help"})); it = vfsCapabilities.insert(m_executable, p.allOutput().contains("vfsoverlay"));
it = vfsCapabilities.insert(m_executable, response.allOutput().contains("vfsoverlay"));
} }
return it.value(); return it.value();
} }

View File

@@ -55,16 +55,16 @@ static QString runExecutable(const Utils::CommandLine &commandLine,
Environment::setupEnglishOutput(&env); Environment::setupEnglishOutput(&env);
cpp.setEnvironment(env); cpp.setEnvironment(env);
const SynchronousProcessResponse response = cpp.runBlocking(commandLine); cpp.runBlocking(commandLine);
if (response.result != SynchronousProcessResponse::Finished if (cpp.result() != QtcProcess::Finished
&& (failSilently == FailSilently::No && (failSilently == FailSilently::No
|| response.result != SynchronousProcessResponse::FinishedError)) { || cpp.result() != QtcProcess::FinishedError)) {
Core::MessageManager::writeFlashing(response.exitMessage(commandLine.toUserOutput(), 10)); Core::MessageManager::writeFlashing(cpp.exitMessage(commandLine.toUserOutput(), 10));
Core::MessageManager::writeFlashing(QString::fromUtf8(response.allRawOutput())); Core::MessageManager::writeFlashing(QString::fromUtf8(cpp.allRawOutput()));
return {}; return {};
} }
return response.stdOut(); return cpp.stdOut();
} }
static QStringList queryClangTidyChecks(const QString &executable, static QStringList queryClangTidyChecks(const QString &executable,

View File

@@ -1667,17 +1667,18 @@ ClearCasePluginPrivate::runCleartool(const QString &workingDir,
return response; return response;
} }
const SynchronousProcessResponse sp_resp = SynchronousProcess proc;
VcsBase::runVcs(workingDir,
{executable, arguments},
timeOutS,
flags, outputCodec);
response.error = sp_resp.result != SynchronousProcessResponse::Finished; VcsCommand command(workingDir, Environment::systemEnvironment());
command.addFlags(flags);
command.setCodec(outputCodec);
command.runCommand(proc, {executable, arguments}, timeOutS);
response.error = proc.result() != QtcProcess::Finished;
if (response.error) if (response.error)
response.message = sp_resp.exitMessage(executable, timeOutS); response.message = proc.exitMessage(executable, timeOutS);
response.stdErr = sp_resp.stdErr(); response.stdErr = proc.stdErr();
response.stdOut = sp_resp.stdOut(); response.stdOut = proc.stdOut();
return response; return response;
} }
@@ -2356,10 +2357,10 @@ QString ClearCasePluginPrivate::runExtDiff(const QString &workingDir, const QStr
process.setTimeoutS(timeOutS); process.setTimeoutS(timeOutS);
process.setWorkingDirectory(workingDir); process.setWorkingDirectory(workingDir);
process.setCodec(outputCodec ? outputCodec : QTextCodec::codecForName("UTF-8")); process.setCodec(outputCodec ? outputCodec : QTextCodec::codecForName("UTF-8"));
SynchronousProcessResponse response = process.run(diff); process.run(diff);
if (response.result != SynchronousProcessResponse::Finished) if (process.result() != QtcProcess::Finished)
return QString(); return QString();
return response.allOutput(); return process.allOutput();
} }
void ClearCasePluginPrivate::syncSlot() void ClearCasePluginPrivate::syncSlot()

View File

@@ -189,9 +189,8 @@ bool CMakeTool::isValid() const
return m_introspection->m_didRun && !m_introspection->m_fileApis.isEmpty(); return m_introspection->m_didRun && !m_introspection->m_fileApis.isEmpty();
} }
Utils::SynchronousProcessResponse CMakeTool::run(const QStringList &args, int timeoutS) const void CMakeTool::runCMake(Utils::SynchronousProcess &cmake, const QStringList &args, int timeoutS) const
{ {
Utils::SynchronousProcess cmake;
cmake.setTimeoutS(timeoutS); cmake.setTimeoutS(timeoutS);
cmake.setDisableUnixTerminal(); cmake.setDisableUnixTerminal();
Utils::Environment env = Utils::Environment::systemEnvironment(); Utils::Environment env = Utils::Environment::systemEnvironment();
@@ -199,7 +198,7 @@ Utils::SynchronousProcessResponse CMakeTool::run(const QStringList &args, int ti
cmake.setEnvironment(env); cmake.setEnvironment(env);
cmake.setTimeOutMessageBoxEnabled(false); cmake.setTimeOutMessageBoxEnabled(false);
return cmake.runBlocking({cmakeExecutable(), args}); cmake.runBlocking({cmakeExecutable(), args});
} }
QVariantMap CMakeTool::toMap() const QVariantMap CMakeTool::toMap() const
@@ -280,22 +279,22 @@ TextEditor::Keywords CMakeTool::keywords()
return {}; return {};
if (m_introspection->m_functions.isEmpty() && m_introspection->m_didRun) { if (m_introspection->m_functions.isEmpty() && m_introspection->m_didRun) {
Utils::SynchronousProcessResponse response; Utils::SynchronousProcess proc;
response = run({"--help-command-list"}, 5); runCMake(proc, {"--help-command-list"}, 5);
if (response.result == Utils::SynchronousProcessResponse::Finished) if (proc.result() == Utils::QtcProcess::Finished)
m_introspection->m_functions = response.stdOut().split('\n'); m_introspection->m_functions = proc.stdOut().split('\n');
response = run({"--help-commands"}, 5); runCMake(proc, {"--help-commands"}, 5);
if (response.result == Utils::SynchronousProcessResponse::Finished) if (proc.result() == Utils::QtcProcess::Finished)
parseFunctionDetailsOutput(response.stdOut()); parseFunctionDetailsOutput(proc.stdOut());
response = run({"--help-property-list"}, 5); runCMake(proc, {"--help-property-list"}, 5);
if (response.result == Utils::SynchronousProcessResponse::Finished) if (proc.result() == Utils::QtcProcess::Finished)
m_introspection->m_variables = parseVariableOutput(response.stdOut()); m_introspection->m_variables = parseVariableOutput(proc.stdOut());
response = run({"--help-variable-list"}, 5); runCMake(proc, {"--help-variable-list"}, 5);
if (response.result == Utils::SynchronousProcessResponse::Finished) { if (proc.result() == Utils::QtcProcess::Finished) {
m_introspection->m_variables.append(parseVariableOutput(response.stdOut())); m_introspection->m_variables.append(parseVariableOutput(proc.stdOut()));
m_introspection->m_variables = Utils::filteredUnique(m_introspection->m_variables); m_introspection->m_variables = Utils::filteredUnique(m_introspection->m_variables);
Utils::sort(m_introspection->m_variables); Utils::sort(m_introspection->m_variables);
} }
@@ -486,11 +485,12 @@ QStringList CMakeTool::parseVariableOutput(const QString &output)
void CMakeTool::fetchFromCapabilities() const void CMakeTool::fetchFromCapabilities() const
{ {
Utils::SynchronousProcessResponse response = run({"-E", "capabilities"}); Utils::SynchronousProcess cmake;
runCMake(cmake, {"-E", "capabilities"});
if (response.result == Utils::SynchronousProcessResponse::Finished) { if (cmake.result() == Utils::QtcProcess::Finished) {
m_introspection->m_didRun = true; m_introspection->m_didRun = true;
parseFromCapabilities(response.stdOut()); parseFromCapabilities(cmake.stdOut());
} else { } else {
m_introspection->m_didRun = false; m_introspection->m_didRun = false;
} }

View File

@@ -116,7 +116,7 @@ public:
private: private:
void readInformation() const; void readInformation() const;
Utils::SynchronousProcessResponse run(const QStringList &args, int timeoutS = 1) const; void runCMake(Utils::SynchronousProcess &proc, const QStringList &args, int timeoutS = 1) const;
void parseFunctionDetailsOutput(const QString &output); void parseFunctionDetailsOutput(const QString &output);
QStringList parseVariableOutput(const QString &output); QStringList parseVariableOutput(const QString &output);

View File

@@ -204,8 +204,8 @@ public:
{ {
if (cmd == DiffCommand) { if (cmd == DiffCommand) {
return [](int code) { return [](int code) {
return (code < 0 || code > 2) ? SynchronousProcessResponse::FinishedError return (code < 0 || code > 2) ? QtcProcess::FinishedError
: SynchronousProcessResponse::Finished; : QtcProcess::Finished;
}; };
} }
return {}; return {};
@@ -1446,28 +1446,31 @@ CvsResponse CvsPluginPrivate::runCvs(const QString &workingDirectory,
return response; return response;
} }
// Run, connect stderr to the output window // Run, connect stderr to the output window
const SynchronousProcessResponse sp_resp = SynchronousProcess proc;
runVcs(workingDirectory, {executable, m_settings.addOptions(arguments)},
timeOutS, flags, outputCodec); VcsCommand command(workingDirectory, Environment::systemEnvironment());
command.addFlags(flags);
command.setCodec(outputCodec);
command.runCommand(proc, {executable, m_settings.addOptions(arguments)}, timeOutS);
response.result = CvsResponse::OtherError; response.result = CvsResponse::OtherError;
response.stdErr = sp_resp.stdErr(); response.stdErr = proc.stdErr();
response.stdOut = sp_resp.stdOut(); response.stdOut = proc.stdOut();
switch (sp_resp.result) { switch (proc.result()) {
case SynchronousProcessResponse::Finished: case QtcProcess::Finished:
response.result = CvsResponse::Ok; response.result = CvsResponse::Ok;
break; break;
case SynchronousProcessResponse::FinishedError: case QtcProcess::FinishedError:
response.result = CvsResponse::NonNullExitCode; response.result = CvsResponse::NonNullExitCode;
break; break;
case SynchronousProcessResponse::TerminatedAbnormally: case QtcProcess::TerminatedAbnormally:
case SynchronousProcessResponse::StartFailed: case QtcProcess::StartFailed:
case SynchronousProcessResponse::Hang: case QtcProcess::Hang:
break; break;
} }
if (response.result != CvsResponse::Ok) if (response.result != CvsResponse::Ok)
response.message = sp_resp.exitMessage(executable.toString(), timeOutS); response.message = proc.exitMessage(executable.toString(), timeOutS);
return response; return response;
} }

View File

@@ -69,11 +69,10 @@ const char DEBUGGER_INFORMATION_WORKINGDIRECTORY[] = "WorkingDirectory";
static QString getConfigurationOfGdbCommand(const FilePath &command, const Utils::Environment &sysEnv) static QString getConfigurationOfGdbCommand(const FilePath &command, const Utils::Environment &sysEnv)
{ {
// run gdb with the --configuration opion // run gdb with the --configuration opion
Utils::SynchronousProcess gdbConfigurationCall; SynchronousProcess proc;
gdbConfigurationCall.setEnvironment(sysEnv); proc.setEnvironment(sysEnv);
Utils::SynchronousProcessResponse output = proc.runBlocking({command, {"--configuration"}});
gdbConfigurationCall.runBlocking({command, {"--configuration"}}); return proc.allOutput();
return output.allOutput();
} }
//! Extract the target ABI identifier from GDB output //! Extract the target ABI identifier from GDB output
@@ -186,13 +185,13 @@ void DebuggerItem::reinitializeFromFile(const Utils::Environment &sysEnv)
SynchronousProcess proc; SynchronousProcess proc;
proc.setEnvironment(sysEnv); proc.setEnvironment(sysEnv);
SynchronousProcessResponse response = proc.runBlocking({m_command, {version}}); proc.runBlocking({m_command, {version}});
if (response.result != SynchronousProcessResponse::Finished) { if (proc.result() != QtcProcess::Finished) {
m_engineType = NoEngineType; m_engineType = NoEngineType;
return; return;
} }
m_abis.clear(); m_abis.clear();
const QString output = response.allOutput().trimmed(); const QString output = proc.allOutput().trimmed();
if (output.contains("gdb")) { if (output.contains("gdb")) {
m_engineType = GdbEngineType; m_engineType = GdbEngineType;

View File

@@ -743,11 +743,11 @@ void DebuggerItemManagerPrivate::autoDetectGdbOrLldbDebuggers()
FilePaths suspects; FilePaths suspects;
if (HostOsInfo::isMacHost()) { if (HostOsInfo::isMacHost()) {
SynchronousProcess lldbInfo; SynchronousProcess proc;
lldbInfo.setTimeoutS(2); proc.setTimeoutS(2);
SynchronousProcessResponse response = lldbInfo.runBlocking({"xcrun", {"--find", "lldb"}}); proc.runBlocking({"xcrun", {"--find", "lldb"}});
if (response.result == Utils::SynchronousProcessResponse::Finished) { if (proc.result() == QtcProcess::Finished) {
QString lPath = response.allOutput().trimmed(); QString lPath = proc.allOutput().trimmed();
if (!lPath.isEmpty()) { if (!lPath.isEmpty()) {
const QFileInfo fi(lPath); const QFileInfo fi(lPath);
if (fi.exists() && fi.isExecutable() && !fi.isDir()) if (fi.exists() && fi.isExecutable() && !fi.isDir())

View File

@@ -4978,10 +4978,10 @@ CoreInfo CoreInfo::readExecutableNameFromCore(const Runnable &debugger, const QS
Environment envLang(QProcess::systemEnvironment()); Environment envLang(QProcess::systemEnvironment());
Environment::setupEnglishOutput(&envLang); Environment::setupEnglishOutput(&envLang);
proc.setEnvironment(envLang); proc.setEnvironment(envLang);
SynchronousProcessResponse response = proc.runBlocking({debugger.executable, args}); proc.runBlocking({debugger.executable, args});
if (response.result == SynchronousProcessResponse::Finished) { if (proc.result() == QtcProcess::Finished) {
QString output = response.stdOut(); QString output = proc.stdOut();
// Core was generated by `/data/dev/creator-2.6/bin/qtcreator'. // Core was generated by `/data/dev/creator-2.6/bin/qtcreator'.
// Program terminated with signal 11, Segmentation fault. // Program terminated with signal 11, Segmentation fault.
int pos1 = output.indexOf("Core was generated by"); int pos1 = output.indexOf("Core was generated by");

View File

@@ -244,11 +244,11 @@ int GerritServer::testConnection()
{ {
static GitClient *const client = GitClient::instance(); static GitClient *const client = GitClient::instance();
const QStringList arguments = curlArguments() << (url(RestUrl) + accountUrlC); const QStringList arguments = curlArguments() << (url(RestUrl) + accountUrlC);
const SynchronousProcessResponse resp = client->vcsFullySynchronousExec( SynchronousProcess proc;
QString(), {curlBinary, arguments}, client->vcsFullySynchronousExec(proc, QString(), {curlBinary, arguments},
Core::ShellCommand::NoOutput); Core::ShellCommand::NoOutput);
if (resp.result == SynchronousProcessResponse::Finished) { if (proc.result() == QtcProcess::Finished) {
QString output = resp.stdOut(); QString output = proc.stdOut();
// Gerrit returns an empty response for /p/qt-creator/a/accounts/self // Gerrit returns an empty response for /p/qt-creator/a/accounts/self
// so consider this as 404. // so consider this as 404.
if (output.isEmpty()) if (output.isEmpty())
@@ -264,10 +264,10 @@ int GerritServer::testConnection()
} }
return Success; return Success;
} }
if (resp.exitCode == CertificateError) if (proc.exitCode() == CertificateError)
return CertificateError; return CertificateError;
const QRegularExpression errorRegexp("returned error: (\\d+)"); const QRegularExpression errorRegexp("returned error: (\\d+)");
QRegularExpressionMatch match = errorRegexp.match(resp.stdErr()); QRegularExpressionMatch match = errorRegexp.match(proc.stdErr());
if (match.hasMatch()) if (match.hasMatch())
return match.captured(1).toInt(); return match.captured(1).toInt();
return UnknownError; return UnknownError;
@@ -341,26 +341,25 @@ void GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
if (!version.isEmpty() && !forceReload) if (!version.isEmpty() && !forceReload)
return; return;
if (type == Ssh) { if (type == Ssh) {
SynchronousProcess process; SynchronousProcess proc;
QStringList arguments; QStringList arguments;
if (port) if (port)
arguments << p.portFlag << QString::number(port); arguments << p.portFlag << QString::number(port);
arguments << hostArgument() << "gerrit" << "version"; arguments << hostArgument() << "gerrit" << "version";
const SynchronousProcessResponse resp = client->vcsFullySynchronousExec( client->vcsFullySynchronousExec(proc, QString(), {p.ssh, arguments},
QString(), {p.ssh, arguments}, Core::ShellCommand::NoOutput);
Core::ShellCommand::NoOutput); QString stdOut = proc.stdOut().trimmed();
QString stdOut = resp.stdOut().trimmed();
stdOut.remove("gerrit version "); stdOut.remove("gerrit version ");
version = stdOut; version = stdOut;
} else { } else {
const QStringList arguments = curlArguments() << (url(RestUrl) + versionUrlC); const QStringList arguments = curlArguments() << (url(RestUrl) + versionUrlC);
const SynchronousProcessResponse resp = client->vcsFullySynchronousExec( SynchronousProcess proc;
QString(), {curlBinary, arguments}, client->vcsFullySynchronousExec(proc, QString(), {curlBinary, arguments},
Core::ShellCommand::NoOutput); Core::ShellCommand::NoOutput);
// REST endpoint for version is only available from 2.8 and up. Do not consider invalid // REST endpoint for version is only available from 2.8 and up. Do not consider invalid
// if it fails. // if it fails.
if (resp.result == SynchronousProcessResponse::Finished) { if (proc.result() == QtcProcess::Finished) {
QString output = resp.stdOut(); QString output = proc.stdOut();
if (output.isEmpty()) if (output.isEmpty())
return; return;
output.remove(0, output.indexOf('\n')); // Strip first line output.remove(0, output.indexOf('\n')); // Strip first line

View File

@@ -669,16 +669,16 @@ public:
connect(command, &VcsCommand::stdErrText, handler, &ConflictHandler::readStdErr); connect(command, &VcsCommand::stdErrText, handler, &ConflictHandler::readStdErr);
} }
static void handleResponse(const Utils::SynchronousProcessResponse &response, static void handleResponse(const Utils::SynchronousProcess &proc,
const QString &workingDirectory, const QString &workingDirectory,
const QString &abortCommand = QString()) const QString &abortCommand = QString())
{ {
ConflictHandler handler(workingDirectory, abortCommand); ConflictHandler handler(workingDirectory, abortCommand);
// No conflicts => do nothing // No conflicts => do nothing
if (response.result == SynchronousProcessResponse::Finished) if (proc.result() == QtcProcess::Finished)
return; return;
handler.readStdOut(response.stdOut()); handler.readStdOut(proc.stdOut());
handler.readStdErr(response.stdErr()); handler.readStdErr(proc.stdErr());
} }
private: private:
@@ -838,9 +838,10 @@ QString GitClient::findGitDirForRepository(const QString &repositoryDir) const
bool GitClient::managesFile(const QString &workingDirectory, const QString &fileName) const bool GitClient::managesFile(const QString &workingDirectory, const QString &fileName) const
{ {
return vcsFullySynchronousExec(workingDirectory, {"ls-files", "--error-unmatch", fileName}, SynchronousProcess proc;
Core::ShellCommand::NoOutput).result vcsFullySynchronousExec(proc, workingDirectory, {"ls-files", "--error-unmatch", fileName},
== SynchronousProcessResponse::Finished; Core::ShellCommand::NoOutput);
return proc.result() == QtcProcess::Finished;
} }
QStringList GitClient::unmanagedFiles(const QStringList &filePaths) const QStringList GitClient::unmanagedFiles(const QStringList &filePaths) const
@@ -855,12 +856,12 @@ QStringList GitClient::unmanagedFiles(const QStringList &filePaths) const
QStringList args({"ls-files", "-z"}); QStringList args({"ls-files", "-z"});
const QDir wd(it.key()); const QDir wd(it.key());
args << transform(it.value(), [&wd](const QString &fp) { return wd.relativeFilePath(fp); }); args << transform(it.value(), [&wd](const QString &fp) { return wd.relativeFilePath(fp); });
const SynchronousProcessResponse response SynchronousProcess proc;
= vcsFullySynchronousExec(it.key(), args, Core::ShellCommand::NoOutput); vcsFullySynchronousExec(proc, it.key(), args, Core::ShellCommand::NoOutput);
if (response.result != SynchronousProcessResponse::Finished) if (proc.result() != QtcProcess::Finished)
return filePaths; return filePaths;
const QStringList managedFilePaths const QStringList managedFilePaths
= transform(response.stdOut().split('\0', Qt::SkipEmptyParts), = transform(proc.stdOut().split('\0', Qt::SkipEmptyParts),
[&wd](const QString &fp) { return wd.absoluteFilePath(fp); }); [&wd](const QString &fp) { return wd.absoluteFilePath(fp); });
res += filtered(it.value(), [&managedFilePaths, &wd](const QString &fp) { res += filtered(it.value(), [&managedFilePaths, &wd](const QString &fp) {
return !managedFilePaths.contains(wd.absoluteFilePath(fp)); return !managedFilePaths.contains(wd.absoluteFilePath(fp));
@@ -1423,11 +1424,11 @@ void GitClient::removeStaleRemoteBranches(const QString &workingDirectory, const
void GitClient::recoverDeletedFiles(const QString &workingDirectory) void GitClient::recoverDeletedFiles(const QString &workingDirectory)
{ {
const SynchronousProcessResponse response = SynchronousProcess proc;
vcsFullySynchronousExec(workingDirectory, {"ls-files", "--deleted"}, vcsFullySynchronousExec(proc, workingDirectory, {"ls-files", "--deleted"},
VcsCommand::SuppressCommandLogging); VcsCommand::SuppressCommandLogging);
if (response.result == SynchronousProcessResponse::Finished) { if (proc.result() == QtcProcess::Finished) {
const QString stdOut = response.stdOut().trimmed(); const QString stdOut = proc.stdOut().trimmed();
if (stdOut.isEmpty()) { if (stdOut.isEmpty()) {
VcsOutputWindow::appendError(tr("Nothing to recover")); VcsOutputWindow::appendError(tr("Nothing to recover"));
return; return;
@@ -1450,15 +1451,15 @@ bool GitClient::synchronousLog(const QString &workingDirectory, const QStringLis
allArguments.append(arguments); allArguments.append(arguments);
const SynchronousProcessResponse resp = vcsFullySynchronousExec( SynchronousProcess proc;
workingDirectory, allArguments, flags, vcsTimeoutS(), vcsFullySynchronousExec(proc, workingDirectory, allArguments, flags, vcsTimeoutS(),
encoding(workingDirectory, "i18n.logOutputEncoding")); encoding(workingDirectory, "i18n.logOutputEncoding"));
if (resp.result == SynchronousProcessResponse::Finished) { if (proc.result() == QtcProcess::Finished) {
*output = resp.stdOut(); *output = proc.stdOut();
return true; return true;
} else { } else {
msgCannotRun(tr("Cannot obtain log of \"%1\": %2") msgCannotRun(tr("Cannot obtain log of \"%1\": %2")
.arg(QDir::toNativeSeparators(workingDirectory), resp.stdErr()), errorMessageIn); .arg(QDir::toNativeSeparators(workingDirectory), proc.stdErr()), errorMessageIn);
return false; return false;
} }
} }
@@ -1469,7 +1470,9 @@ bool GitClient::synchronousAdd(const QString &workingDirectory,
{ {
QStringList args{"add"}; QStringList args{"add"};
args += extraOptions + files; args += extraOptions + files;
return vcsFullySynchronousExec(workingDirectory, args).result == SynchronousProcessResponse::Finished; SynchronousProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, args);
return proc.result() == QtcProcess::Finished;
} }
bool GitClient::synchronousDelete(const QString &workingDirectory, bool GitClient::synchronousDelete(const QString &workingDirectory,
@@ -1480,16 +1483,18 @@ bool GitClient::synchronousDelete(const QString &workingDirectory,
if (force) if (force)
arguments << "--force"; arguments << "--force";
arguments.append(files); arguments.append(files);
return vcsFullySynchronousExec(workingDirectory, arguments).result SynchronousProcess proc;
== SynchronousProcessResponse::Finished; vcsFullySynchronousExec(proc, workingDirectory, arguments);
return proc.result() == QtcProcess::Finished;
} }
bool GitClient::synchronousMove(const QString &workingDirectory, bool GitClient::synchronousMove(const QString &workingDirectory,
const QString &from, const QString &from,
const QString &to) const QString &to)
{ {
return vcsFullySynchronousExec(workingDirectory, {"mv", from, to}).result SynchronousProcess proc;
== SynchronousProcessResponse::Finished; vcsFullySynchronousExec(proc, workingDirectory, {"mv", from, to});
return proc.result() == QtcProcess::Finished;
} }
bool GitClient::synchronousReset(const QString &workingDirectory, bool GitClient::synchronousReset(const QString &workingDirectory,
@@ -1502,19 +1507,20 @@ bool GitClient::synchronousReset(const QString &workingDirectory,
else else
arguments << HEAD << "--" << files; arguments << HEAD << "--" << files;
const SynchronousProcessResponse resp = vcsFullySynchronousExec(workingDirectory, arguments); SynchronousProcess proc;
const QString stdOut = resp.stdOut(); vcsFullySynchronousExec(proc, workingDirectory, arguments);
const QString stdOut = proc.stdOut();
VcsOutputWindow::append(stdOut); VcsOutputWindow::append(stdOut);
// Note that git exits with 1 even if the operation is successful // Note that git exits with 1 even if the operation is successful
// Assume real failure if the output does not contain "foo.cpp modified" // Assume real failure if the output does not contain "foo.cpp modified"
// or "Unstaged changes after reset" (git 1.7.0). // or "Unstaged changes after reset" (git 1.7.0).
if (resp.result != SynchronousProcessResponse::Finished if (proc.result() != QtcProcess::Finished
&& (!stdOut.contains("modified") && !stdOut.contains("Unstaged changes after reset"))) { && (!stdOut.contains("modified") && !stdOut.contains("Unstaged changes after reset"))) {
if (files.isEmpty()) { if (files.isEmpty()) {
msgCannotRun(arguments, workingDirectory, resp.stdErr(), errorMessage); msgCannotRun(arguments, workingDirectory, proc.stdErr(), errorMessage);
} else { } else {
msgCannotRun(tr("Cannot reset %n files in \"%1\": %2", nullptr, files.size()) msgCannotRun(tr("Cannot reset %n files in \"%1\": %2", nullptr, files.size())
.arg(QDir::toNativeSeparators(workingDirectory), resp.stdErr()), .arg(QDir::toNativeSeparators(workingDirectory), proc.stdErr()),
errorMessage); errorMessage);
} }
return false; return false;
@@ -1525,11 +1531,11 @@ bool GitClient::synchronousReset(const QString &workingDirectory,
// Initialize repository // Initialize repository
bool GitClient::synchronousInit(const QString &workingDirectory) bool GitClient::synchronousInit(const QString &workingDirectory)
{ {
const SynchronousProcessResponse resp = vcsFullySynchronousExec(workingDirectory, SynchronousProcess proc;
QStringList{"init"}); vcsFullySynchronousExec(proc, workingDirectory, QStringList{"init"});
// '[Re]Initialized...' // '[Re]Initialized...'
VcsOutputWindow::append(resp.stdOut()); VcsOutputWindow::append(proc.stdOut());
if (resp.result == SynchronousProcessResponse::Finished) { if (proc.result() == QtcProcess::Finished) {
resetCachedVcsInfo(workingDirectory); resetCachedVcsInfo(workingDirectory);
return true; return true;
} else { } else {
@@ -1553,14 +1559,14 @@ bool GitClient::synchronousCheckoutFiles(const QString &workingDirectory, QStrin
if (revertStaging) if (revertStaging)
arguments << revision; arguments << revision;
arguments << "--" << files; arguments << "--" << files;
const SynchronousProcessResponse resp = vcsFullySynchronousExec( SynchronousProcess proc;
workingDirectory, arguments, VcsCommand::ExpectRepoChanges); vcsFullySynchronousExec(proc, workingDirectory, arguments, VcsCommand::ExpectRepoChanges);
if (resp.result != SynchronousProcessResponse::Finished) { if (proc.result() != QtcProcess::Finished) {
const QString fileArg = files.join(", "); const QString fileArg = files.join(", ");
//: Meaning of the arguments: %1: revision, %2: files, %3: repository, //: Meaning of the arguments: %1: revision, %2: files, %3: repository,
//: %4: Error message //: %4: Error message
msgCannotRun(tr("Cannot checkout \"%1\" of %2 in \"%3\": %4") msgCannotRun(tr("Cannot checkout \"%1\" of %2 in \"%3\": %4")
.arg(revision, fileArg, workingDirectory, resp.stdErr()), .arg(revision, fileArg, workingDirectory, proc.stdErr()),
errorMessage); errorMessage);
return false; return false;
} }
@@ -1604,13 +1610,13 @@ bool GitClient::synchronousRevListCmd(const QString &workingDirectory, const QSt
QString *output, QString *errorMessage) const QString *output, QString *errorMessage) const
{ {
const QStringList arguments = QStringList({"rev-list", noColorOption}) + extraArguments; const QStringList arguments = QStringList({"rev-list", noColorOption}) + extraArguments;
const SynchronousProcessResponse resp = vcsFullySynchronousExec( SynchronousProcess proc;
workingDirectory, arguments, silentFlags); vcsFullySynchronousExec(proc, workingDirectory, arguments, silentFlags);
if (resp.result != SynchronousProcessResponse::Finished) { if (proc.result() != QtcProcess::Finished) {
msgCannotRun(arguments, workingDirectory, resp.stdErr(), errorMessage); msgCannotRun(arguments, workingDirectory, proc.stdErr(), errorMessage);
return false; return false;
} }
*output = resp.stdOut(); *output = proc.stdOut();
return true; return true;
} }
@@ -1668,10 +1674,10 @@ QString GitClient::synchronousShortDescription(const QString &workingDirectory,
QString GitClient::synchronousCurrentLocalBranch(const QString &workingDirectory) const QString GitClient::synchronousCurrentLocalBranch(const QString &workingDirectory) const
{ {
QString branch; QString branch;
const SynchronousProcessResponse resp = vcsFullySynchronousExec( SynchronousProcess proc;
workingDirectory, {"symbolic-ref", HEAD}, silentFlags); vcsFullySynchronousExec(proc, workingDirectory, {"symbolic-ref", HEAD}, silentFlags);
if (resp.result == SynchronousProcessResponse::Finished) { if (proc.result() == QtcProcess::Finished) {
branch = resp.stdOut().trimmed(); branch = proc.stdOut().trimmed();
} else { } else {
const QString gitDir = findGitDirForRepository(workingDirectory); const QString gitDir = findGitDirForRepository(workingDirectory);
const QString rebaseHead = gitDir + "/rebase-merge/head-name"; const QString rebaseHead = gitDir + "/rebase-merge/head-name";
@@ -1693,14 +1699,14 @@ bool GitClient::synchronousHeadRefs(const QString &workingDirectory, QStringList
QString *errorMessage) const QString *errorMessage) const
{ {
const QStringList arguments = {"show-ref", "--head", "--abbrev=10", "--dereference"}; const QStringList arguments = {"show-ref", "--head", "--abbrev=10", "--dereference"};
const SynchronousProcessResponse resp = vcsFullySynchronousExec( SynchronousProcess proc;
workingDirectory, arguments, silentFlags); vcsFullySynchronousExec(proc, workingDirectory, arguments, silentFlags);
if (resp.result != SynchronousProcessResponse::Finished) { if (proc.result() != QtcProcess::Finished) {
msgCannotRun(arguments, workingDirectory, resp.stdErr(), errorMessage); msgCannotRun(arguments, workingDirectory, proc.stdErr(), errorMessage);
return false; return false;
} }
const QString stdOut = resp.stdOut(); const QString stdOut = proc.stdOut();
const QString headSha = stdOut.left(10); const QString headSha = stdOut.left(10);
QString rest = stdOut.mid(15); QString rest = stdOut.mid(15);
@@ -1742,10 +1748,10 @@ QString GitClient::synchronousTopic(const QString &workingDirectory) const
return remoteBranch; return remoteBranch;
// No tag or remote branch - try git describe // No tag or remote branch - try git describe
const SynchronousProcessResponse resp = SynchronousProcess proc;
vcsFullySynchronousExec(workingDirectory, QStringList{"describe"}, VcsCommand::NoOutput); vcsFullySynchronousExec(proc, workingDirectory, QStringList{"describe"}, VcsCommand::NoOutput);
if (resp.result == SynchronousProcessResponse::Finished) { if (proc.result() == QtcProcess::Finished) {
const QString stdOut = resp.stdOut().trimmed(); const QString stdOut = proc.stdOut().trimmed();
if (!stdOut.isEmpty()) if (!stdOut.isEmpty())
return stdOut; return stdOut;
} }
@@ -1756,11 +1762,11 @@ bool GitClient::synchronousRevParseCmd(const QString &workingDirectory, const QS
QString *output, QString *errorMessage) const QString *output, QString *errorMessage) const
{ {
const QStringList arguments = {"rev-parse", ref}; const QStringList arguments = {"rev-parse", ref};
const SynchronousProcessResponse resp = vcsFullySynchronousExec( SynchronousProcess proc;
workingDirectory, arguments, silentFlags); vcsFullySynchronousExec(proc, workingDirectory, arguments, silentFlags);
*output = resp.stdOut().trimmed(); *output = proc.stdOut().trimmed();
if (resp.result != SynchronousProcessResponse::Finished) { if (proc.result() != QtcProcess::Finished) {
msgCannotRun(arguments, workingDirectory, resp.stdErr(), errorMessage); msgCannotRun(arguments, workingDirectory, proc.stdErr(), errorMessage);
return false; return false;
} }
@@ -1771,11 +1777,11 @@ bool GitClient::synchronousRevParseCmd(const QString &workingDirectory, const QS
QString GitClient::synchronousTopRevision(const QString &workingDirectory, QDateTime *dateTime) QString GitClient::synchronousTopRevision(const QString &workingDirectory, QDateTime *dateTime)
{ {
const QStringList arguments = {"show", "-s", "--pretty=format:%H:%ct", HEAD}; const QStringList arguments = {"show", "-s", "--pretty=format:%H:%ct", HEAD};
const SynchronousProcessResponse resp = vcsFullySynchronousExec( SynchronousProcess proc;
workingDirectory, arguments, silentFlags); vcsFullySynchronousExec(proc, workingDirectory, arguments, silentFlags);
if (resp.result != SynchronousProcessResponse::Finished) if (proc.result() != QtcProcess::Finished)
return QString(); return QString();
const QStringList output = resp.stdOut().trimmed().split(':'); const QStringList output = proc.stdOut().trimmed().split(':');
if (dateTime && output.size() > 1) { if (dateTime && output.size() > 1) {
bool ok = false; bool ok = false;
const qint64 timeT = output.at(1).toLongLong(&ok); const qint64 timeT = output.at(1).toLongLong(&ok);
@@ -1787,9 +1793,9 @@ QString GitClient::synchronousTopRevision(const QString &workingDirectory, QDate
void GitClient::synchronousTagsForCommit(const QString &workingDirectory, const QString &revision, void GitClient::synchronousTagsForCommit(const QString &workingDirectory, const QString &revision,
QString &precedes, QString &follows) const QString &precedes, QString &follows) const
{ {
const SynchronousProcessResponse resp1 = vcsFullySynchronousExec( SynchronousProcess proc1;
workingDirectory, {"describe", "--contains", revision}, silentFlags); vcsFullySynchronousExec(proc1, workingDirectory, {"describe", "--contains", revision}, silentFlags);
precedes = resp1.stdOut(); precedes = proc1.stdOut();
int tilde = precedes.indexOf('~'); int tilde = precedes.indexOf('~');
if (tilde != -1) if (tilde != -1)
precedes.truncate(tilde); precedes.truncate(tilde);
@@ -1800,9 +1806,10 @@ void GitClient::synchronousTagsForCommit(const QString &workingDirectory, const
QString errorMessage; QString errorMessage;
synchronousParentRevisions(workingDirectory, revision, &parents, &errorMessage); synchronousParentRevisions(workingDirectory, revision, &parents, &errorMessage);
for (const QString &p : qAsConst(parents)) { for (const QString &p : qAsConst(parents)) {
const SynchronousProcessResponse resp2 = vcsFullySynchronousExec( SynchronousProcess proc2;
vcsFullySynchronousExec(proc2,
workingDirectory, {"describe", "--tags", "--abbrev=0", p}, silentFlags); workingDirectory, {"describe", "--tags", "--abbrev=0", p}, silentFlags);
QString pf = resp2.stdOut(); QString pf = proc2.stdOut();
pf.truncate(pf.lastIndexOf('\n')); pf.truncate(pf.lastIndexOf('\n'));
if (!pf.isEmpty()) { if (!pf.isEmpty()) {
if (!follows.isEmpty()) if (!follows.isEmpty())
@@ -1814,15 +1821,16 @@ void GitClient::synchronousTagsForCommit(const QString &workingDirectory, const
bool GitClient::isRemoteCommit(const QString &workingDirectory, const QString &commit) bool GitClient::isRemoteCommit(const QString &workingDirectory, const QString &commit)
{ {
return !vcsFullySynchronousExec( SynchronousProcess proc;
workingDirectory, {"branch", "-r", "--contains", commit}, silentFlags).rawStdOut.isEmpty(); vcsFullySynchronousExec(proc, workingDirectory, {"branch", "-r", "--contains", commit}, silentFlags);
return proc.rawStdOut().isEmpty();
} }
bool GitClient::isFastForwardMerge(const QString &workingDirectory, const QString &branch) bool GitClient::isFastForwardMerge(const QString &workingDirectory, const QString &branch)
{ {
const SynchronousProcessResponse resp = vcsFullySynchronousExec( SynchronousProcess proc;
workingDirectory, {"merge-base", HEAD, branch}, silentFlags); vcsFullySynchronousExec(proc, workingDirectory, {"merge-base", HEAD, branch}, silentFlags);
return resp.stdOut().trimmed() == synchronousTopRevision(workingDirectory); return proc.stdOut().trimmed() == synchronousTopRevision(workingDirectory);
} }
// Format an entry in a one-liner for selection list using git log. // Format an entry in a one-liner for selection list using git log.
@@ -1831,14 +1839,14 @@ QString GitClient::synchronousShortDescription(const QString &workingDirectory,
{ {
const QStringList arguments = {"log", noColorOption, ("--pretty=format:" + format), const QStringList arguments = {"log", noColorOption, ("--pretty=format:" + format),
"--max-count=1", revision}; "--max-count=1", revision};
const SynchronousProcessResponse resp = vcsFullySynchronousExec( SynchronousProcess proc;
workingDirectory, arguments, silentFlags); vcsFullySynchronousExec(proc, workingDirectory, arguments, silentFlags);
if (resp.result != SynchronousProcessResponse::Finished) { if (proc.result() != QtcProcess::Finished) {
VcsOutputWindow::appendSilently(tr("Cannot describe revision \"%1\" in \"%2\": %3") VcsOutputWindow::appendSilently(tr("Cannot describe revision \"%1\" in \"%2\": %3")
.arg(revision, workingDirectory, resp.stdErr())); .arg(revision, workingDirectory, proc.stdErr()));
return revision; return revision;
} }
return stripLastNewline(resp.stdOut()); return stripLastNewline(proc.stdOut());
} }
// Create a default message to be used for describing stashes // Create a default message to be used for describing stashes
@@ -1912,9 +1920,10 @@ bool GitClient::executeSynchronousStash(const QString &workingDirectory,
const unsigned flags = VcsCommand::ShowStdOut const unsigned flags = VcsCommand::ShowStdOut
| VcsCommand::ExpectRepoChanges | VcsCommand::ExpectRepoChanges
| VcsCommand::ShowSuccessMessage; | VcsCommand::ShowSuccessMessage;
const SynchronousProcessResponse resp = vcsSynchronousExec(workingDirectory, arguments, flags); SynchronousProcess proc;
if (resp.result != SynchronousProcessResponse::Finished) { vcsSynchronousExec(proc, workingDirectory, arguments, flags);
msgCannotRun(arguments, workingDirectory, resp.stdErr(), errorMessage); if (proc.result() != QtcProcess::Finished) {
msgCannotRun(arguments, workingDirectory, proc.stdErr(), errorMessage);
return false; return false;
} }
@@ -1951,10 +1960,11 @@ bool GitClient::synchronousBranchCmd(const QString &workingDirectory, QStringLis
QString *output, QString *errorMessage) const QString *output, QString *errorMessage) const
{ {
branchArgs.push_front("branch"); branchArgs.push_front("branch");
const SynchronousProcessResponse resp = vcsFullySynchronousExec(workingDirectory, branchArgs); SynchronousProcess proc;
*output = resp.stdOut(); vcsFullySynchronousExec(proc, workingDirectory, branchArgs);
if (resp.result != SynchronousProcessResponse::Finished) { *output = proc.stdOut();
msgCannotRun(branchArgs, workingDirectory, resp.stdErr(), errorMessage); if (proc.result() != QtcProcess::Finished) {
msgCannotRun(branchArgs, workingDirectory, proc.stdErr(), errorMessage);
return false; return false;
} }
return true; return true;
@@ -1964,10 +1974,11 @@ bool GitClient::synchronousTagCmd(const QString &workingDirectory, QStringList t
QString *output, QString *errorMessage) const QString *output, QString *errorMessage) const
{ {
tagArgs.push_front("tag"); tagArgs.push_front("tag");
const SynchronousProcessResponse resp = vcsFullySynchronousExec(workingDirectory, tagArgs); SynchronousProcess proc;
*output = resp.stdOut(); vcsFullySynchronousExec(proc, workingDirectory, tagArgs);
if (resp.result != SynchronousProcessResponse::Finished) { *output = proc.stdOut();
msgCannotRun(tagArgs, workingDirectory, resp.stdErr(), errorMessage); if (proc.result() != QtcProcess::Finished) {
msgCannotRun(tagArgs, workingDirectory, proc.stdErr(), errorMessage);
return false; return false;
} }
return true; return true;
@@ -1977,11 +1988,11 @@ bool GitClient::synchronousForEachRefCmd(const QString &workingDirectory, QStrin
QString *output, QString *errorMessage) const QString *output, QString *errorMessage) const
{ {
args.push_front("for-each-ref"); args.push_front("for-each-ref");
const SynchronousProcessResponse resp = vcsFullySynchronousExec(workingDirectory, args, SynchronousProcess proc;
silentFlags); vcsFullySynchronousExec(proc, workingDirectory, args, silentFlags);
*output = resp.stdOut(); *output = proc.stdOut();
if (resp.result != SynchronousProcessResponse::Finished) { if (proc.result() != QtcProcess::Finished) {
msgCannotRun(args, workingDirectory, resp.stdErr(), errorMessage); msgCannotRun(args, workingDirectory, proc.stdErr(), errorMessage);
return false; return false;
} }
return true; return true;
@@ -1997,14 +2008,14 @@ bool GitClient::synchronousRemoteCmd(const QString &workingDirectory, QStringLis
QString *output, QString *errorMessage, bool silent) const QString *output, QString *errorMessage, bool silent) const
{ {
remoteArgs.push_front("remote"); remoteArgs.push_front("remote");
const SynchronousProcessResponse resp = vcsFullySynchronousExec(workingDirectory, remoteArgs, SynchronousProcess proc;
silent ? silentFlags : 0); vcsFullySynchronousExec(proc, workingDirectory, remoteArgs, silent ? silentFlags : 0);
const QString stdErr = resp.stdErr(); const QString stdErr = proc.stdErr();
*errorMessage = stdErr; *errorMessage = stdErr;
*output = resp.stdOut(); *output = proc.stdOut();
if (resp.result != SynchronousProcessResponse::Finished) { if (proc.result() != QtcProcess::Finished) {
msgCannotRun(remoteArgs, workingDirectory, stdErr, errorMessage); msgCannotRun(remoteArgs, workingDirectory, stdErr, errorMessage);
return false; return false;
} }
@@ -2041,15 +2052,15 @@ QStringList GitClient::synchronousSubmoduleStatus(const QString &workingDirector
QString *errorMessage) const QString *errorMessage) const
{ {
// get submodule status // get submodule status
const SynchronousProcessResponse resp = SynchronousProcess proc;
vcsFullySynchronousExec(workingDirectory, {"submodule", "status"}, silentFlags); vcsFullySynchronousExec(proc, workingDirectory, {"submodule", "status"}, silentFlags);
if (resp.result != SynchronousProcessResponse::Finished) { if (proc.result() != QtcProcess::Finished) {
msgCannotRun(tr("Cannot retrieve submodule status of \"%1\": %2") msgCannotRun(tr("Cannot retrieve submodule status of \"%1\": %2")
.arg(QDir::toNativeSeparators(workingDirectory), resp.stdErr()), errorMessage); .arg(QDir::toNativeSeparators(workingDirectory), proc.stdErr()), errorMessage);
return QStringList(); return QStringList();
} }
return splitLines(resp.stdOut()); return splitLines(proc.stdOut());
} }
SubmoduleDataMap GitClient::submoduleList(const QString &workingDirectory) const SubmoduleDataMap GitClient::submoduleList(const QString &workingDirectory) const
@@ -2122,12 +2133,13 @@ QByteArray GitClient::synchronousShow(const QString &workingDirectory, const QSt
return {}; return {};
} }
const QStringList arguments = {"show", decorateOption, noColorOption, "--no-patch", id}; const QStringList arguments = {"show", decorateOption, noColorOption, "--no-patch", id};
const SynchronousProcessResponse resp = vcsFullySynchronousExec(workingDirectory, arguments, flags); SynchronousProcess proc;
if (resp.result != SynchronousProcessResponse::Finished) { vcsFullySynchronousExec(proc, workingDirectory, arguments, flags);
msgCannotRun(arguments, workingDirectory, resp.stdErr(), nullptr); if (proc.result() != QtcProcess::Finished) {
msgCannotRun(arguments, workingDirectory, proc.stdErr(), nullptr);
return {}; return {};
} }
return resp.rawStdOut; return proc.rawStdOut();
} }
// Retrieve list of files to be cleaned // Retrieve list of files to be cleaned
@@ -2137,10 +2149,10 @@ bool GitClient::cleanList(const QString &workingDirectory, const QString &module
const QString directory = workingDirectory + '/' + modulePath; const QString directory = workingDirectory + '/' + modulePath;
const QStringList arguments = {"clean", "--dry-run", flag}; const QStringList arguments = {"clean", "--dry-run", flag};
const SynchronousProcessResponse resp = vcsFullySynchronousExec(directory, arguments, SynchronousProcess proc;
VcsCommand::ForceCLocale); vcsFullySynchronousExec(proc, directory, arguments, VcsCommand::ForceCLocale);
if (resp.result != SynchronousProcessResponse::Finished) { if (proc.result() != QtcProcess::Finished) {
msgCannotRun(arguments, directory, resp.stdErr(), errorMessage); msgCannotRun(arguments, directory, proc.stdErr(), errorMessage);
return false; return false;
} }
@@ -2148,7 +2160,7 @@ bool GitClient::cleanList(const QString &workingDirectory, const QString &module
const QString relativeBase = modulePath.isEmpty() ? QString() : modulePath + '/'; const QString relativeBase = modulePath.isEmpty() ? QString() : modulePath + '/';
const QString prefix = "Would remove "; const QString prefix = "Would remove ";
const QStringList removeLines = Utils::filtered( const QStringList removeLines = Utils::filtered(
splitLines(resp.stdOut()), [](const QString &s) { splitLines(proc.stdOut()), [](const QString &s) {
return s.startsWith("Would remove "); return s.startsWith("Would remove ");
}); });
*files = Utils::transform(removeLines, [&relativeBase, &prefix](const QString &s) -> QString { *files = Utils::transform(removeLines, [&relativeBase, &prefix](const QString &s) -> QString {
@@ -2184,9 +2196,10 @@ bool GitClient::synchronousApplyPatch(const QString &workingDirectory,
QStringList arguments = {"apply", "--whitespace=fix"}; QStringList arguments = {"apply", "--whitespace=fix"};
arguments << extraArguments << file; arguments << extraArguments << file;
const SynchronousProcessResponse resp = vcsFullySynchronousExec(workingDirectory, arguments); SynchronousProcess proc;
const QString stdErr = resp.stdErr(); vcsFullySynchronousExec(proc, workingDirectory, arguments);
if (resp.result == SynchronousProcessResponse::Finished) { const QString stdErr = proc.stdErr();
if (proc.result() == QtcProcess::Finished) {
if (!stdErr.isEmpty()) if (!stdErr.isEmpty())
*errorMessage = tr("There were warnings while applying \"%1\" to \"%2\":\n%3") *errorMessage = tr("There were warnings while applying \"%1\" to \"%2\":\n%3")
.arg(file, workingDirectory, stdErr); .arg(file, workingDirectory, stdErr);
@@ -2312,19 +2325,19 @@ GitClient::StatusResult GitClient::gitStatus(const QString &workingDirectory, St
arguments << "--ignore-submodules=all"; arguments << "--ignore-submodules=all";
arguments << "--porcelain" << "-b"; arguments << "--porcelain" << "-b";
const SynchronousProcessResponse resp = vcsFullySynchronousExec( SynchronousProcess proc;
workingDirectory, arguments, silentFlags); vcsFullySynchronousExec(proc, workingDirectory, arguments, silentFlags);
const QString stdOut = resp.stdOut(); const QString stdOut = proc.stdOut();
if (output) if (output)
*output = stdOut; *output = stdOut;
const bool statusRc = resp.result == SynchronousProcessResponse::Finished; const bool statusRc = proc.result() == QtcProcess::Finished;
const bool branchKnown = !stdOut.startsWith("## HEAD (no branch)\n"); const bool branchKnown = !stdOut.startsWith("## HEAD (no branch)\n");
// Is it something really fatal? // Is it something really fatal?
if (!statusRc && !branchKnown) { if (!statusRc && !branchKnown) {
if (errorMessage) { if (errorMessage) {
*errorMessage = tr("Cannot obtain status: %1").arg(resp.stdErr()); *errorMessage = tr("Cannot obtain status: %1").arg(proc.stdErr());
} }
return StatusFailed; return StatusFailed;
} }
@@ -2480,7 +2493,8 @@ QStringList GitClient::synchronousRepositoryBranches(const QString &repositoryUR
const unsigned flags = VcsCommand::SshPasswordPrompt const unsigned flags = VcsCommand::SshPasswordPrompt
| VcsCommand::SuppressStdErr | VcsCommand::SuppressStdErr
| VcsCommand::SuppressFailMessage; | VcsCommand::SuppressFailMessage;
const SynchronousProcessResponse resp = vcsSynchronousExec( SynchronousProcess proc;
vcsSynchronousExec(proc,
workingDirectory, {"ls-remote", repositoryURL, HEAD, "refs/heads/*"}, flags); workingDirectory, {"ls-remote", repositoryURL, HEAD, "refs/heads/*"}, flags);
QStringList branches; QStringList branches;
branches << tr("<Detached HEAD>"); branches << tr("<Detached HEAD>");
@@ -2488,7 +2502,7 @@ QStringList GitClient::synchronousRepositoryBranches(const QString &repositoryUR
// split "82bfad2f51d34e98b18982211c82220b8db049b<tab>refs/heads/master" // split "82bfad2f51d34e98b18982211c82220b8db049b<tab>refs/heads/master"
bool headFound = false; bool headFound = false;
bool branchFound = false; bool branchFound = false;
const QStringList lines = resp.stdOut().split('\n'); const QStringList lines = proc.stdOut().split('\n');
for (const QString &line : lines) { for (const QString &line : lines) {
if (line.endsWith("\tHEAD")) { if (line.endsWith("\tHEAD")) {
QTC_CHECK(headSha.isNull()); QTC_CHECK(headSha.isNull());
@@ -2694,9 +2708,10 @@ bool GitClient::readDataFromCommit(const QString &repoDirectory, const QString &
{ {
// Get commit data as "SHA1<lf>author<lf>email<lf>message". // Get commit data as "SHA1<lf>author<lf>email<lf>message".
const QStringList arguments = {"log", "--max-count=1", "--pretty=format:%h\n%an\n%ae\n%B", commit}; const QStringList arguments = {"log", "--max-count=1", "--pretty=format:%h\n%an\n%ae\n%B", commit};
const SynchronousProcessResponse resp = vcsFullySynchronousExec(repoDirectory, arguments, silentFlags); SynchronousProcess proc;
vcsFullySynchronousExec(proc, repoDirectory, arguments, silentFlags);
if (resp.result != SynchronousProcessResponse::Finished) { if (proc.result() != QtcProcess::Finished) {
if (errorMessage) { if (errorMessage) {
*errorMessage = tr("Cannot retrieve last commit data of repository \"%1\".") *errorMessage = tr("Cannot retrieve last commit data of repository \"%1\".")
.arg(QDir::toNativeSeparators(repoDirectory)); .arg(QDir::toNativeSeparators(repoDirectory));
@@ -2707,7 +2722,7 @@ bool GitClient::readDataFromCommit(const QString &repoDirectory, const QString &
QTextCodec *authorCodec = HostOsInfo::isWindowsHost() QTextCodec *authorCodec = HostOsInfo::isWindowsHost()
? QTextCodec::codecForName("UTF-8") ? QTextCodec::codecForName("UTF-8")
: commitData.commitEncoding; : commitData.commitEncoding;
QByteArray stdOut = resp.rawStdOut; QByteArray stdOut = proc.rawStdOut();
commitData.amendSHA1 = QLatin1String(shiftLogLine(stdOut)); commitData.amendSHA1 = QLatin1String(shiftLogLine(stdOut));
commitData.panelData.author = authorCodec->toUnicode(shiftLogLine(stdOut)); commitData.panelData.author = authorCodec->toUnicode(shiftLogLine(stdOut));
commitData.panelData.email = authorCodec->toUnicode(shiftLogLine(stdOut)); commitData.panelData.email = authorCodec->toUnicode(shiftLogLine(stdOut));
@@ -2950,9 +2965,9 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory,
arguments << "--signoff"; arguments << "--signoff";
} }
const SynchronousProcessResponse resp = vcsSynchronousExec(repositoryDirectory, arguments, SynchronousProcess proc;
VcsCommand::NoFullySync); vcsSynchronousExec(proc, repositoryDirectory, arguments, VcsCommand::NoFullySync);
if (resp.result == SynchronousProcessResponse::Finished) { if (proc.result() == QtcProcess::Finished) {
VcsOutputWindow::appendMessage(msgCommitted(amendSHA1, commitCount)); VcsOutputWindow::appendMessage(msgCommitted(amendSHA1, commitCount));
GitPlugin::updateCurrentBranch(); GitPlugin::updateCurrentBranch();
return true; return true;
@@ -3089,10 +3104,11 @@ bool GitClient::executeAndHandleConflicts(const QString &workingDirectory,
| VcsCommand::ShowStdOut | VcsCommand::ShowStdOut
| VcsCommand::ExpectRepoChanges | VcsCommand::ExpectRepoChanges
| VcsCommand::ShowSuccessMessage; | VcsCommand::ShowSuccessMessage;
const SynchronousProcessResponse resp = vcsSynchronousExec(workingDirectory, arguments, flags); SynchronousProcess proc;
vcsSynchronousExec(proc, workingDirectory, arguments, flags);
// Notify about changed files or abort the rebase. // Notify about changed files or abort the rebase.
ConflictHandler::handleResponse(resp, workingDirectory, abortCommand); ConflictHandler::handleResponse(proc, workingDirectory, abortCommand);
return resp.result == SynchronousProcessResponse::Finished; return proc.result() == QtcProcess::Finished;
} }
void GitClient::pull(const QString &workingDirectory, bool rebase) void GitClient::pull(const QString &workingDirectory, bool rebase)
@@ -3122,10 +3138,10 @@ void GitClient::synchronousAbortCommand(const QString &workingDir, const QString
return; return;
} }
const SynchronousProcessResponse resp = vcsFullySynchronousExec( SynchronousProcess proc;
workingDir, {abortCommand, "--abort"}, vcsFullySynchronousExec(proc, workingDir, {abortCommand, "--abort"},
VcsCommand::ExpectRepoChanges | VcsCommand::ShowSuccessMessage); VcsCommand::ExpectRepoChanges | VcsCommand::ShowSuccessMessage);
VcsOutputWindow::append(resp.stdOut()); VcsOutputWindow::append(proc.stdOut());
} }
QString GitClient::synchronousTrackingBranch(const QString &workingDirectory, const QString &branch) QString GitClient::synchronousTrackingBranch(const QString &workingDirectory, const QString &branch)
@@ -3148,9 +3164,10 @@ QString GitClient::synchronousTrackingBranch(const QString &workingDirectory, co
bool GitClient::synchronousSetTrackingBranch(const QString &workingDirectory, bool GitClient::synchronousSetTrackingBranch(const QString &workingDirectory,
const QString &branch, const QString &tracking) const QString &branch, const QString &tracking)
{ {
return vcsFullySynchronousExec( SynchronousProcess proc;
workingDirectory, {"branch", "--set-upstream-to=" + tracking, branch}).result vcsFullySynchronousExec(proc,
== SynchronousProcessResponse::Finished; workingDirectory, {"branch", "--set-upstream-to=" + tracking, branch});
return proc.result() == QtcProcess::Finished;
} }
VcsBase::VcsCommand *GitClient::asyncUpstreamStatus(const QString &workingDirectory, VcsBase::VcsCommand *GitClient::asyncUpstreamStatus(const QString &workingDirectory,
@@ -3221,7 +3238,8 @@ void GitClient::synchronousSubversionFetch(const QString &workingDirectory) cons
const unsigned flags = VcsCommand::SshPasswordPrompt const unsigned flags = VcsCommand::SshPasswordPrompt
| VcsCommand::ShowStdOut | VcsCommand::ShowStdOut
| VcsCommand::ShowSuccessMessage; | VcsCommand::ShowSuccessMessage;
vcsSynchronousExec(workingDirectory, {"svn", "fetch"}, flags); SynchronousProcess proc;
vcsSynchronousExec(proc, workingDirectory, {"svn", "fetch"}, flags);
} }
void GitClient::subversionLog(const QString &workingDirectory) const void GitClient::subversionLog(const QString &workingDirectory) const
@@ -3470,14 +3488,15 @@ bool GitClient::synchronousStashRemove(const QString &workingDirectory, const QS
else else
arguments << "drop" << stash; arguments << "drop" << stash;
const SynchronousProcessResponse resp = vcsFullySynchronousExec(workingDirectory, arguments); SynchronousProcess proc;
if (resp.result == SynchronousProcessResponse::Finished) { vcsFullySynchronousExec(proc, workingDirectory, arguments);
const QString output = resp.stdOut(); if (proc.result() == QtcProcess::Finished) {
const QString output = proc.stdOut();
if (!output.isEmpty()) if (!output.isEmpty())
VcsOutputWindow::append(output); VcsOutputWindow::append(output);
return true; return true;
} else { } else {
msgCannotRun(arguments, workingDirectory, resp.stdErr(), errorMessage); msgCannotRun(arguments, workingDirectory, proc.stdErr(), errorMessage);
return false; return false;
} }
} }
@@ -3488,14 +3507,14 @@ bool GitClient::synchronousStashList(const QString &workingDirectory, QList<Stas
stashes->clear(); stashes->clear();
const QStringList arguments = {"stash", "list", noColorOption}; const QStringList arguments = {"stash", "list", noColorOption};
const SynchronousProcessResponse resp = vcsFullySynchronousExec(workingDirectory, arguments, SynchronousProcess proc;
VcsCommand::ForceCLocale); vcsFullySynchronousExec(proc, workingDirectory, arguments, VcsCommand::ForceCLocale);
if (resp.result != SynchronousProcessResponse::Finished) { if (proc.result() != QtcProcess::Finished) {
msgCannotRun(arguments, workingDirectory, resp.stdErr(), errorMessage); msgCannotRun(arguments, workingDirectory, proc.stdErr(), errorMessage);
return false; return false;
} }
Stash stash; Stash stash;
const QStringList lines = splitLines(resp.stdOut()); const QStringList lines = splitLines(proc.stdOut());
for (const QString &line : lines) { for (const QString &line : lines) {
if (stash.parseStashLine(line)) if (stash.parseStashLine(line))
stashes->push_back(stash); stashes->push_back(stash);
@@ -3528,11 +3547,11 @@ QString GitClient::readOneLine(const QString &workingDirectory, const QStringLis
? QTextCodec::codecForName("UTF-8") ? QTextCodec::codecForName("UTF-8")
: QTextCodec::codecForLocale(); : QTextCodec::codecForLocale();
const SynchronousProcessResponse resp = vcsFullySynchronousExec( SynchronousProcess proc;
workingDirectory, arguments, silentFlags, vcsTimeoutS(), codec); vcsFullySynchronousExec(proc, workingDirectory, arguments, silentFlags, vcsTimeoutS(), codec);
if (resp.result != SynchronousProcessResponse::Finished) if (proc.result() != QtcProcess::Finished)
return QString(); return QString();
return resp.stdOut().trimmed(); return proc.stdOut().trimmed();
} }
// determine version as '(major << 16) + (minor << 8) + patch' or 0. // determine version as '(major << 16) + (minor << 8) + patch' or 0.
@@ -3555,16 +3574,16 @@ unsigned GitClient::synchronousGitVersion(QString *errorMessage) const
return 0; return 0;
// run git --version // run git --version
const SynchronousProcessResponse resp = vcsSynchronousExec( SynchronousProcess proc;
QString(), {"--version"}, silentFlags); vcsSynchronousExec(proc, QString(), {"--version"}, silentFlags);
if (resp.result != SynchronousProcessResponse::Finished) { if (proc.result() != QtcProcess::Finished) {
msgCannotRun(tr("Cannot determine Git version: %1").arg(resp.stdErr()), errorMessage); msgCannotRun(tr("Cannot determine Git version: %1").arg(proc.stdErr()), errorMessage);
return 0; return 0;
} }
// cut 'git version 1.6.5.1.sha' // cut 'git version 1.6.5.1.sha'
// another form: 'git version 1.9.rc1' // another form: 'git version 1.9.rc1'
const QString output = resp.stdOut(); const QString output = proc.stdOut();
const QRegularExpression versionPattern("^[^\\d]+(\\d+)\\.(\\d+)\\.(\\d+|rc\\d).*$"); const QRegularExpression versionPattern("^[^\\d]+(\\d+)\\.(\\d+)\\.(\\d+|rc\\d).*$");
QTC_ASSERT(versionPattern.isValid(), return 0); QTC_ASSERT(versionPattern.isValid(), return 0);
const QRegularExpressionMatch match = versionPattern.match(output); const QRegularExpressionMatch match = versionPattern.match(output);

View File

@@ -194,15 +194,16 @@ public:
command.data(), &VcsCommand::cancel); command.data(), &VcsCommand::cancel);
watcher.setFuture(m_fi.future()); watcher.setFuture(m_fi.future());
connect(command.data(), &VcsCommand::stdOutText, this, &GitGrepRunner::read); connect(command.data(), &VcsCommand::stdOutText, this, &GitGrepRunner::read);
SynchronousProcessResponse resp = command->runCommand({GitClient::instance()->vcsBinary(), arguments}, 0); SynchronousProcess proc;
switch (resp.result) { command->runCommand(proc, {GitClient::instance()->vcsBinary(), arguments}, 0);
case SynchronousProcessResponse::TerminatedAbnormally: switch (proc.result()) {
case SynchronousProcessResponse::StartFailed: case QtcProcess::TerminatedAbnormally:
case SynchronousProcessResponse::Hang: case QtcProcess::StartFailed:
case QtcProcess::Hang:
m_fi.reportCanceled(); m_fi.reportCanceled();
break; break;
case SynchronousProcessResponse::Finished: case QtcProcess::Finished:
case SynchronousProcessResponse::FinishedError: case QtcProcess::FinishedError:
// When no results are found, git-grep exits with non-zero status. // When no results are found, git-grep exits with non-zero status.
// Do not consider this as an error. // Do not consider this as an error.
break; break;

View File

@@ -236,10 +236,10 @@ static QByteArray decodeProvisioningProfile(const QString &path)
p.setTimeoutS(3); p.setTimeoutS(3);
// path is assumed to be valid file path to .mobileprovision // path is assumed to be valid file path to .mobileprovision
const QStringList args = {"smime", "-inform", "der", "-verify", "-in", path}; const QStringList args = {"smime", "-inform", "der", "-verify", "-in", path};
Utils::SynchronousProcessResponse res = p.runBlocking({"openssl", args}); p.runBlocking({"openssl", args});
if (res.result != Utils::SynchronousProcessResponse::Finished) if (p.result() != Utils::QtcProcess::Finished)
qCDebug(iosCommonLog) << "Reading signed provisioning file failed" << path; qCDebug(iosCommonLog) << "Reading signed provisioning file failed" << path;
return res.stdOut().toLatin1(); return p.stdOut().toLatin1();
} }
void IosConfigurations::updateAutomaticKitList() void IosConfigurations::updateAutomaticKitList()

View File

@@ -68,12 +68,12 @@ void XcodeProbe::detectDeveloperPaths()
Utils::SynchronousProcess selectedXcode; Utils::SynchronousProcess selectedXcode;
selectedXcode.setTimeoutS(5); selectedXcode.setTimeoutS(5);
const CommandLine xcodeSelect{"/usr/bin/xcode-select", {"--print-path"}}; const CommandLine xcodeSelect{"/usr/bin/xcode-select", {"--print-path"}};
Utils::SynchronousProcessResponse response = selectedXcode.run(xcodeSelect); selectedXcode.run(xcodeSelect);
if (response.result != Utils::SynchronousProcessResponse::Finished) if (selectedXcode.result() != QtcProcess::Finished)
qCWarning(probeLog) qCWarning(probeLog)
<< QString::fromLatin1("Could not detect selected Xcode using xcode-select"); << QString::fromLatin1("Could not detect selected Xcode using xcode-select");
else else
addDeveloperPath(response.stdOut().trimmed()); addDeveloperPath(selectedXcode.stdOut().trimmed());
addDeveloperPath(defaultDeveloperPath); addDeveloperPath(defaultDeveloperPath);
} }

View File

@@ -83,12 +83,12 @@ static bool runCommand(const CommandLine &command, QString *stdOutput, QString *
{ {
SynchronousProcess p; SynchronousProcess p;
p.setTimeoutS(-1); p.setTimeoutS(-1);
SynchronousProcessResponse resp = p.runBlocking(command); p.runBlocking(command);
if (stdOutput) if (stdOutput)
*stdOutput = resp.stdOut(); *stdOutput = p.stdOut();
if (allOutput) if (allOutput)
*allOutput = resp.allOutput(); *allOutput = p.allOutput();
return resp.result == SynchronousProcessResponse::Finished; return p.result() == QtcProcess::Finished;
} }
static bool runSimCtlCommand(QStringList args, QString *output, QString *allOutput = nullptr) static bool runSimCtlCommand(QStringList args, QString *output, QString *allOutput = nullptr)

View File

@@ -96,12 +96,13 @@ bool MercurialClient::manifestSync(const QString &repository, const QString &rel
// This only works when called from the repo and outputs paths relative to it. // This only works when called from the repo and outputs paths relative to it.
const QStringList args(QLatin1String("manifest")); const QStringList args(QLatin1String("manifest"));
const SynchronousProcessResponse result = vcsFullySynchronousExec(repository, args); SynchronousProcess proc;
vcsFullySynchronousExec(proc, repository, args);
const QDir repositoryDir(repository); const QDir repositoryDir(repository);
const QFileInfo needle = QFileInfo(repositoryDir, relativeFilename); const QFileInfo needle = QFileInfo(repositoryDir, relativeFilename);
const QStringList files = result.stdOut().split(QLatin1Char('\n')); const QStringList files = proc.stdOut().split(QLatin1Char('\n'));
foreach (const QString &fileName, files) { foreach (const QString &fileName, files) {
const QFileInfo managedFile(repositoryDir, fileName); const QFileInfo managedFile(repositoryDir, fileName);
if (needle == managedFile) if (needle == managedFile)
@@ -126,17 +127,17 @@ bool MercurialClient::synchronousClone(const QString &workingDir,
if (workingDirectory.exists()) { if (workingDirectory.exists()) {
// Let's make first init // Let's make first init
QStringList arguments(QLatin1String("init")); QStringList arguments(QLatin1String("init"));
const SynchronousProcessResponse resp = vcsFullySynchronousExec( SynchronousProcess proc;
workingDirectory.path(), arguments); vcsFullySynchronousExec(proc, workingDirectory.path(), arguments);
if (resp.result != SynchronousProcessResponse::Finished) if (proc.result() != QtcProcess::Finished)
return false; return false;
// Then pull remote repository // Then pull remote repository
arguments.clear(); arguments.clear();
arguments << QLatin1String("pull") << dstLocation; arguments << QLatin1String("pull") << dstLocation;
const SynchronousProcessResponse resp1 = vcsSynchronousExec( SynchronousProcess proc1;
workingDirectory.path(), arguments, flags); vcsSynchronousExec(proc1, workingDirectory.path(), arguments, flags);
if (resp1.result != SynchronousProcessResponse::Finished) if (proc1.result() != QtcProcess::Finished)
return false; return false;
// By now, there is no hgrc file -> create it // By now, there is no hgrc file -> create it
@@ -151,16 +152,16 @@ bool MercurialClient::synchronousClone(const QString &workingDir,
// And last update repository // And last update repository
arguments.clear(); arguments.clear();
arguments << QLatin1String("update"); arguments << QLatin1String("update");
const SynchronousProcessResponse resp2 = vcsSynchronousExec( SynchronousProcess proc2;
workingDirectory.path(), arguments, flags); vcsSynchronousExec(proc2, workingDirectory.path(), arguments, flags);
return resp2.result == SynchronousProcessResponse::Finished; return proc2.result() == QtcProcess::Finished;
} else { } else {
QStringList arguments(QLatin1String("clone")); QStringList arguments(QLatin1String("clone"));
arguments << dstLocation << workingDirectory.dirName(); arguments << dstLocation << workingDirectory.dirName();
workingDirectory.cdUp(); workingDirectory.cdUp();
const SynchronousProcessResponse resp = vcsSynchronousExec( SynchronousProcess proc;
workingDirectory.path(), arguments, flags); vcsSynchronousExec(proc, workingDirectory.path(), arguments, flags);
return resp.result == SynchronousProcessResponse::Finished; return proc.result() == QtcProcess::Finished;
} }
} }
@@ -177,11 +178,15 @@ bool MercurialClient::synchronousPull(const QString &workingDir, const QString &
// cause mercurial doesn`t understand LANG // cause mercurial doesn`t understand LANG
Environment env = Environment::systemEnvironment(); Environment env = Environment::systemEnvironment();
env.set("LANGUAGE", "C"); env.set("LANGUAGE", "C");
const SynchronousProcessResponse resp = VcsBase::runVcs( SynchronousProcess proc;
workingDir, {vcsBinary(), args}, vcsTimeoutS(), flags, nullptr, env);
const bool ok = resp.result == SynchronousProcessResponse::Finished;
parsePullOutput(resp.stdOut().trimmed()); VcsCommand command(workingDir, env);
command.addFlags(flags);
command.runCommand(proc, {vcsBinary(), args}, vcsTimeoutS());
const bool ok = proc.result() == QtcProcess::Finished;
parsePullOutput(proc.stdOut().trimmed());
return ok; return ok;
} }
@@ -218,22 +223,25 @@ QStringList MercurialClient::parentRevisionsSync(const QString &workingDirectory
args << QLatin1String("parents") << QLatin1String("-r") <<revision; args << QLatin1String("parents") << QLatin1String("-r") <<revision;
if (!file.isEmpty()) if (!file.isEmpty())
args << file; args << file;
const SynchronousProcessResponse resp = vcsFullySynchronousExec(workingDirectory, args); SynchronousProcess proc;
if (resp.result != SynchronousProcessResponse::Finished) vcsFullySynchronousExec(proc, workingDirectory, args);
if (proc.result() != QtcProcess::Finished)
return QStringList(); return QStringList();
/* Looks like: \code /* Looks like: \code
changeset: 0:031a48610fba changeset: 0:031a48610fba
user: ... user: ...
\endcode */ \endcode */
// Obtain first line and split by blank-delimited tokens // Obtain first line and split by blank-delimited tokens
const QStringList lines = resp.stdOut().split(QLatin1Char('\n')); const QStringList lines = proc.stdOut().split(QLatin1Char('\n'));
if (lines.size() < 1) { if (lines.size() < 1) {
VcsOutputWindow::appendSilently(msgParentRevisionFailed(workingDirectory, revision, msgParseParentsOutputFailed(resp.stdOut()))); VcsOutputWindow::appendSilently(
msgParentRevisionFailed(workingDirectory, revision, msgParseParentsOutputFailed(proc.stdOut())));
return QStringList(); return QStringList();
} }
QStringList changeSets = lines.front().simplified().split(QLatin1Char(' ')); QStringList changeSets = lines.front().simplified().split(QLatin1Char(' '));
if (changeSets.size() < 2) { if (changeSets.size() < 2) {
VcsOutputWindow::appendSilently(msgParentRevisionFailed(workingDirectory, revision, msgParseParentsOutputFailed(resp.stdOut()))); VcsOutputWindow::appendSilently(
msgParentRevisionFailed(workingDirectory, revision, msgParseParentsOutputFailed(proc.stdOut())));
return QStringList(); return QStringList();
} }
// Remove revision numbers // Remove revision numbers
@@ -258,10 +266,11 @@ QString MercurialClient::shortDescriptionSync(const QString &workingDirectory,
if (!format.isEmpty()) if (!format.isEmpty())
args << QLatin1String("--template") << format; args << QLatin1String("--template") << format;
const SynchronousProcessResponse resp = vcsFullySynchronousExec(workingDirectory, args); SynchronousProcess proc;
if (resp.result != SynchronousProcessResponse::Finished) vcsFullySynchronousExec(proc, workingDirectory, args);
if (proc.result() != QtcProcess::Finished)
return revision; return revision;
return stripLastNewline(resp.stdOut()); return stripLastNewline(proc.stdOut());
} }
// Default format: "SHA1 (author summmary)" // Default format: "SHA1 (author summmary)"
@@ -277,7 +286,9 @@ bool MercurialClient::managesFile(const QString &workingDirectory, const QString
{ {
QStringList args; QStringList args;
args << QLatin1String("status") << QLatin1String("--unknown") << fileName; args << QLatin1String("status") << QLatin1String("--unknown") << fileName;
return vcsFullySynchronousExec(workingDirectory, args).stdOut().isEmpty(); SynchronousProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, args);
return proc.stdOut().isEmpty();
} }
void MercurialClient::incoming(const QString &repositoryRoot, const QString &repository) void MercurialClient::incoming(const QString &repositoryRoot, const QString &repository)

View File

@@ -1272,28 +1272,28 @@ PerforceResponse PerforcePluginPrivate::synchronousProcess(const QString &workin
process.setStdOutCallback([](const QString &lines) { VcsOutputWindow::append(lines); }); process.setStdOutCallback([](const QString &lines) { VcsOutputWindow::append(lines); });
} }
process.setTimeOutMessageBoxEnabled(true); process.setTimeOutMessageBoxEnabled(true);
const SynchronousProcessResponse sp_resp = process.run({m_settings.p4BinaryPath.value(), args}); process.run({m_settings.p4BinaryPath.value(), args});
PerforceResponse response; PerforceResponse response;
response.error = true; response.error = true;
response.exitCode = sp_resp.exitCode; response.exitCode = process.exitCode();
response.stdErr = sp_resp.stdErr(); response.stdErr = process.stdErr();
response.stdOut = sp_resp.stdOut(); response.stdOut = process.stdOut();
switch (sp_resp.result) { switch (process.result()) {
case SynchronousProcessResponse::Finished: case QtcProcess::Finished:
response.error = false; response.error = false;
break; break;
case SynchronousProcessResponse::FinishedError: case QtcProcess::FinishedError:
response.message = msgExitCode(sp_resp.exitCode); response.message = msgExitCode(process.exitCode());
response.error = !(flags & IgnoreExitCode); response.error = !(flags & IgnoreExitCode);
break; break;
case SynchronousProcessResponse::TerminatedAbnormally: case QtcProcess::TerminatedAbnormally:
response.message = msgCrash(); response.message = msgCrash();
break; break;
case SynchronousProcessResponse::StartFailed: case QtcProcess::StartFailed:
response.message = msgNotStarted(m_settings.p4BinaryPath.value()); response.message = msgNotStarted(m_settings.p4BinaryPath.value());
break; break;
case SynchronousProcessResponse::Hang: case QtcProcess::Hang:
response.message = msgCrash(); response.message = msgCrash();
break; break;
} }

View File

@@ -112,11 +112,11 @@ static bool
if (CustomWizard::verbose()) if (CustomWizard::verbose())
qDebug("In %s, running:\n%s\n", qPrintable(workingDirectory), qDebug("In %s, running:\n%s\n", qPrintable(workingDirectory),
qPrintable(cmd.toUserOutput())); qPrintable(cmd.toUserOutput()));
Utils::SynchronousProcessResponse response = process.run(cmd); process.run(cmd);
if (response.result != Utils::SynchronousProcessResponse::Finished) { if (process.result() != Utils::QtcProcess::Finished) {
*errorMessage = QString::fromLatin1("Generator script failed: %1") *errorMessage = QString::fromLatin1("Generator script failed: %1")
.arg(response.exitMessage(binary, 30)); .arg(process.exitMessage(binary, 30));
const QString stdErr = response.stdErr(); const QString stdErr = process.stdErr();
if (!stdErr.isEmpty()) { if (!stdErr.isEmpty()) {
errorMessage->append(QLatin1Char('\n')); errorMessage->append(QLatin1Char('\n'));
errorMessage->append(stdErr); errorMessage->append(stdErr);
@@ -124,7 +124,7 @@ static bool
return false; return false;
} }
if (stdOut) { if (stdOut) {
*stdOut = response.stdOut(); *stdOut = process.stdOut();
if (CustomWizard::verbose()) if (CustomWizard::verbose())
qDebug("Output: '%s'\n", qPrintable(*stdOut)); qDebug("Output: '%s'\n", qPrintable(*stdOut));
} }

View File

@@ -88,15 +88,15 @@ static QByteArray runGcc(const FilePath &gcc, const QStringList &arguments, cons
cpp.setEnvironment(environment); cpp.setEnvironment(environment);
cpp.setTimeoutS(10); cpp.setTimeoutS(10);
CommandLine cmdLine(gcc, arguments); CommandLine cmdLine(gcc, arguments);
SynchronousProcessResponse response = cpp.runBlocking(cmdLine); cpp.runBlocking(cmdLine);
if (response.result != SynchronousProcessResponse::Finished || response.exitCode != 0) { if (cpp.result() != QtcProcess::Finished || cpp.exitCode() != 0) {
Core::MessageManager::writeFlashing({"Compiler feature detection failure!", Core::MessageManager::writeFlashing({"Compiler feature detection failure!",
response.exitMessage(cmdLine.toUserOutput(), 10), cpp.exitMessage(cmdLine.toUserOutput(), 10),
QString::fromUtf8(response.allRawOutput())}); QString::fromUtf8(cpp.allRawOutput())});
return QByteArray(); return QByteArray();
} }
return response.allOutput().toUtf8(); return cpp.allOutput().toUtf8();
} }
static ProjectExplorer::Macros gccPredefinedMacros(const FilePath &gcc, static ProjectExplorer::Macros gccPredefinedMacros(const FilePath &gcc,

View File

@@ -234,35 +234,35 @@ static Utils::optional<VisualStudioInstallation> detectCppBuildTools2017()
static QVector<VisualStudioInstallation> detectVisualStudioFromVsWhere(const QString &vswhere) static QVector<VisualStudioInstallation> detectVisualStudioFromVsWhere(const QString &vswhere)
{ {
QVector<VisualStudioInstallation> installations; QVector<VisualStudioInstallation> installations;
Utils::SynchronousProcess vsWhereProcess; SynchronousProcess vsWhereProcess;
vsWhereProcess.setCodec(QTextCodec::codecForName("UTF-8")); vsWhereProcess.setCodec(QTextCodec::codecForName("UTF-8"));
const int timeoutS = 5; const int timeoutS = 5;
vsWhereProcess.setTimeoutS(timeoutS); vsWhereProcess.setTimeoutS(timeoutS);
const CommandLine cmd(vswhere, const CommandLine cmd(vswhere,
{"-products", "*", "-prerelease", "-legacy", "-format", "json", "-utf8"}); {"-products", "*", "-prerelease", "-legacy", "-format", "json", "-utf8"});
Utils::SynchronousProcessResponse response = vsWhereProcess.runBlocking(cmd); vsWhereProcess.runBlocking(cmd);
switch (response.result) { switch (vsWhereProcess.result()) {
case Utils::SynchronousProcessResponse::Finished: case QtcProcess::Finished:
break; break;
case Utils::SynchronousProcessResponse::StartFailed: case QtcProcess::StartFailed:
qWarning().noquote() << QDir::toNativeSeparators(vswhere) << "could not be started."; qWarning().noquote() << QDir::toNativeSeparators(vswhere) << "could not be started.";
return installations; return installations;
case Utils::SynchronousProcessResponse::FinishedError: case QtcProcess::FinishedError:
qWarning().noquote().nospace() << QDir::toNativeSeparators(vswhere) qWarning().noquote().nospace() << QDir::toNativeSeparators(vswhere)
<< " finished with exit code " << " finished with exit code "
<< response.exitCode << "."; << vsWhereProcess.exitCode() << ".";
return installations; return installations;
case Utils::SynchronousProcessResponse::TerminatedAbnormally: case QtcProcess::TerminatedAbnormally:
qWarning().noquote().nospace() qWarning().noquote().nospace()
<< QDir::toNativeSeparators(vswhere) << " crashed. Exit code: " << response.exitCode; << QDir::toNativeSeparators(vswhere) << " crashed. Exit code: " << vsWhereProcess.exitCode();
return installations; return installations;
case Utils::SynchronousProcessResponse::Hang: case QtcProcess::Hang:
qWarning().noquote() << QDir::toNativeSeparators(vswhere) << "did not finish in" << timeoutS qWarning().noquote() << QDir::toNativeSeparators(vswhere) << "did not finish in" << timeoutS
<< "seconds."; << "seconds.";
return installations; return installations;
} }
QByteArray output = response.stdOut().toUtf8(); QByteArray output = vsWhereProcess.stdOut().toUtf8();
QJsonParseError error; QJsonParseError error;
const QJsonDocument doc = QJsonDocument::fromJson(output, &error); const QJsonDocument doc = QJsonDocument::fromJson(output, &error);
if (error.error != QJsonParseError::NoError || doc.isNull()) { if (error.error != QJsonParseError::NoError || doc.isNull()) {
@@ -621,11 +621,11 @@ Macros MsvcToolChain::msvcPredefinedMacros(const QStringList &cxxflags,
if (language() == ProjectExplorer::Constants::C_LANGUAGE_ID) if (language() == ProjectExplorer::Constants::C_LANGUAGE_ID)
arguments << QLatin1String("/TC"); arguments << QLatin1String("/TC");
arguments << toProcess << QLatin1String("/EP") << QDir::toNativeSeparators(saver.fileName()); arguments << toProcess << QLatin1String("/EP") << QDir::toNativeSeparators(saver.fileName());
SynchronousProcessResponse response = cpp.runBlocking({binary, arguments}); cpp.runBlocking({binary, arguments});
if (response.result != Utils::SynchronousProcessResponse::Finished || response.exitCode != 0) if (cpp.result() != QtcProcess::Finished || cpp.exitCode() != 0)
return predefinedMacros; return predefinedMacros;
const QStringList output = Utils::filtered(response.stdOut().split('\n'), const QStringList output = Utils::filtered(cpp.stdOut().split('\n'),
[](const QString &s) { return s.startsWith('V'); }); [](const QString &s) { return s.startsWith('V'); });
for (const QString &line : output) for (const QString &line : output)
predefinedMacros.append(Macro::fromKeyValue(line.mid(1))); predefinedMacros.append(Macro::fromKeyValue(line.mid(1)));
@@ -1495,13 +1495,12 @@ static const MsvcToolChain *findMsvcToolChain(const QString &displayedVarsBat)
static QVersionNumber clangClVersion(const QString &clangClPath) static QVersionNumber clangClVersion(const QString &clangClPath)
{ {
SynchronousProcess clangClProcess; SynchronousProcess clangClProcess;
const SynchronousProcessResponse response clangClProcess.runBlocking({clangClPath, {"--version"}});
= clangClProcess.runBlocking({clangClPath, {"--version"}}); if (clangClProcess.result() != QtcProcess::Finished || clangClProcess.exitCode() != 0)
if (response.result != SynchronousProcessResponse::Finished || response.exitCode != 0)
return {}; return {};
const QRegularExpressionMatch match = QRegularExpression( const QRegularExpressionMatch match = QRegularExpression(
QStringLiteral("clang version (\\d+(\\.\\d+)+)")) QStringLiteral("clang version (\\d+(\\.\\d+)+)"))
.match(response.stdOut()); .match(clangClProcess.stdOut());
if (!match.hasMatch()) if (!match.hasMatch())
return {}; return {};
return QVersionNumber::fromString(match.captured(1)); return QVersionNumber::fromString(match.captured(1));
@@ -1677,20 +1676,20 @@ Macros ClangClToolChain::msvcPredefinedMacros(const QStringList &cxxflags,
if (!cxxflags.contains("--driver-mode=g++")) if (!cxxflags.contains("--driver-mode=g++"))
return MsvcToolChain::msvcPredefinedMacros(cxxflags, env); return MsvcToolChain::msvcPredefinedMacros(cxxflags, env);
Utils::SynchronousProcess cpp; SynchronousProcess cpp;
cpp.setEnvironment(env); cpp.setEnvironment(env);
cpp.setWorkingDirectory(Utils::TemporaryDirectory::masterDirectoryPath()); cpp.setWorkingDirectory(Utils::TemporaryDirectory::masterDirectoryPath());
QStringList arguments = cxxflags; QStringList arguments = cxxflags;
arguments.append(gccPredefinedMacrosOptions(language())); arguments.append(gccPredefinedMacrosOptions(language()));
arguments.append("-"); arguments.append("-");
Utils::SynchronousProcessResponse response = cpp.runBlocking({compilerCommand(), arguments}); cpp.runBlocking({compilerCommand(), arguments});
if (response.result != Utils::SynchronousProcessResponse::Finished || response.exitCode != 0) { if (cpp.result() != Utils::QtcProcess::Finished || cpp.exitCode() != 0) {
// Show the warning but still parse the output. // Show the warning but still parse the output.
QTC_CHECK(false && "clang-cl exited with non-zero code."); QTC_CHECK(false && "clang-cl exited with non-zero code.");
} }
return Macro::toMacros(response.allRawOutput()); return Macro::toMacros(cpp.allRawOutput());
} }
Utils::LanguageVersion ClangClToolChain::msvcLanguageVersion(const QStringList &cxxflags, Utils::LanguageVersion ClangClToolChain::msvcLanguageVersion(const QStringList &cxxflags,
@@ -2022,12 +2021,12 @@ Utils::optional<QString> MsvcToolChain::generateEnvironmentSettings(const Utils:
qDebug() << "readEnvironmentSetting: " << call << cmd.toUserOutput() qDebug() << "readEnvironmentSetting: " << call << cmd.toUserOutput()
<< " Env: " << runEnv.size(); << " Env: " << runEnv.size();
run.setCodec(QTextCodec::codecForName("UTF-8")); run.setCodec(QTextCodec::codecForName("UTF-8"));
Utils::SynchronousProcessResponse response = run.runBlocking(cmd); run.runBlocking(cmd);
if (response.result != Utils::SynchronousProcessResponse::Finished) { if (run.result() != QtcProcess::Finished) {
const QString message = !response.stdErr().isEmpty() const QString message = !run.stdErr().isEmpty()
? response.stdErr() ? run.stdErr()
: response.exitMessage(cmdPath.toString(), 10); : run.exitMessage(cmdPath.toString(), 10);
qWarning().noquote() << message; qWarning().noquote() << message;
QString command = QDir::toNativeSeparators(batchFile); QString command = QDir::toNativeSeparators(batchFile);
if (!batchArgs.isEmpty()) if (!batchArgs.isEmpty())
@@ -2039,7 +2038,7 @@ Utils::optional<QString> MsvcToolChain::generateEnvironmentSettings(const Utils:
} }
// The SDK/MSVC scripts do not return exit codes != 0. Check on stdout. // The SDK/MSVC scripts do not return exit codes != 0. Check on stdout.
const QString stdOut = response.stdOut(); const QString stdOut = run.stdOut();
// //
// Now parse the file to get the environment settings // Now parse the file to get the environment settings

View File

@@ -281,10 +281,9 @@ Interpreter::Interpreter(const FilePath &python, const QString &defaultName, boo
SynchronousProcess pythonProcess; SynchronousProcess pythonProcess;
pythonProcess.setProcessChannelMode(QProcess::MergedChannels); pythonProcess.setProcessChannelMode(QProcess::MergedChannels);
pythonProcess.setTimeoutS(1); pythonProcess.setTimeoutS(1);
SynchronousProcessResponse response = pythonProcess.runBlocking( pythonProcess.runBlocking({python, {"--version"}});
CommandLine(python, {"--version"})); if (pythonProcess.result() == QtcProcess::Finished)
if (response.result == SynchronousProcessResponse::Finished) name = pythonProcess.stdOut().trimmed();
name = response.stdOut().trimmed();
if (name.isEmpty()) if (name.isEmpty())
name = defaultName; name = defaultName;
if (windowedSuffix) if (windowedSuffix)

View File

@@ -87,10 +87,10 @@ static QString pythonName(const FilePath &pythonPath)
SynchronousProcess pythonProcess; SynchronousProcess pythonProcess;
pythonProcess.setTimeoutS(2); pythonProcess.setTimeoutS(2);
const CommandLine pythonVersionCommand(pythonPath, {"--version"}); const CommandLine pythonVersionCommand(pythonPath, {"--version"});
const SynchronousProcessResponse response = pythonProcess.runBlocking(pythonVersionCommand); pythonProcess.runBlocking(pythonVersionCommand);
if (response.result != SynchronousProcessResponse::Finished) if (pythonProcess.result() != QtcProcess::Finished)
return {}; return {};
name = response.allOutput().trimmed(); name = pythonProcess.allOutput().trimmed();
nameForPython[pythonPath] = name; nameForPython[pythonPath] = name;
} }
return name; return name;
@@ -109,7 +109,7 @@ FilePath getPylsModulePath(CommandLine pylsCommand)
Environment env = pythonProcess.environment(); Environment env = pythonProcess.environment();
env.set("PYTHONVERBOSE", "x"); env.set("PYTHONVERBOSE", "x");
pythonProcess.setEnvironment(env); pythonProcess.setEnvironment(env);
SynchronousProcessResponse response = pythonProcess.runBlocking(pylsCommand); pythonProcess.runBlocking(pylsCommand);
static const QString pylsInitPattern = "(.*)" static const QString pylsInitPattern = "(.*)"
+ QRegularExpression::escape( + QRegularExpression::escape(
@@ -120,7 +120,7 @@ FilePath getPylsModulePath(CommandLine pylsCommand)
static const QRegularExpression regexNotCached(" code object from " + pylsInitPattern, static const QRegularExpression regexNotCached(" code object from " + pylsInitPattern,
QRegularExpression::MultilineOption); QRegularExpression::MultilineOption);
const QString &output = response.allOutput(); const QString output = pythonProcess.allOutput();
for (const auto &regex : {regexCached, regexNotCached}) { for (const auto &regex : {regexCached, regexNotCached}) {
const QRegularExpressionMatch result = regex.match(output); const QRegularExpressionMatch result = regex.match(output);
if (result.hasMatch()) { if (result.hasMatch()) {
@@ -148,7 +148,6 @@ QList<const StdIOSettings *> configuredPythonLanguageServer()
static PythonLanguageServerState checkPythonLanguageServer(const FilePath &python) static PythonLanguageServerState checkPythonLanguageServer(const FilePath &python)
{ {
using namespace LanguageClient; using namespace LanguageClient;
SynchronousProcess pythonProcess;
const CommandLine pythonLShelpCommand(python, {"-m", "pyls", "-h"}); const CommandLine pythonLShelpCommand(python, {"-m", "pyls", "-h"});
const FilePath &modulePath = getPylsModulePath(pythonLShelpCommand); const FilePath &modulePath = getPylsModulePath(pythonLShelpCommand);
for (const StdIOSettings *serverSetting : configuredPythonLanguageServer()) { for (const StdIOSettings *serverSetting : configuredPythonLanguageServer()) {
@@ -159,13 +158,14 @@ static PythonLanguageServerState checkPythonLanguageServer(const FilePath &pytho
} }
} }
SynchronousProcessResponse response = pythonProcess.runBlocking(pythonLShelpCommand); SynchronousProcess pythonProcess;
if (response.allOutput().contains("Python Language Server")) pythonProcess.runBlocking(pythonLShelpCommand);
if (pythonProcess.allOutput().contains("Python Language Server"))
return {PythonLanguageServerState::AlreadyInstalled, modulePath}; return {PythonLanguageServerState::AlreadyInstalled, modulePath};
const CommandLine pythonPipVersionCommand(python, {"-m", "pip", "-V"}); const CommandLine pythonPipVersionCommand(python, {"-m", "pip", "-V"});
response = pythonProcess.runBlocking(pythonPipVersionCommand); pythonProcess.runBlocking(pythonPipVersionCommand);
if (response.allOutput().startsWith("pip ")) if (pythonProcess.allOutput().startsWith("pip "))
return {PythonLanguageServerState::CanBeInstalled, FilePath()}; return {PythonLanguageServerState::CanBeInstalled, FilePath()};
else else
return {PythonLanguageServerState::CanNotBeInstalled, FilePath()}; return {PythonLanguageServerState::CanNotBeInstalled, FilePath()};

View File

@@ -91,10 +91,10 @@ bool SubversionClient::doCommit(const QString &repositoryRoot,
<< QLatin1String("--file") << commitMessageFile; << QLatin1String("--file") << commitMessageFile;
QStringList args(vcsCommandString(CommitCommand)); QStringList args(vcsCommandString(CommitCommand));
SynchronousProcessResponse resp = SynchronousProcess proc;
vcsSynchronousExec(repositoryRoot, args << svnExtraOptions << escapeFiles(files), vcsSynchronousExec(proc, repositoryRoot, args << svnExtraOptions << escapeFiles(files),
VcsCommand::ShowStdOut | VcsCommand::NoFullySync); VcsCommand::ShowStdOut | VcsCommand::NoFullySync);
return resp.result == SynchronousProcessResponse::Finished; return proc.result() == QtcProcess::Finished;
} }
void SubversionClient::commit(const QString &repositoryRoot, void SubversionClient::commit(const QString &repositoryRoot,
@@ -151,12 +151,12 @@ QString SubversionClient::synchronousTopic(const QString &repository) const
else else
svnVersionBinary = svnVersionBinary.left(pos + 1); svnVersionBinary = svnVersionBinary.left(pos + 1);
svnVersionBinary.append(HostOsInfo::withExecutableSuffix("svnversion")); svnVersionBinary.append(HostOsInfo::withExecutableSuffix("svnversion"));
const SynchronousProcessResponse result SynchronousProcess proc;
= vcsFullySynchronousExec(repository, {svnVersionBinary, args}); vcsFullySynchronousExec(proc, repository, {svnVersionBinary, args});
if (result.result != SynchronousProcessResponse::Finished) if (proc.result() != QtcProcess::Finished)
return QString(); return QString();
return result.stdOut().trimmed(); return proc.stdOut().trimmed();
} }
QString SubversionClient::escapeFile(const QString &file) QString SubversionClient::escapeFile(const QString &file)

View File

@@ -1026,14 +1026,14 @@ SubversionResponse SubversionPluginPrivate::runSvn(const QString &workingDir,
return response; return response;
} }
const SynchronousProcessResponse sp_resp SynchronousProcess proc;
= m_client->vcsFullySynchronousExec(workingDir, arguments, flags, timeOutS, outputCodec); m_client->vcsFullySynchronousExec(proc, workingDir, arguments, flags, timeOutS, outputCodec);
response.error = sp_resp.result != SynchronousProcessResponse::Finished; response.error = proc.result() != QtcProcess::Finished;
if (response.error) if (response.error)
response.message = sp_resp.exitMessage(m_settings.binaryPath.value(), timeOutS); response.message = proc.exitMessage(m_settings.binaryPath.value(), timeOutS);
response.stdErr = sp_resp.stdErr(); response.stdErr = proc.stdErr();
response.stdOut = sp_resp.stdOut(); response.stdOut = proc.stdOut();
return response; return response;
} }

View File

@@ -88,15 +88,15 @@ static FormatTask format(FormatTask task)
// Format temporary file // Format temporary file
QStringList options = task.command.options(); QStringList options = task.command.options();
options.replaceInStrings(QLatin1String("%file"), sourceFile.fileName()); options.replaceInStrings(QLatin1String("%file"), sourceFile.fileName());
Utils::SynchronousProcess process; SynchronousProcess process;
process.setTimeoutS(5); process.setTimeoutS(5);
Utils::SynchronousProcessResponse response = process.runBlocking({executable, options}); process.runBlocking({executable, options});
if (response.result != Utils::SynchronousProcessResponse::Finished) { if (process.result() != QtcProcess::Finished) {
task.error = QString(QT_TRANSLATE_NOOP("TextEditor", "Failed to format: %1.")) task.error = QString(QT_TRANSLATE_NOOP("TextEditor", "Failed to format: %1."))
.arg(response.exitMessage(executable, 5)); .arg(process.exitMessage(executable, 5));
return task; return task;
} }
const QString output = response.stdErr(); const QString output = process.stdErr();
if (!output.isEmpty()) if (!output.isEmpty())
task.error = executable + QLatin1String(": ") + output; task.error = executable + QLatin1String(": ") + output;

View File

@@ -74,10 +74,9 @@ QString findFallbackDefinitionsLocation()
for (auto &program : programs) { for (auto &program : programs) {
Utils::SynchronousProcess process; Utils::SynchronousProcess process;
process.setTimeoutS(5); process.setTimeoutS(5);
Utils::SynchronousProcessResponse response process.runBlocking({program, {"--prefix"}});
= process.runBlocking({program, {"--prefix"}}); if (process.result() == Utils::QtcProcess::Finished) {
if (response.result == Utils::SynchronousProcessResponse::Finished) { QString output = process.stdOut();
QString output = response.stdOut();
output.remove(QLatin1Char('\n')); output.remove(QLatin1Char('\n'));
for (auto &kateSyntaxPath : kateSyntaxPaths) { for (auto &kateSyntaxPath : kateSyntaxPaths) {
dir.setPath(output + kateSyntaxPath); dir.setPath(output + kateSyntaxPath);

View File

@@ -138,7 +138,7 @@ void UpdateInfoPlugin::startCheckForUpdates()
d->m_checkUpdatesCommand->addJob({Utils::FilePath::fromString(d->m_maintenanceTool), {"--checkupdates"}}, d->m_checkUpdatesCommand->addJob({Utils::FilePath::fromString(d->m_maintenanceTool), {"--checkupdates"}},
60 * 3, // 3 minutes timeout 60 * 3, // 3 minutes timeout
/*workingDirectory=*/QString(), /*workingDirectory=*/QString(),
[](int /*exitCode*/) { return Utils::SynchronousProcessResponse::Finished; }); [](int /*exitCode*/) { return Utils::QtcProcess::Finished; });
d->m_checkUpdatesCommand->execute(); d->m_checkUpdatesCommand->execute();
d->m_progress = d->m_checkUpdatesCommand->futureProgress(); d->m_progress = d->m_checkUpdatesCommand->futureProgress();
if (d->m_progress) { if (d->m_progress) {

View File

@@ -154,15 +154,15 @@ QString VcsBaseClientImpl::stripLastNewline(const QString &in)
return in; return in;
} }
SynchronousProcessResponse void VcsBaseClientImpl::vcsFullySynchronousExec(SynchronousProcess &proc,
VcsBaseClientImpl::vcsFullySynchronousExec(const QString &workingDir, const CommandLine &cmdLine, const QString &workingDir, const CommandLine &cmdLine,
unsigned flags, int timeoutS, QTextCodec *codec) const unsigned flags, int timeoutS, QTextCodec *codec) const
{ {
VcsCommand command(workingDir, processEnvironment()); VcsCommand command(workingDir, processEnvironment());
command.addFlags(flags); command.addFlags(flags);
if (codec) if (codec)
command.setCodec(codec); command.setCodec(codec);
return command.runCommand(cmdLine, (timeoutS > 0) ? timeoutS : vcsTimeoutS()); command.runCommand(proc, cmdLine, (timeoutS > 0) ? timeoutS : vcsTimeoutS());
} }
void VcsBaseClientImpl::resetCachedVcsInfo(const QString &workingDir) void VcsBaseClientImpl::resetCachedVcsInfo(const QString &workingDir)
@@ -183,11 +183,11 @@ void VcsBaseClientImpl::annotateRevisionRequested(const QString &workingDirector
annotate(workingDirectory, file, changeCopy, line); annotate(workingDirectory, file, changeCopy, line);
} }
SynchronousProcessResponse void VcsBaseClientImpl::vcsFullySynchronousExec(SynchronousProcess &proc,
VcsBaseClientImpl::vcsFullySynchronousExec(const QString &workingDir, const QStringList &args, const QString &workingDir, const QStringList &args,
unsigned flags, int timeoutS, QTextCodec *codec) const unsigned flags, int timeoutS, QTextCodec *codec) const
{ {
return vcsFullySynchronousExec(workingDir, {vcsBinary(), args}, flags, timeoutS, codec); vcsFullySynchronousExec(proc, workingDir, {vcsBinary(), args}, flags, timeoutS, codec);
} }
VcsCommand *VcsBaseClientImpl::vcsExec(const QString &workingDirectory, const QStringList &arguments, VcsCommand *VcsBaseClientImpl::vcsExec(const QString &workingDirectory, const QStringList &arguments,
@@ -204,13 +204,16 @@ VcsCommand *VcsBaseClientImpl::vcsExec(const QString &workingDirectory, const QS
return command; return command;
} }
SynchronousProcessResponse VcsBaseClientImpl::vcsSynchronousExec(const QString &workingDir, void VcsBaseClientImpl::vcsSynchronousExec(SynchronousProcess &proc, const QString &workingDir,
const QStringList &args, const QStringList &args,
unsigned flags, unsigned flags,
QTextCodec *outputCodec) const QTextCodec *outputCodec) const
{ {
return VcsBase::runVcs(workingDir, {vcsBinary(), args}, vcsTimeoutS(), flags, Environment env = processEnvironment();
outputCodec, processEnvironment()); VcsCommand command(workingDir, env.size() == 0 ? Environment::systemEnvironment() : env);
command.addFlags(flags);
command.setCodec(outputCodec);
command.runCommand(proc, {vcsBinary(), args}, vcsTimeoutS());
} }
int VcsBaseClientImpl::vcsTimeoutS() const int VcsBaseClientImpl::vcsTimeoutS() const
@@ -264,10 +267,11 @@ bool VcsBaseClient::synchronousCreateRepository(const QString &workingDirectory,
{ {
QStringList args(vcsCommandString(CreateRepositoryCommand)); QStringList args(vcsCommandString(CreateRepositoryCommand));
args << extraOptions; args << extraOptions;
SynchronousProcessResponse result = vcsFullySynchronousExec(workingDirectory, args); SynchronousProcess proc;
if (result.result != SynchronousProcessResponse::Finished) vcsFullySynchronousExec(proc, workingDirectory, args);
if (proc.result() != QtcProcess::Finished)
return false; return false;
VcsOutputWindow::append(result.stdOut()); VcsOutputWindow::append(proc.stdOut());
resetCachedVcsInfo(workingDirectory); resetCachedVcsInfo(workingDirectory);
@@ -283,9 +287,10 @@ bool VcsBaseClient::synchronousClone(const QString &workingDir,
args << vcsCommandString(CloneCommand) args << vcsCommandString(CloneCommand)
<< extraOptions << srcLocation << dstLocation; << extraOptions << srcLocation << dstLocation;
SynchronousProcessResponse result = vcsFullySynchronousExec(workingDir, args); SynchronousProcess proc;
vcsFullySynchronousExec(proc, workingDir, args);
resetCachedVcsInfo(workingDir); resetCachedVcsInfo(workingDir);
return result.result == SynchronousProcessResponse::Finished; return proc.result() == QtcProcess::Finished;
} }
bool VcsBaseClient::synchronousAdd(const QString &workingDir, const QString &filename, bool VcsBaseClient::synchronousAdd(const QString &workingDir, const QString &filename,
@@ -293,7 +298,9 @@ bool VcsBaseClient::synchronousAdd(const QString &workingDir, const QString &fil
{ {
QStringList args; QStringList args;
args << vcsCommandString(AddCommand) << extraOptions << filename; args << vcsCommandString(AddCommand) << extraOptions << filename;
return vcsFullySynchronousExec(workingDir, args).result == SynchronousProcessResponse::Finished; SynchronousProcess proc;
vcsFullySynchronousExec(proc, workingDir, args);
return proc.result() == QtcProcess::Finished;
} }
bool VcsBaseClient::synchronousRemove(const QString &workingDir, const QString &filename, bool VcsBaseClient::synchronousRemove(const QString &workingDir, const QString &filename,
@@ -301,7 +308,9 @@ bool VcsBaseClient::synchronousRemove(const QString &workingDir, const QString &
{ {
QStringList args; QStringList args;
args << vcsCommandString(RemoveCommand) << extraOptions << filename; args << vcsCommandString(RemoveCommand) << extraOptions << filename;
return vcsFullySynchronousExec(workingDir, args).result == SynchronousProcessResponse::Finished; SynchronousProcess proc;
vcsFullySynchronousExec(proc, workingDir, args);
return proc.result() == QtcProcess::Finished;
} }
bool VcsBaseClient::synchronousMove(const QString &workingDir, bool VcsBaseClient::synchronousMove(const QString &workingDir,
@@ -310,7 +319,9 @@ bool VcsBaseClient::synchronousMove(const QString &workingDir,
{ {
QStringList args; QStringList args;
args << vcsCommandString(MoveCommand) << extraOptions << from << to; args << vcsCommandString(MoveCommand) << extraOptions << from << to;
return vcsFullySynchronousExec(workingDir, args).result == SynchronousProcessResponse::Finished; SynchronousProcess proc;
vcsFullySynchronousExec(proc, workingDir, args);
return proc.result() == QtcProcess::Finished;
} }
bool VcsBaseClient::synchronousPull(const QString &workingDir, bool VcsBaseClient::synchronousPull(const QString &workingDir,
@@ -324,8 +335,9 @@ bool VcsBaseClient::synchronousPull(const QString &workingDir,
VcsCommand::SshPasswordPrompt VcsCommand::SshPasswordPrompt
| VcsCommand::ShowStdOut | VcsCommand::ShowStdOut
| VcsCommand::ShowSuccessMessage; | VcsCommand::ShowSuccessMessage;
const SynchronousProcessResponse resp = vcsSynchronousExec(workingDir, args, flags); SynchronousProcess proc;
const bool ok = resp.result == SynchronousProcessResponse::Finished; vcsSynchronousExec(proc, workingDir, args, flags);
const bool ok = proc.result() == QtcProcess::Finished;
if (ok) if (ok)
emit changed(QVariant(workingDir)); emit changed(QVariant(workingDir));
return ok; return ok;
@@ -342,8 +354,9 @@ bool VcsBaseClient::synchronousPush(const QString &workingDir,
VcsCommand::SshPasswordPrompt VcsCommand::SshPasswordPrompt
| VcsCommand::ShowStdOut | VcsCommand::ShowStdOut
| VcsCommand::ShowSuccessMessage; | VcsCommand::ShowSuccessMessage;
const SynchronousProcessResponse resp = vcsSynchronousExec(workingDir, args, flags); SynchronousProcess proc;
return resp.result == SynchronousProcessResponse::Finished; vcsSynchronousExec(proc, workingDir, args, flags);
return proc.result() == QtcProcess::Finished;
} }
VcsBaseEditorWidget *VcsBaseClient::annotate( VcsBaseEditorWidget *VcsBaseClient::annotate(

View File

@@ -99,12 +99,12 @@ public:
static QString stripLastNewline(const QString &in); static QString stripLastNewline(const QString &in);
// Fully synchronous VCS execution (QProcess-based) // Fully synchronous VCS execution (QProcess-based)
Utils::SynchronousProcessResponse void vcsFullySynchronousExec(Utils::SynchronousProcess &process,
vcsFullySynchronousExec(const QString &workingDir, const QStringList &args, const QString &workingDir, const QStringList &args,
unsigned flags = 0, int timeoutS = -1, QTextCodec *codec = nullptr) const; unsigned flags = 0, int timeoutS = -1, QTextCodec *codec = nullptr) const;
Utils::SynchronousProcessResponse void vcsFullySynchronousExec(Utils::SynchronousProcess &process,
vcsFullySynchronousExec(const QString &workingDir, const Utils::CommandLine &cmdLine, const QString &workingDir, const Utils::CommandLine &cmdLine,
unsigned flags = 0, int timeoutS = -1, QTextCodec *codec = nullptr) const; unsigned flags = 0, int timeoutS = -1, QTextCodec *codec = nullptr) const;
// Simple helper to execute a single command using createCommand and enqueueJob. // Simple helper to execute a single command using createCommand and enqueueJob.
@@ -119,10 +119,11 @@ protected:
// Synchronous VCS execution using Utils::SynchronousProcess, with // Synchronous VCS execution using Utils::SynchronousProcess, with
// log windows updating (using VcsBasePlugin::runVcs with flags) // log windows updating (using VcsBasePlugin::runVcs with flags)
Utils::SynchronousProcessResponse vcsSynchronousExec(const QString &workingDir, void vcsSynchronousExec(Utils::SynchronousProcess &proc,
const QStringList &args, const QString &workingDir,
unsigned flags = 0, const QStringList &args,
QTextCodec *outputCodec = nullptr) const; unsigned flags = 0,
QTextCodec *outputCodec = nullptr) const;
private: private:
void saveSettings(); void saveSettings();

View File

@@ -752,21 +752,6 @@ void setProcessEnvironment(Environment *e, bool forceCLocale, const QString &ssh
e->set("SSH_ASKPASS", sshPromptBinary); e->set("SSH_ASKPASS", sshPromptBinary);
} }
// Run a process synchronously, returning Utils::SynchronousProcessResponse
// response struct and using the VcsBasePlugin flags as applicable
SynchronousProcessResponse runVcs(const QString &workingDir,
const CommandLine &cmd,
int timeOutS,
unsigned flags,
QTextCodec *outputCodec,
const Environment &env)
{
VcsCommand command(workingDir, env.size() == 0 ? Environment::systemEnvironment() : env);
command.addFlags(flags);
command.setCodec(outputCodec);
return command.runCommand(cmd, timeOutS);
}
} // namespace VcsBase } // namespace VcsBase
#include "vcsbaseplugin.moc" #include "vcsbaseplugin.moc"

View File

@@ -147,13 +147,6 @@ VCSBASE_EXPORT void setSource(Core::IDocument *document, const QString &source);
// Returns the source of editor contents. // Returns the source of editor contents.
VCSBASE_EXPORT QString source(Core::IDocument *document); VCSBASE_EXPORT QString source(Core::IDocument *document);
VCSBASE_EXPORT Utils::SynchronousProcessResponse runVcs(const QString &workingDir,
const Utils::CommandLine &cmd,
int timeOutS,
unsigned flags = 0,
QTextCodec *outputCodec = nullptr,
const Utils::Environment &env = {});
class VCSBASE_EXPORT VcsBasePluginPrivate : public Core::IVersionControl class VCSBASE_EXPORT VcsBasePluginPrivate : public Core::IVersionControl
{ {
Q_OBJECT Q_OBJECT

View File

@@ -76,14 +76,14 @@ const Environment VcsCommand::processEnvironment() const
return env; return env;
} }
SynchronousProcessResponse VcsCommand::runCommand(const CommandLine &command, int timeoutS, void VcsCommand::runCommand(SynchronousProcess &proc,
const QString &workingDirectory, const CommandLine &command,
const ExitCodeInterpreter &interpreter) int timeoutS,
const QString &workingDirectory,
const ExitCodeInterpreter &interpreter)
{ {
SynchronousProcessResponse response ShellCommand::runCommand(proc, command, timeoutS, workingDirectory, interpreter);
= Core::ShellCommand::runCommand(command, timeoutS, workingDirectory, interpreter);
emitRepositoryChanged(workingDirectory); emitRepositoryChanged(workingDirectory);
return response;
} }
void VcsCommand::emitRepositoryChanged(const QString &workingDirectory) void VcsCommand::emitRepositoryChanged(const QString &workingDirectory)

View File

@@ -45,10 +45,11 @@ public:
const Utils::Environment processEnvironment() const override; const Utils::Environment processEnvironment() const override;
Utils::SynchronousProcessResponse runCommand(const Utils::CommandLine &command, void runCommand(Utils::SynchronousProcess &process,
int timeoutS, const Utils::CommandLine &command,
const QString &workDirectory = QString(), int timeoutS,
const Utils::ExitCodeInterpreter &interpreter = {}) override; const QString &workDirectory = QString(),
const Utils::ExitCodeInterpreter &interpreter = {}) override;
private: private:
void emitRepositoryChanged(const QString &workingDirectory); void emitRepositoryChanged(const QString &workingDirectory);