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

View File

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

View File

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

View File

@@ -44,10 +44,14 @@ class Environment;
namespace Internal { class QtcProcessPrivate; }
/* Result of SynchronousProcess execution */
class QTCREATOR_UTILS_EXPORT SynchronousProcessResponse
class QTCREATOR_UTILS_EXPORT QtcProcess : public QProcess
{
Q_OBJECT
public:
QtcProcess(QObject *parent = nullptr);
~QtcProcess();
enum Result {
// Finished with return code 0
Finished,
@@ -60,35 +64,6 @@ public:
// Hang, no output after time out
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);
const Environment &environment() const;
@@ -109,12 +84,12 @@ public:
void setCodec(QTextCodec *c);
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
SynchronousProcessResponse run(const CommandLine &cmd, const QByteArray &writeData = {});
void run(const CommandLine &cmd, const QByteArray &writeData = {});
// 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 setStdErrCallback(const std::function<void(const QString &)> &callback);
@@ -129,6 +104,24 @@ public:
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
// and file types.
static QString locateBinary(const QString &binary);
@@ -139,13 +132,17 @@ private:
void setupChildProcess() override;
#endif
friend class SynchronousProcess;
friend QDebug operator<<(QDebug str, const QtcProcess &r);
Internal::QtcProcessPrivate *d = nullptr;
void setProcessEnvironment(const QProcessEnvironment &environment) = 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
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -198,11 +198,12 @@ void AndroidCreateKeystoreCertificate::buttonBoxAccepted()
SynchronousProcess genKeyCertProc;
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"),
response.exitMessage(command.executable().toString(), 15) + '\n' + response.allOutput());
genKeyCertProc.exitMessage(command.executable().toString(), 15)
+ '\n' + genKeyCertProc.allOutput());
return;
}
accept();

View File

@@ -481,9 +481,9 @@ void AndroidDeployQtStep::runCommand(const CommandLine &command)
buildProc.setTimeoutS(2 * 60);
emit addOutput(tr("Package deploy: Running command \"%1\".").arg(command.toUserOutput()),
OutputFormat::NormalMessage);
SynchronousProcessResponse response = buildProc.run(command);
if (response.result != SynchronousProcessResponse::Finished || response.exitCode != 0) {
const QString error = response.exitMessage(command.executable().toString(), 2 * 60);
buildProc.run(command);
if (buildProc.result() != QtcProcess::Finished || buildProc.exitCode() != 0) {
const QString error = buildProc.exitMessage(command.executable().toString(), 2 * 60);
emit addOutput(error, OutputFormat::ErrorMessage);
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});
SynchronousProcess proc;
proc.setTimeoutS(10);
SynchronousProcessResponse response = proc.run(cmd);
return (response.result == SynchronousProcessResponse::Finished && response.exitCode == 0);
proc.run(cmd);
return proc.result() == QtcProcess::Finished && proc.exitCode() == 0;
}
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;
proc.setTimeoutS(10);
SynchronousProcessResponse response
= proc.run({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
return response.result == SynchronousProcessResponse::Finished && response.exitCode == 0;
proc.run({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
return proc.result() == QtcProcess::Finished && proc.exitCode() == 0;
}
bool AndroidManager::checkCertificateExists(const QString &keystorePath,
@@ -568,9 +567,8 @@ bool AndroidManager::checkCertificateExists(const QString &keystorePath,
SynchronousProcess proc;
proc.setTimeoutS(10);
SynchronousProcessResponse response
= proc.run({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
return response.result == SynchronousProcessResponse::Finished && response.exitCode == 0;
proc.run({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
return proc.result() == QtcProcess::Finished && proc.exitCode() == 0;
}
using GradleProperties = QMap<QByteArray, QByteArray>;
@@ -724,15 +722,15 @@ SdkToolResult AndroidManager::runCommand(const CommandLine &command,
SynchronousProcess cmdProc;
cmdProc.setTimeoutS(timeoutS);
qCDebug(androidManagerLog) << "Running command (sync):" << command.toUserOutput();
SynchronousProcessResponse response = cmdProc.run(command, writeData);
cmdResult.m_stdOut = response.stdOut().trimmed();
cmdResult.m_stdErr = response.stdErr().trimmed();
cmdResult.m_success = response.result == SynchronousProcessResponse::Finished;
cmdProc.run(command, writeData);
cmdResult.m_stdOut = cmdProc.stdOut().trimmed();
cmdResult.m_stdErr = cmdProc.stdErr().trimmed();
cmdResult.m_success = cmdProc.result() == QtcProcess::Finished;
qCDebug(androidManagerLog) << "Command finshed (sync):" << command.toUserOutput()
<< "Success:" << cmdResult.m_success
<< "Output:" << response.allRawOutput();
<< "Output:" << cmdProc.allRawOutput();
if (!cmdResult.success())
cmdResult.m_exitMessage = response.exitMessage(command.executable().toString(), timeoutS);
cmdResult.m_exitMessage = cmdProc.exitMessage(command.executable().toString(), timeoutS);
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();
do {
QThread::msleep(200);
const auto out = SynchronousProcess().runBlocking({adbPath, args}).allRawOutput();
SynchronousProcess proc;
proc.runBlocking({adbPath, args});
const QByteArray out = proc.allRawOutput();
if (preNougat) {
processPID = extractPID(out, packageName);
} else {

View File

@@ -149,10 +149,10 @@ static bool sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
proc.setEnvironment(AndroidConfigurations::toolsEnvironment(config));
proc.setTimeoutS(timeout);
proc.setTimeOutMessageBoxEnabled(true);
SynchronousProcessResponse response = proc.run({config.sdkManagerToolPath(), newArgs});
proc.run({config.sdkManagerToolPath(), newArgs});
if (output)
*output = response.allOutput();
return response.result == SynchronousProcessResponse::Finished;
*output = proc.allOutput();
return proc.result() == QtcProcess::Finished;
}
/*!
@@ -189,15 +189,15 @@ static void sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
QObject::connect(&sdkManager, &AndroidSdkManager::cancelActiveOperations,
&proc, &SynchronousProcess::stopProcess);
}
SynchronousProcessResponse response = proc.run({config.sdkManagerToolPath(), newArgs});
proc.run({config.sdkManagerToolPath(), newArgs});
if (assertionFound) {
output.success = false;
output.stdOutput = response.stdOut();
output.stdOutput = proc.stdOut();
output.stdError = QCoreApplication::translate("Android::Internal::AndroidSdkManager",
"The operation requires user interaction. "
"Use the \"sdkmanager\" command-line tool.");
} 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(outpath);
const SynchronousProcessResponse response = cpp.runBlocking(cmd);
if (response.result != SynchronousProcessResponse::Finished
|| response.exitCode != 0) {
qWarning() << response.exitMessage(cmd.toUserOutput(), 10);
cpp.runBlocking(cmd);
if (cpp.result() != QtcProcess::Finished || cpp.exitCode() != 0) {
qWarning() << cpp.exitMessage(cmd.toUserOutput(), 10);
return {};
}
@@ -157,11 +156,11 @@ static HeaderPaths dumpHeaderPaths(const FilePath &compiler, const Id languageId
cmd.addArg(".");
// Note: Response should retutn an error, just don't check on errors.
const SynchronousProcessResponse response = cpp.runBlocking(cmd);
cpp.runBlocking(cmd);
HeaderPaths headerPaths;
const QByteArray output = response.allOutput().toUtf8();
const QByteArray output = cpp.allOutput().toUtf8();
for (auto pos = 0; pos < output.size(); ++pos) {
const int searchIndex = output.indexOf("searched:", pos);
if (searchIndex == -1)

View File

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

View File

@@ -150,9 +150,10 @@ bool BazaarClient::synchronousUncommit(const QString &workingDir,
<< revisionSpec(revision)
<< extraOptions;
const SynchronousProcessResponse result = vcsFullySynchronousExec(workingDir, args);
VcsOutputWindow::append(result.stdOut());
return result.result == SynchronousProcessResponse::Finished;
SynchronousProcess proc;
vcsFullySynchronousExec(proc, workingDir, args);
VcsOutputWindow::append(proc.stdOut());
return proc.result() == QtcProcess::Finished;
}
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"));
args << fileName;
const SynchronousProcessResponse result = vcsFullySynchronousExec(workingDirectory, args);
if (result.result != SynchronousProcessResponse::Finished)
SynchronousProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, args);
if (proc.result() != QtcProcess::Finished)
return false;
return result.rawStdOut.startsWith("unknown");
return proc.rawStdOut().startsWith("unknown");
}
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) {
return [](int code) {
return (code < 0 || code > 2) ? SynchronousProcessResponse::FinishedError
: SynchronousProcessResponse::Finished;
return (code < 0 || code > 2) ? QtcProcess::FinishedError
: QtcProcess::Finished;
};
}
return {};

View File

@@ -84,15 +84,15 @@ static int parseVersion(const QString &text)
static int updateVersionHelper(const Utils::FilePath &command)
{
Utils::SynchronousProcess process;
Utils::SynchronousProcessResponse response = process.runBlocking({command, {"--version"}});
if (response.result != Utils::SynchronousProcessResponse::Finished)
process.runBlocking({command, {"--version"}});
if (process.result() != Utils::QtcProcess::Finished)
return 0;
// 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)
return version;
return parseVersion(response.stdErr().trimmed());
return parseVersion(process.stdErr().trimmed());
}
void ArtisticStyleSettings::updateVersion()
@@ -181,8 +181,8 @@ void ArtisticStyleSettings::createDocumentationFile() const
{
Utils::SynchronousProcess process;
process.setTimeoutS(2);
Utils::SynchronousProcessResponse response = process.runBlocking({command(), {"-h"}});
if (response.result != Utils::SynchronousProcessResponse::Finished)
process.runBlocking({command(), {"-h"}});
if (process.result() != Utils::QtcProcess::Finished)
return;
QFile file(documentationFilePath());
@@ -200,7 +200,7 @@ void ArtisticStyleSettings::createDocumentationFile() const
stream.writeStartElement(Constants::DOCUMENTATION_XMLROOT);
// 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 docu;
for (QString line : lines) {

View File

@@ -150,9 +150,8 @@ void UncrustifySettings::createDocumentationFile() const
{
Utils::SynchronousProcess process;
process.setTimeoutS(2);
Utils::SynchronousProcessResponse response
= process.runBlocking({command(), {"--show-config"}});
if (response.result != Utils::SynchronousProcessResponse::Finished)
process.runBlocking({command(), {"--show-config"}});
if (process.result() != Utils::QtcProcess::Finished)
return;
QFile file(documentationFilePath());
@@ -169,7 +168,7 @@ void UncrustifySettings::createDocumentationFile() const
stream.writeComment("Created " + QDateTime::currentDateTime().toString(Qt::ISODate));
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();
for (int i = 0; i < totalLines; ++i) {
const QString &line = lines.at(i);

View File

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

View File

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

View File

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

View File

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

View File

@@ -116,7 +116,7 @@ public:
private:
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);
QStringList parseVariableOutput(const QString &output);

View File

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

View File

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

View File

@@ -743,11 +743,11 @@ void DebuggerItemManagerPrivate::autoDetectGdbOrLldbDebuggers()
FilePaths suspects;
if (HostOsInfo::isMacHost()) {
SynchronousProcess lldbInfo;
lldbInfo.setTimeoutS(2);
SynchronousProcessResponse response = lldbInfo.runBlocking({"xcrun", {"--find", "lldb"}});
if (response.result == Utils::SynchronousProcessResponse::Finished) {
QString lPath = response.allOutput().trimmed();
SynchronousProcess proc;
proc.setTimeoutS(2);
proc.runBlocking({"xcrun", {"--find", "lldb"}});
if (proc.result() == QtcProcess::Finished) {
QString lPath = proc.allOutput().trimmed();
if (!lPath.isEmpty()) {
const QFileInfo fi(lPath);
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::setupEnglishOutput(&envLang);
proc.setEnvironment(envLang);
SynchronousProcessResponse response = proc.runBlocking({debugger.executable, args});
proc.runBlocking({debugger.executable, args});
if (response.result == SynchronousProcessResponse::Finished) {
QString output = response.stdOut();
if (proc.result() == QtcProcess::Finished) {
QString output = proc.stdOut();
// Core was generated by `/data/dev/creator-2.6/bin/qtcreator'.
// Program terminated with signal 11, Segmentation fault.
int pos1 = output.indexOf("Core was generated by");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -83,12 +83,12 @@ static bool runCommand(const CommandLine &command, QString *stdOutput, QString *
{
SynchronousProcess p;
p.setTimeoutS(-1);
SynchronousProcessResponse resp = p.runBlocking(command);
p.runBlocking(command);
if (stdOutput)
*stdOutput = resp.stdOut();
*stdOutput = p.stdOut();
if (allOutput)
*allOutput = resp.allOutput();
return resp.result == SynchronousProcessResponse::Finished;
*allOutput = p.allOutput();
return p.result() == QtcProcess::Finished;
}
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.
const QStringList args(QLatin1String("manifest"));
const SynchronousProcessResponse result = vcsFullySynchronousExec(repository, args);
SynchronousProcess proc;
vcsFullySynchronousExec(proc, repository, args);
const QDir repositoryDir(repository);
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) {
const QFileInfo managedFile(repositoryDir, fileName);
if (needle == managedFile)
@@ -126,17 +127,17 @@ bool MercurialClient::synchronousClone(const QString &workingDir,
if (workingDirectory.exists()) {
// Let's make first init
QStringList arguments(QLatin1String("init"));
const SynchronousProcessResponse resp = vcsFullySynchronousExec(
workingDirectory.path(), arguments);
if (resp.result != SynchronousProcessResponse::Finished)
SynchronousProcess proc;
vcsFullySynchronousExec(proc, workingDirectory.path(), arguments);
if (proc.result() != QtcProcess::Finished)
return false;
// Then pull remote repository
arguments.clear();
arguments << QLatin1String("pull") << dstLocation;
const SynchronousProcessResponse resp1 = vcsSynchronousExec(
workingDirectory.path(), arguments, flags);
if (resp1.result != SynchronousProcessResponse::Finished)
SynchronousProcess proc1;
vcsSynchronousExec(proc1, workingDirectory.path(), arguments, flags);
if (proc1.result() != QtcProcess::Finished)
return false;
// By now, there is no hgrc file -> create it
@@ -151,16 +152,16 @@ bool MercurialClient::synchronousClone(const QString &workingDir,
// And last update repository
arguments.clear();
arguments << QLatin1String("update");
const SynchronousProcessResponse resp2 = vcsSynchronousExec(
workingDirectory.path(), arguments, flags);
return resp2.result == SynchronousProcessResponse::Finished;
SynchronousProcess proc2;
vcsSynchronousExec(proc2, workingDirectory.path(), arguments, flags);
return proc2.result() == QtcProcess::Finished;
} else {
QStringList arguments(QLatin1String("clone"));
arguments << dstLocation << workingDirectory.dirName();
workingDirectory.cdUp();
const SynchronousProcessResponse resp = vcsSynchronousExec(
workingDirectory.path(), arguments, flags);
return resp.result == SynchronousProcessResponse::Finished;
SynchronousProcess proc;
vcsSynchronousExec(proc, workingDirectory.path(), arguments, flags);
return proc.result() == QtcProcess::Finished;
}
}
@@ -177,11 +178,15 @@ bool MercurialClient::synchronousPull(const QString &workingDir, const QString &
// cause mercurial doesn`t understand LANG
Environment env = Environment::systemEnvironment();
env.set("LANGUAGE", "C");
const SynchronousProcessResponse resp = VcsBase::runVcs(
workingDir, {vcsBinary(), args}, vcsTimeoutS(), flags, nullptr, env);
const bool ok = resp.result == SynchronousProcessResponse::Finished;
SynchronousProcess proc;
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;
}
@@ -218,22 +223,25 @@ QStringList MercurialClient::parentRevisionsSync(const QString &workingDirectory
args << QLatin1String("parents") << QLatin1String("-r") <<revision;
if (!file.isEmpty())
args << file;
const SynchronousProcessResponse resp = vcsFullySynchronousExec(workingDirectory, args);
if (resp.result != SynchronousProcessResponse::Finished)
SynchronousProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, args);
if (proc.result() != QtcProcess::Finished)
return QStringList();
/* Looks like: \code
changeset: 0:031a48610fba
user: ...
\endcode */
// 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) {
VcsOutputWindow::appendSilently(msgParentRevisionFailed(workingDirectory, revision, msgParseParentsOutputFailed(resp.stdOut())));
VcsOutputWindow::appendSilently(
msgParentRevisionFailed(workingDirectory, revision, msgParseParentsOutputFailed(proc.stdOut())));
return QStringList();
}
QStringList changeSets = lines.front().simplified().split(QLatin1Char(' '));
if (changeSets.size() < 2) {
VcsOutputWindow::appendSilently(msgParentRevisionFailed(workingDirectory, revision, msgParseParentsOutputFailed(resp.stdOut())));
VcsOutputWindow::appendSilently(
msgParentRevisionFailed(workingDirectory, revision, msgParseParentsOutputFailed(proc.stdOut())));
return QStringList();
}
// Remove revision numbers
@@ -258,10 +266,11 @@ QString MercurialClient::shortDescriptionSync(const QString &workingDirectory,
if (!format.isEmpty())
args << QLatin1String("--template") << format;
const SynchronousProcessResponse resp = vcsFullySynchronousExec(workingDirectory, args);
if (resp.result != SynchronousProcessResponse::Finished)
SynchronousProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, args);
if (proc.result() != QtcProcess::Finished)
return revision;
return stripLastNewline(resp.stdOut());
return stripLastNewline(proc.stdOut());
}
// Default format: "SHA1 (author summmary)"
@@ -277,7 +286,9 @@ bool MercurialClient::managesFile(const QString &workingDirectory, const QString
{
QStringList args;
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)

View File

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

View File

@@ -112,11 +112,11 @@ static bool
if (CustomWizard::verbose())
qDebug("In %s, running:\n%s\n", qPrintable(workingDirectory),
qPrintable(cmd.toUserOutput()));
Utils::SynchronousProcessResponse response = process.run(cmd);
if (response.result != Utils::SynchronousProcessResponse::Finished) {
process.run(cmd);
if (process.result() != Utils::QtcProcess::Finished) {
*errorMessage = QString::fromLatin1("Generator script failed: %1")
.arg(response.exitMessage(binary, 30));
const QString stdErr = response.stdErr();
.arg(process.exitMessage(binary, 30));
const QString stdErr = process.stdErr();
if (!stdErr.isEmpty()) {
errorMessage->append(QLatin1Char('\n'));
errorMessage->append(stdErr);
@@ -124,7 +124,7 @@ static bool
return false;
}
if (stdOut) {
*stdOut = response.stdOut();
*stdOut = process.stdOut();
if (CustomWizard::verbose())
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.setTimeoutS(10);
CommandLine cmdLine(gcc, arguments);
SynchronousProcessResponse response = cpp.runBlocking(cmdLine);
if (response.result != SynchronousProcessResponse::Finished || response.exitCode != 0) {
cpp.runBlocking(cmdLine);
if (cpp.result() != QtcProcess::Finished || cpp.exitCode() != 0) {
Core::MessageManager::writeFlashing({"Compiler feature detection failure!",
response.exitMessage(cmdLine.toUserOutput(), 10),
QString::fromUtf8(response.allRawOutput())});
cpp.exitMessage(cmdLine.toUserOutput(), 10),
QString::fromUtf8(cpp.allRawOutput())});
return QByteArray();
}
return response.allOutput().toUtf8();
return cpp.allOutput().toUtf8();
}
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)
{
QVector<VisualStudioInstallation> installations;
Utils::SynchronousProcess vsWhereProcess;
SynchronousProcess vsWhereProcess;
vsWhereProcess.setCodec(QTextCodec::codecForName("UTF-8"));
const int timeoutS = 5;
vsWhereProcess.setTimeoutS(timeoutS);
const CommandLine cmd(vswhere,
{"-products", "*", "-prerelease", "-legacy", "-format", "json", "-utf8"});
Utils::SynchronousProcessResponse response = vsWhereProcess.runBlocking(cmd);
switch (response.result) {
case Utils::SynchronousProcessResponse::Finished:
vsWhereProcess.runBlocking(cmd);
switch (vsWhereProcess.result()) {
case QtcProcess::Finished:
break;
case Utils::SynchronousProcessResponse::StartFailed:
case QtcProcess::StartFailed:
qWarning().noquote() << QDir::toNativeSeparators(vswhere) << "could not be started.";
return installations;
case Utils::SynchronousProcessResponse::FinishedError:
case QtcProcess::FinishedError:
qWarning().noquote().nospace() << QDir::toNativeSeparators(vswhere)
<< " finished with exit code "
<< response.exitCode << ".";
<< vsWhereProcess.exitCode() << ".";
return installations;
case Utils::SynchronousProcessResponse::TerminatedAbnormally:
case QtcProcess::TerminatedAbnormally:
qWarning().noquote().nospace()
<< QDir::toNativeSeparators(vswhere) << " crashed. Exit code: " << response.exitCode;
<< QDir::toNativeSeparators(vswhere) << " crashed. Exit code: " << vsWhereProcess.exitCode();
return installations;
case Utils::SynchronousProcessResponse::Hang:
case QtcProcess::Hang:
qWarning().noquote() << QDir::toNativeSeparators(vswhere) << "did not finish in" << timeoutS
<< "seconds.";
return installations;
}
QByteArray output = response.stdOut().toUtf8();
QByteArray output = vsWhereProcess.stdOut().toUtf8();
QJsonParseError error;
const QJsonDocument doc = QJsonDocument::fromJson(output, &error);
if (error.error != QJsonParseError::NoError || doc.isNull()) {
@@ -621,11 +621,11 @@ Macros MsvcToolChain::msvcPredefinedMacros(const QStringList &cxxflags,
if (language() == ProjectExplorer::Constants::C_LANGUAGE_ID)
arguments << QLatin1String("/TC");
arguments << toProcess << QLatin1String("/EP") << QDir::toNativeSeparators(saver.fileName());
SynchronousProcessResponse response = cpp.runBlocking({binary, arguments});
if (response.result != Utils::SynchronousProcessResponse::Finished || response.exitCode != 0)
cpp.runBlocking({binary, arguments});
if (cpp.result() != QtcProcess::Finished || cpp.exitCode() != 0)
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'); });
for (const QString &line : output)
predefinedMacros.append(Macro::fromKeyValue(line.mid(1)));
@@ -1495,13 +1495,12 @@ static const MsvcToolChain *findMsvcToolChain(const QString &displayedVarsBat)
static QVersionNumber clangClVersion(const QString &clangClPath)
{
SynchronousProcess clangClProcess;
const SynchronousProcessResponse response
= clangClProcess.runBlocking({clangClPath, {"--version"}});
if (response.result != SynchronousProcessResponse::Finished || response.exitCode != 0)
clangClProcess.runBlocking({clangClPath, {"--version"}});
if (clangClProcess.result() != QtcProcess::Finished || clangClProcess.exitCode() != 0)
return {};
const QRegularExpressionMatch match = QRegularExpression(
QStringLiteral("clang version (\\d+(\\.\\d+)+)"))
.match(response.stdOut());
.match(clangClProcess.stdOut());
if (!match.hasMatch())
return {};
return QVersionNumber::fromString(match.captured(1));
@@ -1677,20 +1676,20 @@ Macros ClangClToolChain::msvcPredefinedMacros(const QStringList &cxxflags,
if (!cxxflags.contains("--driver-mode=g++"))
return MsvcToolChain::msvcPredefinedMacros(cxxflags, env);
Utils::SynchronousProcess cpp;
SynchronousProcess cpp;
cpp.setEnvironment(env);
cpp.setWorkingDirectory(Utils::TemporaryDirectory::masterDirectoryPath());
QStringList arguments = cxxflags;
arguments.append(gccPredefinedMacrosOptions(language()));
arguments.append("-");
Utils::SynchronousProcessResponse response = cpp.runBlocking({compilerCommand(), arguments});
if (response.result != Utils::SynchronousProcessResponse::Finished || response.exitCode != 0) {
cpp.runBlocking({compilerCommand(), arguments});
if (cpp.result() != Utils::QtcProcess::Finished || cpp.exitCode() != 0) {
// Show the warning but still parse the output.
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,
@@ -2022,12 +2021,12 @@ Utils::optional<QString> MsvcToolChain::generateEnvironmentSettings(const Utils:
qDebug() << "readEnvironmentSetting: " << call << cmd.toUserOutput()
<< " Env: " << runEnv.size();
run.setCodec(QTextCodec::codecForName("UTF-8"));
Utils::SynchronousProcessResponse response = run.runBlocking(cmd);
run.runBlocking(cmd);
if (response.result != Utils::SynchronousProcessResponse::Finished) {
const QString message = !response.stdErr().isEmpty()
? response.stdErr()
: response.exitMessage(cmdPath.toString(), 10);
if (run.result() != QtcProcess::Finished) {
const QString message = !run.stdErr().isEmpty()
? run.stdErr()
: run.exitMessage(cmdPath.toString(), 10);
qWarning().noquote() << message;
QString command = QDir::toNativeSeparators(batchFile);
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.
const QString stdOut = response.stdOut();
const QString stdOut = run.stdOut();
//
// 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;
pythonProcess.setProcessChannelMode(QProcess::MergedChannels);
pythonProcess.setTimeoutS(1);
SynchronousProcessResponse response = pythonProcess.runBlocking(
CommandLine(python, {"--version"}));
if (response.result == SynchronousProcessResponse::Finished)
name = response.stdOut().trimmed();
pythonProcess.runBlocking({python, {"--version"}});
if (pythonProcess.result() == QtcProcess::Finished)
name = pythonProcess.stdOut().trimmed();
if (name.isEmpty())
name = defaultName;
if (windowedSuffix)

View File

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

View File

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

View File

@@ -1026,14 +1026,14 @@ SubversionResponse SubversionPluginPrivate::runSvn(const QString &workingDir,
return response;
}
const SynchronousProcessResponse sp_resp
= m_client->vcsFullySynchronousExec(workingDir, arguments, flags, timeOutS, outputCodec);
SynchronousProcess proc;
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)
response.message = sp_resp.exitMessage(m_settings.binaryPath.value(), timeOutS);
response.stdErr = sp_resp.stdErr();
response.stdOut = sp_resp.stdOut();
response.message = proc.exitMessage(m_settings.binaryPath.value(), timeOutS);
response.stdErr = proc.stdErr();
response.stdOut = proc.stdOut();
return response;
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -99,11 +99,11 @@ public:
static QString stripLastNewline(const QString &in);
// Fully synchronous VCS execution (QProcess-based)
Utils::SynchronousProcessResponse
vcsFullySynchronousExec(const QString &workingDir, const QStringList &args,
void vcsFullySynchronousExec(Utils::SynchronousProcess &process,
const QString &workingDir, const QStringList &args,
unsigned flags = 0, int timeoutS = -1, QTextCodec *codec = nullptr) const;
Utils::SynchronousProcessResponse
vcsFullySynchronousExec(const QString &workingDir, const Utils::CommandLine &cmdLine,
void vcsFullySynchronousExec(Utils::SynchronousProcess &process,
const QString &workingDir, const Utils::CommandLine &cmdLine,
unsigned flags = 0, int timeoutS = -1, QTextCodec *codec = nullptr) const;
@@ -119,7 +119,8 @@ protected:
// Synchronous VCS execution using Utils::SynchronousProcess, with
// log windows updating (using VcsBasePlugin::runVcs with flags)
Utils::SynchronousProcessResponse vcsSynchronousExec(const QString &workingDir,
void vcsSynchronousExec(Utils::SynchronousProcess &proc,
const QString &workingDir,
const QStringList &args,
unsigned flags = 0,
QTextCodec *outputCodec = nullptr) const;

View File

@@ -752,21 +752,6 @@ void setProcessEnvironment(Environment *e, bool forceCLocale, const QString &ssh
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
#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.
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
{
Q_OBJECT

View File

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

View File

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