All: Replace most SynchronousProcess by QtcProcess

Change-Id: I0bf22fef2cd4a7297ef5a1e9aa9c3e2b9348ba42
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2021-06-22 04:33:47 +02:00
parent 8ac67dd1b7
commit 430e81facd
55 changed files with 157 additions and 158 deletions

View File

@@ -419,7 +419,7 @@ QString PluginManager::systemInformation()
QString result;
CommandLine qtDiag(HostOsInfo::withExecutableSuffix(
QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qtdiag"));
SynchronousProcess qtDiagProc;
QtcProcess qtDiagProc;
qtDiagProc.setCommand(qtDiag);
qtDiagProc.runBlocking();
if (qtDiagProc.result() == QtcProcess::FinishedWithSuccess)

View File

@@ -44,7 +44,7 @@ bool BuildableHelperLibrary::isQtChooser(const QFileInfo &info)
QString BuildableHelperLibrary::qtChooserToQmakePath(const QString &path)
{
const QString toolDir = QLatin1String("QTTOOLDIR=\"");
SynchronousProcess proc;
QtcProcess proc;
proc.setTimeoutS(1);
proc.setCommand({path, {"-print-env"}});
proc.runBlocking();
@@ -129,7 +129,7 @@ QString BuildableHelperLibrary::qtVersionForQMake(const QString &qmakePath)
if (qmakePath.isEmpty())
return QString();
SynchronousProcess qmake;
QtcProcess qmake;
qmake.setTimeoutS(5);
qmake.setCommand({qmakePath, {"--version"}});
qmake.runBlocking();

View File

@@ -149,7 +149,7 @@ QString BinaryVersionToolTipEventFilter::toolVersion(const CommandLine &cmd)
{
if (cmd.executable().isEmpty())
return QString();
SynchronousProcess proc;
QtcProcess proc;
proc.setTimeoutS(1);
proc.setCommand(cmd);
proc.runBlocking();

View File

@@ -183,7 +183,6 @@ public:
QProcess::OpenMode m_openMode = QProcess::ReadWrite;
// SynchronousProcess left overs:
void slotTimeout();
void slotFinished(int exitCode, QProcess::ExitStatus e);
void slotError(QProcess::ProcessError);
@@ -492,7 +491,7 @@ static bool askToKill(const QString &command)
}
// Helper for running a process synchronously in the foreground with timeout
// detection similar SynchronousProcess' handling (taking effect after no more output
// detection (taking effect after no more output
// occurs on stderr/stdout as opposed to waitForFinished()). Returns false if a timeout
// occurs. Checking of the process' exit state/code still has to be done.
@@ -984,7 +983,7 @@ static bool isGuiThread()
}
#endif
void SynchronousProcess::runBlocking()
void QtcProcess::runBlocking()
{
// FIXME: Implement properly
if (d->m_commandLine.executable().needsDevice()) {

View File

@@ -272,7 +272,7 @@ 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);
SynchronousProcess proc;
QtcProcess proc;
proc.setExitCodeInterpreter(job.exitCodeInterpreter);
proc.setTimeoutS(job.timeoutS);
runCommand(proc, job.command, job.workingDirectory);
@@ -306,7 +306,7 @@ void ShellCommand::run(QFutureInterface<void> &future)
this->deleteLater();
}
void ShellCommand::runCommand(SynchronousProcess &proc,
void ShellCommand::runCommand(QtcProcess &proc,
const CommandLine &command,
const QString &workingDirectory)
{
@@ -340,7 +340,7 @@ void ShellCommand::runCommand(SynchronousProcess &proc,
}
}
void ShellCommand::runFullySynchronous(SynchronousProcess &process,
void ShellCommand::runFullySynchronous(QtcProcess &process,
const QString &workingDirectory)
{
// Set up process
@@ -372,10 +372,10 @@ void ShellCommand::runFullySynchronous(SynchronousProcess &process,
}
}
void ShellCommand::runSynchronous(SynchronousProcess &process,
void ShellCommand::runSynchronous(QtcProcess &process,
const QString &workingDirectory)
{
connect(this, &ShellCommand::terminate, &process, &SynchronousProcess::stopProcess);
connect(this, &ShellCommand::terminate, &process, &QtcProcess::stopProcess);
process.setEnvironment(processEnvironment());
if (d->m_codec)
process.setCodec(d->m_codec);

View File

@@ -123,7 +123,7 @@ 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 void runCommand(Utils::SynchronousProcess &process,
virtual void runCommand(Utils::QtcProcess &process,
const CommandLine &command,
const QString &workingDirectory = QString());
@@ -153,10 +153,10 @@ private:
void run(QFutureInterface<void> &future);
// Run without a event loop in fully blocking mode. No signals will be delivered.
void runFullySynchronous(SynchronousProcess &proc,
void runFullySynchronous(QtcProcess &proc,
const QString &workingDirectory);
// Run with an event loop. Signals will be delivered.
void runSynchronous(SynchronousProcess &proc,
void runSynchronous(QtcProcess &proc,
const QString &workingDirectory);
class Internal::ShellCommandPrivate *const d;

View File

@@ -66,7 +66,7 @@ const int avdCreateTimeoutMs = 30000;
bool AndroidAvdManager::avdManagerCommand(const AndroidConfig &config, const QStringList &args, QString *output)
{
CommandLine cmd(config.avdManagerToolPath(), args);
Utils::SynchronousProcess proc;
Utils::QtcProcess proc;
Environment env = AndroidConfigurations::toolsEnvironment(config);
proc.setEnvironment(env);
qCDebug(avdManagerLog) << "Running AVD Manager command:" << cmd.toUserOutput();
@@ -200,7 +200,7 @@ bool AndroidAvdManager::removeAvd(const QString &name) const
{
const CommandLine command(m_config.avdManagerToolPath(), {"delete", "avd", "-n", name});
qCDebug(avdManagerLog) << "Running command (removeAvd):" << command.toUserOutput();
SynchronousProcess proc;
QtcProcess proc;
proc.setTimeoutS(5);
proc.setCommand(command);
proc.runBlocking();
@@ -350,7 +350,7 @@ bool AndroidAvdManager::isAvdBooted(const QString &device) const
const CommandLine command({m_config.adbToolPath(), arguments});
qCDebug(avdManagerLog) << "Running command (isAvdBooted):" << command.toUserOutput();
SynchronousProcess adbProc;
QtcProcess adbProc;
adbProc.setTimeoutS(10);
adbProc.setCommand(command);
adbProc.runBlocking();

View File

@@ -1006,7 +1006,7 @@ QAbstractItemModel *AndroidBuildApkStep::keystoreCertificates()
const QStringList params = {"-list", "-v", "-keystore", m_keystorePath.toUserOutput(),
"-storepass", m_keystorePasswd, "-J-Duser.language=en"};
SynchronousProcess keytoolProc;
QtcProcess keytoolProc;
keytoolProc.setTimeoutS(30);
keytoolProc.setCommand({AndroidConfigurations::currentConfig().keytoolPath(), params});
keytoolProc.setProcessUserEventWhileRunning();

View File

@@ -156,7 +156,7 @@ namespace {
if (executable.isEmpty() || shell.isEmpty())
return true; // we can't detect, but creator is 32bit so assume 32bit
SynchronousProcess proc;
QtcProcess proc;
proc.setProcessChannelMode(QProcess::MergedChannels);
proc.setTimeoutS(30);
proc.setCommand({executable, {shell}});
@@ -560,7 +560,7 @@ QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(QString *error) const
QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(const FilePath &adbToolPath, QString *error)
{
QVector<AndroidDeviceInfo> devices;
SynchronousProcess adbProc;
QtcProcess adbProc;
adbProc.setTimeoutS(30);
CommandLine cmd{adbToolPath, {"devices"}};
adbProc.setCommand(cmd);
@@ -630,7 +630,7 @@ QString AndroidConfig::getDeviceProperty(const FilePath &adbToolPath, const QStr
CommandLine cmd(adbToolPath, AndroidDeviceInfo::adbSelector(device));
cmd.addArgs({"shell", "getprop", property});
SynchronousProcess adbProc;
QtcProcess adbProc;
adbProc.setTimeoutS(10);
adbProc.setCommand(cmd);
adbProc.runBlocking();
@@ -728,7 +728,7 @@ QStringList AndroidConfig::getAbis(const FilePath &adbToolPath, const QString &d
// First try via ro.product.cpu.abilist
QStringList arguments = AndroidDeviceInfo::adbSelector(device);
arguments << "shell" << "getprop" << "ro.product.cpu.abilist";
SynchronousProcess adbProc;
QtcProcess adbProc;
adbProc.setTimeoutS(10);
adbProc.setCommand({adbToolPath, arguments});
adbProc.runBlocking();
@@ -751,7 +751,7 @@ QStringList AndroidConfig::getAbis(const FilePath &adbToolPath, const QString &d
else
arguments << QString::fromLatin1("ro.product.cpu.abi%1").arg(i);
SynchronousProcess abiProc;
QtcProcess abiProc;
abiProc.setTimeoutS(10);
abiProc.setCommand({adbToolPath, arguments});
abiProc.runBlocking();

View File

@@ -196,7 +196,7 @@ void AndroidCreateKeystoreCertificate::buttonBoxAccepted()
"-keypass", certificatePassword(),
"-dname", distinguishedNames});
SynchronousProcess genKeyCertProc;
QtcProcess genKeyCertProc;
genKeyCertProc.setTimeoutS(15);
genKeyCertProc.setCommand(command);
genKeyCertProc.setProcessUserEventWhileRunning();

View File

@@ -480,7 +480,7 @@ void AndroidDeployQtStep::doRun()
void AndroidDeployQtStep::runCommand(const CommandLine &command)
{
SynchronousProcess buildProc;
QtcProcess buildProc;
buildProc.setTimeoutS(2 * 60);
emit addOutput(tr("Package deploy: Running command \"%1\".").arg(command.toUserOutput()),
OutputFormat::NormalMessage);

View File

@@ -534,7 +534,7 @@ bool AndroidManager::checkKeystorePassword(const QString &keystorePath, const QS
return false;
const CommandLine cmd(AndroidConfigurations::currentConfig().keytoolPath(),
{"-list", "-keystore", keystorePath, "--storepass", keystorePasswd});
SynchronousProcess proc;
QtcProcess proc;
proc.setTimeoutS(10);
proc.setCommand(cmd);
proc.setProcessUserEventWhileRunning();
@@ -552,7 +552,7 @@ bool AndroidManager::checkCertificatePassword(const QString &keystorePath, const
else
arguments << certificatePasswd;
SynchronousProcess proc;
QtcProcess proc;
proc.setTimeoutS(10);
proc.setCommand({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
proc.setProcessUserEventWhileRunning();
@@ -567,7 +567,7 @@ bool AndroidManager::checkCertificateExists(const QString &keystorePath,
QStringList arguments = { "-list", "-keystore", keystorePath,
"--storepass", keystorePasswd, "-alias", alias };
SynchronousProcess proc;
QtcProcess proc;
proc.setTimeoutS(10);
proc.setCommand({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
proc.setProcessUserEventWhileRunning();
@@ -723,7 +723,7 @@ SdkToolResult AndroidManager::runCommand(const CommandLine &command,
const QByteArray &writeData, int timeoutS)
{
Android::SdkToolResult cmdResult;
SynchronousProcess cmdProc;
QtcProcess cmdProc;
cmdProc.setTimeoutS(timeoutS);
cmdProc.setWriteData(writeData);
qCDebug(androidManagerLog) << "Running command (sync):" << command.toUserOutput();

View File

@@ -123,7 +123,7 @@ static void findProcessPID(QFutureInterface<qint64> &fi, QStringList selector,
chrono::high_resolution_clock::time_point start = chrono::high_resolution_clock::now();
do {
QThread::msleep(200);
SynchronousProcess proc;
QtcProcess proc;
proc.setCommand({adbPath, args});
proc.runBlocking();
const QByteArray out = proc.allRawOutput();

View File

@@ -151,7 +151,7 @@ static bool sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
qCDebug(sdkManagerLog) << "Running SDK Manager command (sync):"
<< CommandLine(config.sdkManagerToolPath(), newArgs)
.toUserOutput();
SynchronousProcess proc;
QtcProcess proc;
proc.setEnvironment(AndroidConfigurations::toolsEnvironment(config));
proc.setTimeoutS(timeout);
proc.setTimeOutMessageBoxEnabled(true);
@@ -179,7 +179,7 @@ static void sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
qCDebug(sdkManagerLog) << "Running SDK Manager command (async):"
<< CommandLine(config.sdkManagerToolPath(), newArgs).toUserOutput();
int offset = fi.progressValue();
SynchronousProcess proc;
QtcProcess proc;
proc.setEnvironment(AndroidConfigurations::toolsEnvironment(config));
bool assertionFound = false;
proc.setTimeoutS(timeout);
@@ -195,7 +195,7 @@ static void sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
});
if (interruptible) {
QObject::connect(&sdkManager, &AndroidSdkManager::cancelActiveOperations,
&proc, &SynchronousProcess::stopProcess);
&proc, &QtcProcess::stopProcess);
}
proc.setCommand({config.sdkManagerToolPath(), newArgs});
proc.setProcessUserEventWhileRunning();

View File

@@ -100,7 +100,7 @@ static Macros dumpPredefinedMacros(const FilePath &compiler, const QStringList &
const QString outpath = fakeIn.fileName() + ".tmp";
SynchronousProcess cpp;
QtcProcess cpp;
cpp.setEnvironment(env);
cpp.setTimeoutS(10);
@@ -152,7 +152,7 @@ static HeaderPaths dumpHeaderPaths(const FilePath &compiler, const Id languageId
cmd.addArg("--preinclude");
cmd.addArg(".");
SynchronousProcess cpp;
QtcProcess cpp;
cpp.setEnvironment(env);
cpp.setTimeoutS(10);
cpp.setCommand(cmd);

View File

@@ -135,7 +135,7 @@ static Macros dumpMcsPredefinedMacros(const FilePath &compiler, const Environmen
fakeIn.close();
SynchronousProcess cpp;
QtcProcess cpp;
cpp.setEnvironment(env);
cpp.setTimeoutS(10);
cpp.setCommand({compiler, {fakeIn.fileName()}});
@@ -212,7 +212,7 @@ static Macros dumpC166PredefinedMacros(const FilePath &compiler, const Environme
fakeIn.close();
SynchronousProcess cpp;
QtcProcess cpp;
cpp.setEnvironment(env);
cpp.setTimeoutS(10);
@@ -277,7 +277,7 @@ static Macros dumpC166PredefinedMacros(const FilePath &compiler, const Environme
static Macros dumpArmPredefinedMacros(const FilePath &compiler, const QStringList &extraArgs, const Environment &env)
{
SynchronousProcess cpp;
QtcProcess cpp;
cpp.setEnvironment(env);
cpp.setTimeoutS(10);

View File

@@ -87,7 +87,7 @@ static Macros dumpPredefinedMacros(const FilePath &compiler, const Environment &
return {};
fakeIn.close();
SynchronousProcess cpp;
QtcProcess cpp;
cpp.setEnvironment(env);
cpp.setTimeoutS(10);
cpp.setCommand({compiler, {compilerTargetFlag(abi), "-dM", "-E", fakeIn.fileName()}});
@@ -108,7 +108,7 @@ static HeaderPaths dumpHeaderPaths(const FilePath &compiler, const Environment &
if (!compiler.exists())
return {};
SynchronousProcess cpp;
QtcProcess cpp;
cpp.setEnvironment(env);
cpp.setTimeoutS(10);
cpp.setCommand({compiler, {compilerTargetFlag(abi), "--print-search-dirs"}});

View File

@@ -150,7 +150,7 @@ bool BazaarClient::synchronousUncommit(const QString &workingDir,
<< revisionSpec(revision)
<< extraOptions;
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDir, args);
VcsOutputWindow::append(proc.stdOut());
return proc.result() == QtcProcess::FinishedWithSuccess;
@@ -191,7 +191,7 @@ bool BazaarClient::managesFile(const QString &workingDirectory, const QString &f
QStringList args(QLatin1String("status"));
args << fileName;
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, args);
if (proc.result() != QtcProcess::FinishedWithSuccess)
return false;

View File

@@ -83,7 +83,7 @@ static int parseVersion(const QString &text)
static int updateVersionHelper(const Utils::FilePath &command)
{
Utils::SynchronousProcess process;
Utils::QtcProcess process;
process.setCommand({command, {"--version"}});
process.runBlocking();
if (process.result() != Utils::QtcProcess::FinishedWithSuccess)
@@ -180,7 +180,7 @@ QString ArtisticStyleSettings::documentationFilePath() const
void ArtisticStyleSettings::createDocumentationFile() const
{
Utils::SynchronousProcess process;
Utils::QtcProcess process;
process.setTimeoutS(2);
process.setCommand({command(), {"-h"}});
process.runBlocking();

View File

@@ -148,7 +148,7 @@ QString UncrustifySettings::documentationFilePath() const
void UncrustifySettings::createDocumentationFile() const
{
Utils::SynchronousProcess process;
Utils::QtcProcess process;
process.setTimeoutS(2);
process.setCommand({command(), {"--show-config"}});
process.runBlocking();

View File

@@ -104,7 +104,7 @@ bool ClangToolRunner::supportsVFSOverlay() const
static QMap<QString, bool> vfsCapabilities;
auto it = vfsCapabilities.find(m_executable);
if (it == vfsCapabilities.end()) {
SynchronousProcess p;
QtcProcess p;
p.setCommand({m_executable, {"--help"}});
p.runBlocking();
it = vfsCapabilities.insert(m_executable, p.allOutput().contains("vfsoverlay"));

View File

@@ -50,7 +50,7 @@ static QString runExecutable(const Utils::CommandLine &commandLine,
if (commandLine.executable().isEmpty() || !commandLine.executable().toFileInfo().isExecutable())
return {};
SynchronousProcess cpp;
QtcProcess cpp;
Environment env = Environment::systemEnvironment();
env.setupEnglishOutput();
cpp.setEnvironment(env);

View File

@@ -1667,7 +1667,7 @@ ClearCasePluginPrivate::runCleartool(const QString &workingDir,
return response;
}
SynchronousProcess proc;
QtcProcess proc;
proc.setTimeoutS(timeOutS);
VcsCommand command(workingDir, Environment::systemEnvironment());
@@ -2355,7 +2355,7 @@ QString ClearCasePluginPrivate::runExtDiff(const QString &workingDir, const QStr
diff.addArgs(m_settings.diffArgs.split(' ', Qt::SkipEmptyParts));
diff.addArgs(arguments);
SynchronousProcess process;
QtcProcess process;
process.setTimeoutS(timeOutS);
process.setWorkingDirectory(workingDir);
process.setCodec(outputCodec ? outputCodec : QTextCodec::codecForName("UTF-8"));

View File

@@ -198,7 +198,7 @@ static FilePath qmakeFromCMakeCache(const CMakeConfig &config)
));
cmakeListTxt.close();
SynchronousProcess cmake;
QtcProcess cmake;
cmake.setTimeoutS(5);
cmake.setDisableUnixTerminal();
Environment env = Environment::systemEnvironment();

View File

@@ -268,7 +268,7 @@ TextEditor::Keywords CMakeTool::keywords()
return {};
if (m_introspection->m_functions.isEmpty() && m_introspection->m_didRun) {
SynchronousProcess proc;
QtcProcess proc;
runCMake(proc, {"--help-command-list"}, 5);
if (proc.result() == QtcProcess::FinishedWithSuccess)
m_introspection->m_functions = proc.stdOut().split('\n');
@@ -481,7 +481,7 @@ QStringList CMakeTool::parseVariableOutput(const QString &output)
void CMakeTool::fetchFromCapabilities() const
{
SynchronousProcess cmake;
QtcProcess cmake;
runCMake(cmake, {"-E", "capabilities"});
if (cmake.result() == QtcProcess::FinishedWithSuccess) {

View File

@@ -427,7 +427,7 @@ static std::function<void(QFileInfo)> postCopyOperation()
return;
// On macOS, downloaded files get a quarantine flag, remove it, otherwise it is a hassle
// to get it loaded as a plugin in Qt Creator.
SynchronousProcess xattr;
QtcProcess xattr;
xattr.setTimeoutS(1);
xattr.setCommand({"/usr/bin/xattr", {"-d", "com.apple.quarantine", fi.absoluteFilePath()}});
xattr.runBlocking();

View File

@@ -1446,7 +1446,7 @@ CvsResponse CvsPluginPrivate::runCvs(const QString &workingDirectory,
return response;
}
// Run, connect stderr to the output window
SynchronousProcess proc;
QtcProcess proc;
proc.setTimeoutS(timeOutS);
VcsCommand command(workingDirectory, Environment::systemEnvironment());

View File

@@ -69,7 +69,7 @@ const char DEBUGGER_INFORMATION_WORKINGDIRECTORY[] = "WorkingDirectory";
static QString getConfigurationOfGdbCommand(const FilePath &command, const Utils::Environment &sysEnv)
{
// run gdb with the --configuration opion
SynchronousProcess proc;
QtcProcess proc;
proc.setEnvironment(sysEnv);
proc.setCommand({command, {"--configuration"}});
proc.runBlocking();
@@ -184,7 +184,7 @@ void DebuggerItem::reinitializeFromFile(const Utils::Environment &sysEnv)
return;
}
SynchronousProcess proc;
QtcProcess proc;
proc.setEnvironment(sysEnv);
proc.setCommand({m_command, {version}});
proc.runBlocking();

View File

@@ -747,7 +747,7 @@ void DebuggerItemManagerPrivate::autoDetectGdbOrLldbDebuggers(const FilePath &de
FilePaths suspects;
if (device->osType() == OsTypeMac) {
SynchronousProcess proc;
QtcProcess proc;
proc.setTimeoutS(2);
proc.setCommand({"xcrun", {"--find", "lldb"}});
proc.runBlocking();

View File

@@ -4984,7 +4984,7 @@ CoreInfo CoreInfo::readExecutableNameFromCore(const Runnable &debugger, const QS
args += {"-ex", "set osabi GNU/Linux"};
args += {"-ex", "core " + coreFile};
SynchronousProcess proc;
QtcProcess proc;
Environment envLang(Environment::systemEnvironment());
envLang.setupEnglishOutput();
proc.setEnvironment(envLang);

View File

@@ -992,7 +992,7 @@ void DockerDevice::aboutToBeRemoved() const
void DockerDevicePrivate::fetchSystemEnviroment()
{
SynchronousProcess proc;
QtcProcess proc;
proc.setCommand({"env", {}});
q->runProcess(proc); // FIXME: This only starts.

View File

@@ -244,7 +244,7 @@ int GerritServer::testConnection()
{
static GitClient *const client = GitClient::instance();
const QStringList arguments = curlArguments() << (url(RestUrl) + accountUrlC);
SynchronousProcess proc;
QtcProcess proc;
client->vcsFullySynchronousExec(proc, QString(), {curlBinary, arguments},
Core::ShellCommand::NoOutput);
if (proc.result() == QtcProcess::FinishedWithSuccess) {
@@ -341,7 +341,7 @@ void GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
if (!version.isEmpty() && !forceReload)
return;
if (type == Ssh) {
SynchronousProcess proc;
QtcProcess proc;
QStringList arguments;
if (port)
arguments << p.portFlag << QString::number(port);
@@ -353,7 +353,7 @@ void GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
version = stdOut;
} else {
const QStringList arguments = curlArguments() << (url(RestUrl) + versionUrlC);
SynchronousProcess proc;
QtcProcess 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

View File

@@ -669,7 +669,7 @@ public:
connect(command, &VcsCommand::stdErrText, handler, &ConflictHandler::readStdErr);
}
static void handleResponse(const Utils::SynchronousProcess &proc,
static void handleResponse(const Utils::QtcProcess &proc,
const QString &workingDirectory,
const QString &abortCommand = QString())
{
@@ -838,7 +838,7 @@ QString GitClient::findGitDirForRepository(const QString &repositoryDir) const
bool GitClient::managesFile(const QString &workingDirectory, const QString &fileName) const
{
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, {"ls-files", "--error-unmatch", fileName},
Core::ShellCommand::NoOutput);
return proc.result() == QtcProcess::FinishedWithSuccess;
@@ -856,7 +856,7 @@ 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); });
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, it.key(), args, Core::ShellCommand::NoOutput);
if (proc.result() != QtcProcess::FinishedWithSuccess)
return filePaths;
@@ -1424,7 +1424,7 @@ void GitClient::removeStaleRemoteBranches(const QString &workingDirectory, const
void GitClient::recoverDeletedFiles(const QString &workingDirectory)
{
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, {"ls-files", "--deleted"},
VcsCommand::SuppressCommandLogging);
if (proc.result() == QtcProcess::FinishedWithSuccess) {
@@ -1451,7 +1451,7 @@ bool GitClient::synchronousLog(const QString &workingDirectory, const QStringLis
allArguments.append(arguments);
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, allArguments, flags, vcsTimeoutS(),
encoding(workingDirectory, "i18n.logOutputEncoding"));
if (proc.result() == QtcProcess::FinishedWithSuccess) {
@@ -1470,7 +1470,7 @@ bool GitClient::synchronousAdd(const QString &workingDirectory,
{
QStringList args{"add"};
args += extraOptions + files;
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, args);
return proc.result() == QtcProcess::FinishedWithSuccess;
}
@@ -1483,7 +1483,7 @@ bool GitClient::synchronousDelete(const QString &workingDirectory,
if (force)
arguments << "--force";
arguments.append(files);
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, arguments);
return proc.result() == QtcProcess::FinishedWithSuccess;
}
@@ -1492,7 +1492,7 @@ bool GitClient::synchronousMove(const QString &workingDirectory,
const QString &from,
const QString &to)
{
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, {"mv", from, to});
return proc.result() == QtcProcess::FinishedWithSuccess;
}
@@ -1507,7 +1507,7 @@ bool GitClient::synchronousReset(const QString &workingDirectory,
else
arguments << HEAD << "--" << files;
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, arguments);
const QString stdOut = proc.stdOut();
VcsOutputWindow::append(stdOut);
@@ -1531,7 +1531,7 @@ bool GitClient::synchronousReset(const QString &workingDirectory,
// Initialize repository
bool GitClient::synchronousInit(const QString &workingDirectory)
{
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, QStringList{"init"});
// '[Re]Initialized...'
VcsOutputWindow::append(proc.stdOut());
@@ -1559,7 +1559,7 @@ bool GitClient::synchronousCheckoutFiles(const QString &workingDirectory, QStrin
if (revertStaging)
arguments << revision;
arguments << "--" << files;
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, arguments, VcsCommand::ExpectRepoChanges);
if (proc.result() != QtcProcess::FinishedWithSuccess) {
const QString fileArg = files.join(", ");
@@ -1610,7 +1610,7 @@ bool GitClient::synchronousRevListCmd(const QString &workingDirectory, const QSt
QString *output, QString *errorMessage) const
{
const QStringList arguments = QStringList({"rev-list", noColorOption}) + extraArguments;
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, arguments, silentFlags);
if (proc.result() != QtcProcess::FinishedWithSuccess) {
msgCannotRun(arguments, workingDirectory, proc.stdErr(), errorMessage);
@@ -1674,7 +1674,7 @@ QString GitClient::synchronousShortDescription(const QString &workingDirectory,
QString GitClient::synchronousCurrentLocalBranch(const QString &workingDirectory) const
{
QString branch;
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, {"symbolic-ref", HEAD}, silentFlags);
if (proc.result() == QtcProcess::FinishedWithSuccess) {
branch = proc.stdOut().trimmed();
@@ -1699,7 +1699,7 @@ bool GitClient::synchronousHeadRefs(const QString &workingDirectory, QStringList
QString *errorMessage) const
{
const QStringList arguments = {"show-ref", "--head", "--abbrev=10", "--dereference"};
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, arguments, silentFlags);
if (proc.result() != QtcProcess::FinishedWithSuccess) {
msgCannotRun(arguments, workingDirectory, proc.stdErr(), errorMessage);
@@ -1748,7 +1748,7 @@ QString GitClient::synchronousTopic(const QString &workingDirectory) const
return remoteBranch;
// No tag or remote branch - try git describe
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, QStringList{"describe"}, VcsCommand::NoOutput);
if (proc.result() == QtcProcess::FinishedWithSuccess) {
const QString stdOut = proc.stdOut().trimmed();
@@ -1762,7 +1762,7 @@ bool GitClient::synchronousRevParseCmd(const QString &workingDirectory, const QS
QString *output, QString *errorMessage) const
{
const QStringList arguments = {"rev-parse", ref};
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, arguments, silentFlags);
*output = proc.stdOut().trimmed();
if (proc.result() != QtcProcess::FinishedWithSuccess) {
@@ -1777,7 +1777,7 @@ 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};
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, arguments, silentFlags);
if (proc.result() != QtcProcess::FinishedWithSuccess)
return QString();
@@ -1793,7 +1793,7 @@ QString GitClient::synchronousTopRevision(const QString &workingDirectory, QDate
void GitClient::synchronousTagsForCommit(const QString &workingDirectory, const QString &revision,
QString &precedes, QString &follows) const
{
SynchronousProcess proc1;
QtcProcess proc1;
vcsFullySynchronousExec(proc1, workingDirectory, {"describe", "--contains", revision}, silentFlags);
precedes = proc1.stdOut();
int tilde = precedes.indexOf('~');
@@ -1806,7 +1806,7 @@ void GitClient::synchronousTagsForCommit(const QString &workingDirectory, const
QString errorMessage;
synchronousParentRevisions(workingDirectory, revision, &parents, &errorMessage);
for (const QString &p : qAsConst(parents)) {
SynchronousProcess proc2;
QtcProcess proc2;
vcsFullySynchronousExec(proc2,
workingDirectory, {"describe", "--tags", "--abbrev=0", p}, silentFlags);
QString pf = proc2.stdOut();
@@ -1821,14 +1821,14 @@ void GitClient::synchronousTagsForCommit(const QString &workingDirectory, const
bool GitClient::isRemoteCommit(const QString &workingDirectory, const QString &commit)
{
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, {"branch", "-r", "--contains", commit}, silentFlags);
return proc.rawStdOut().isEmpty();
}
bool GitClient::isFastForwardMerge(const QString &workingDirectory, const QString &branch)
{
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, {"merge-base", HEAD, branch}, silentFlags);
return proc.stdOut().trimmed() == synchronousTopRevision(workingDirectory);
}
@@ -1839,7 +1839,7 @@ QString GitClient::synchronousShortDescription(const QString &workingDirectory,
{
const QStringList arguments = {"log", noColorOption, ("--pretty=format:" + format),
"--max-count=1", revision};
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, arguments, silentFlags);
if (proc.result() != QtcProcess::FinishedWithSuccess) {
VcsOutputWindow::appendSilently(tr("Cannot describe revision \"%1\" in \"%2\": %3")
@@ -1920,7 +1920,7 @@ bool GitClient::executeSynchronousStash(const QString &workingDirectory,
const unsigned flags = VcsCommand::ShowStdOut
| VcsCommand::ExpectRepoChanges
| VcsCommand::ShowSuccessMessage;
SynchronousProcess proc;
QtcProcess proc;
vcsSynchronousExec(proc, workingDirectory, arguments, flags);
if (proc.result() != QtcProcess::FinishedWithSuccess) {
msgCannotRun(arguments, workingDirectory, proc.stdErr(), errorMessage);
@@ -1960,7 +1960,7 @@ bool GitClient::synchronousBranchCmd(const QString &workingDirectory, QStringLis
QString *output, QString *errorMessage) const
{
branchArgs.push_front("branch");
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, branchArgs);
*output = proc.stdOut();
if (proc.result() != QtcProcess::FinishedWithSuccess) {
@@ -1974,7 +1974,7 @@ bool GitClient::synchronousTagCmd(const QString &workingDirectory, QStringList t
QString *output, QString *errorMessage) const
{
tagArgs.push_front("tag");
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, tagArgs);
*output = proc.stdOut();
if (proc.result() != QtcProcess::FinishedWithSuccess) {
@@ -1988,7 +1988,7 @@ bool GitClient::synchronousForEachRefCmd(const QString &workingDirectory, QStrin
QString *output, QString *errorMessage) const
{
args.push_front("for-each-ref");
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, args, silentFlags);
*output = proc.stdOut();
if (proc.result() != QtcProcess::FinishedWithSuccess) {
@@ -2008,7 +2008,7 @@ bool GitClient::synchronousRemoteCmd(const QString &workingDirectory, QStringLis
QString *output, QString *errorMessage, bool silent) const
{
remoteArgs.push_front("remote");
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, remoteArgs, silent ? silentFlags : 0);
const QString stdErr = proc.stdErr();
@@ -2052,7 +2052,7 @@ QStringList GitClient::synchronousSubmoduleStatus(const QString &workingDirector
QString *errorMessage) const
{
// get submodule status
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, {"submodule", "status"}, silentFlags);
if (proc.result() != QtcProcess::FinishedWithSuccess) {
@@ -2133,7 +2133,7 @@ QByteArray GitClient::synchronousShow(const QString &workingDirectory, const QSt
return {};
}
const QStringList arguments = {"show", decorateOption, noColorOption, "--no-patch", id};
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, arguments, flags);
if (proc.result() != QtcProcess::FinishedWithSuccess) {
msgCannotRun(arguments, workingDirectory, proc.stdErr(), nullptr);
@@ -2149,7 +2149,7 @@ bool GitClient::cleanList(const QString &workingDirectory, const QString &module
const QString directory = workingDirectory + '/' + modulePath;
const QStringList arguments = {"clean", "--dry-run", flag};
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, directory, arguments, VcsCommand::ForceCLocale);
if (proc.result() != QtcProcess::FinishedWithSuccess) {
msgCannotRun(arguments, directory, proc.stdErr(), errorMessage);
@@ -2196,7 +2196,7 @@ bool GitClient::synchronousApplyPatch(const QString &workingDirectory,
QStringList arguments = {"apply", "--whitespace=fix"};
arguments << extraArguments << file;
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, arguments);
const QString stdErr = proc.stdErr();
if (proc.result() == QtcProcess::FinishedWithSuccess) {
@@ -2325,7 +2325,7 @@ GitClient::StatusResult GitClient::gitStatus(const QString &workingDirectory, St
arguments << "--ignore-submodules=all";
arguments << "--porcelain" << "-b";
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, arguments, silentFlags);
const QString stdOut = proc.stdOut();
@@ -2493,7 +2493,7 @@ QStringList GitClient::synchronousRepositoryBranches(const QString &repositoryUR
const unsigned flags = VcsCommand::SshPasswordPrompt
| VcsCommand::SuppressStdErr
| VcsCommand::SuppressFailMessage;
SynchronousProcess proc;
QtcProcess proc;
vcsSynchronousExec(proc,
workingDirectory, {"ls-remote", repositoryURL, HEAD, "refs/heads/*"}, flags);
QStringList branches;
@@ -2708,7 +2708,7 @@ 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};
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, repoDirectory, arguments, silentFlags);
if (proc.result() != QtcProcess::FinishedWithSuccess) {
@@ -2965,7 +2965,7 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory,
arguments << "--signoff";
}
SynchronousProcess proc;
QtcProcess proc;
vcsSynchronousExec(proc, repositoryDirectory, arguments, VcsCommand::NoFullySync);
if (proc.result() == QtcProcess::FinishedWithSuccess) {
VcsOutputWindow::appendMessage(msgCommitted(amendSHA1, commitCount));
@@ -3104,7 +3104,7 @@ bool GitClient::executeAndHandleConflicts(const QString &workingDirectory,
| VcsCommand::ShowStdOut
| VcsCommand::ExpectRepoChanges
| VcsCommand::ShowSuccessMessage;
SynchronousProcess proc;
QtcProcess proc;
vcsSynchronousExec(proc, workingDirectory, arguments, flags);
// Notify about changed files or abort the rebase.
ConflictHandler::handleResponse(proc, workingDirectory, abortCommand);
@@ -3138,7 +3138,7 @@ void GitClient::synchronousAbortCommand(const QString &workingDir, const QString
return;
}
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDir, {abortCommand, "--abort"},
VcsCommand::ExpectRepoChanges | VcsCommand::ShowSuccessMessage);
VcsOutputWindow::append(proc.stdOut());
@@ -3164,7 +3164,7 @@ QString GitClient::synchronousTrackingBranch(const QString &workingDirectory, co
bool GitClient::synchronousSetTrackingBranch(const QString &workingDirectory,
const QString &branch, const QString &tracking)
{
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc,
workingDirectory, {"branch", "--set-upstream-to=" + tracking, branch});
return proc.result() == QtcProcess::FinishedWithSuccess;
@@ -3238,7 +3238,7 @@ void GitClient::synchronousSubversionFetch(const QString &workingDirectory) cons
const unsigned flags = VcsCommand::SshPasswordPrompt
| VcsCommand::ShowStdOut
| VcsCommand::ShowSuccessMessage;
SynchronousProcess proc;
QtcProcess proc;
vcsSynchronousExec(proc, workingDirectory, {"svn", "fetch"}, flags);
}
@@ -3488,7 +3488,7 @@ bool GitClient::synchronousStashRemove(const QString &workingDirectory, const QS
else
arguments << "drop" << stash;
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, arguments);
if (proc.result() == QtcProcess::FinishedWithSuccess) {
const QString output = proc.stdOut();
@@ -3507,7 +3507,7 @@ bool GitClient::synchronousStashList(const QString &workingDirectory, QList<Stas
stashes->clear();
const QStringList arguments = {"stash", "list", noColorOption};
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, arguments, VcsCommand::ForceCLocale);
if (proc.result() != QtcProcess::FinishedWithSuccess) {
msgCannotRun(arguments, workingDirectory, proc.stdErr(), errorMessage);
@@ -3547,7 +3547,7 @@ QString GitClient::readOneLine(const QString &workingDirectory, const QStringLis
? QTextCodec::codecForName("UTF-8")
: QTextCodec::codecForLocale();
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, arguments, silentFlags, vcsTimeoutS(), codec);
if (proc.result() != QtcProcess::FinishedWithSuccess)
return QString();
@@ -3574,7 +3574,7 @@ unsigned GitClient::synchronousGitVersion(QString *errorMessage) const
return 0;
// run git --version
SynchronousProcess proc;
QtcProcess proc;
vcsSynchronousExec(proc, QString(), {"--version"}, silentFlags);
if (proc.result() != QtcProcess::FinishedWithSuccess) {
msgCannotRun(tr("Cannot determine Git version: %1").arg(proc.stdErr()), errorMessage);

View File

@@ -198,7 +198,7 @@ public:
QObject::connect(m_command.get(),
&VcsCommand::stdOutText,
[this, &fi](const QString &text) { read(fi, text); });
SynchronousProcess proc;
QtcProcess proc;
proc.setTimeoutS(0);
m_command->runCommand(proc, {m_vcsBinary, arguments});
switch (proc.result()) {

View File

@@ -232,7 +232,7 @@ static QByteArray decodeProvisioningProfile(const QString &path)
{
QTC_ASSERT(!path.isEmpty(), return QByteArray());
Utils::SynchronousProcess p;
Utils::QtcProcess p;
p.setTimeoutS(3);
// path is assumed to be valid file path to .mobileprovision
p.setCommand({"openssl", {"smime", "-inform", "der", "-verify", "-in", path}});

View File

@@ -65,7 +65,7 @@ void XcodeProbe::addDeveloperPath(const QString &path)
void XcodeProbe::detectDeveloperPaths()
{
Utils::SynchronousProcess selectedXcode;
Utils::QtcProcess selectedXcode;
selectedXcode.setTimeoutS(5);
selectedXcode.setCommand({"/usr/bin/xcode-select", {"--print-path"}});
selectedXcode.runBlocking();

View File

@@ -81,7 +81,7 @@ static bool checkForTimeout(const chrono::high_resolution_clock::time_point &sta
static bool runCommand(const CommandLine &command, QString *stdOutput, QString *allOutput = nullptr)
{
SynchronousProcess p;
QtcProcess p;
p.setTimeoutS(-1);
p.setCommand(command);
p.runBlocking();

View File

@@ -96,7 +96,7 @@ 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"));
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, repository, args);
const QDir repositoryDir(repository);
@@ -127,7 +127,7 @@ bool MercurialClient::synchronousClone(const QString &workingDir,
if (workingDirectory.exists()) {
// Let's make first init
QStringList arguments(QLatin1String("init"));
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory.path(), arguments);
if (proc.result() != QtcProcess::FinishedWithSuccess)
return false;
@@ -135,7 +135,7 @@ bool MercurialClient::synchronousClone(const QString &workingDir,
// Then pull remote repository
arguments.clear();
arguments << QLatin1String("pull") << dstLocation;
SynchronousProcess proc1;
QtcProcess proc1;
vcsSynchronousExec(proc1, workingDirectory.path(), arguments, flags);
if (proc1.result() != QtcProcess::FinishedWithSuccess)
return false;
@@ -152,14 +152,14 @@ bool MercurialClient::synchronousClone(const QString &workingDir,
// And last update repository
arguments.clear();
arguments << QLatin1String("update");
SynchronousProcess proc2;
QtcProcess proc2;
vcsSynchronousExec(proc2, workingDirectory.path(), arguments, flags);
return proc2.result() == QtcProcess::FinishedWithSuccess;
} else {
QStringList arguments(QLatin1String("clone"));
arguments << dstLocation << workingDirectory.dirName();
workingDirectory.cdUp();
SynchronousProcess proc;
QtcProcess proc;
vcsSynchronousExec(proc, workingDirectory.path(), arguments, flags);
return proc.result() == QtcProcess::FinishedWithSuccess;
}
@@ -178,7 +178,7 @@ bool MercurialClient::synchronousPull(const QString &workingDir, const QString &
// cause mercurial doesn`t understand LANG
Environment env = Environment::systemEnvironment();
env.set("LANGUAGE", "C");
SynchronousProcess proc;
QtcProcess proc;
proc.setTimeoutS(vcsTimeoutS());
VcsCommand command(workingDir, env);
@@ -224,7 +224,7 @@ QStringList MercurialClient::parentRevisionsSync(const QString &workingDirectory
args << QLatin1String("parents") << QLatin1String("-r") <<revision;
if (!file.isEmpty())
args << file;
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, args);
if (proc.result() != QtcProcess::FinishedWithSuccess)
return QStringList();
@@ -267,7 +267,7 @@ QString MercurialClient::shortDescriptionSync(const QString &workingDirectory,
if (!format.isEmpty())
args << QLatin1String("--template") << format;
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, args);
if (proc.result() != QtcProcess::FinishedWithSuccess)
return revision;
@@ -287,7 +287,7 @@ bool MercurialClient::managesFile(const QString &workingDirectory, const QString
{
QStringList args;
args << QLatin1String("status") << QLatin1String("--unknown") << fileName;
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, args);
return proc.stdOut().isEmpty();
}

View File

@@ -1250,7 +1250,7 @@ PerforceResponse PerforcePluginPrivate::synchronousProcess(const QString &workin
QTC_ASSERT(stdInput.isEmpty(), return PerforceResponse()); // Not supported here
// Run, connect stderr to the output window
SynchronousProcess process;
QtcProcess process;
const int timeOutS = (flags & LongTimeOut) ? m_settings.longTimeOutS() : m_settings.timeOutS.value();
process.setTimeoutS(timeOutS);
if (outputCodec)

View File

@@ -83,7 +83,7 @@ static bool
const QMap<QString, QString> &fieldMap,
QString *stdOut /* = 0 */, QString *errorMessage)
{
Utils::SynchronousProcess process;
Utils::QtcProcess process;
const QString binary = script.front();
QStringList arguments;
const int binarySize = script.size();

View File

@@ -81,7 +81,7 @@ static QByteArray runGcc(const FilePath &gcc, const QStringList &arguments, cons
if (!gcc.isExecutableFile())
return QByteArray();
SynchronousProcess cpp;
QtcProcess cpp;
Environment environment(env);
environment.setupEnglishOutput();

View File

@@ -237,7 +237,7 @@ static Utils::optional<VisualStudioInstallation> detectCppBuildTools2017()
static QVector<VisualStudioInstallation> detectVisualStudioFromVsWhere(const QString &vswhere)
{
QVector<VisualStudioInstallation> installations;
SynchronousProcess vsWhereProcess;
QtcProcess vsWhereProcess;
vsWhereProcess.setCodec(QTextCodec::codecForName("UTF-8"));
const int timeoutS = 5;
vsWhereProcess.setTimeoutS(timeoutS);
@@ -615,7 +615,7 @@ Macros MsvcToolChain::msvcPredefinedMacros(const QStringList &cxxflags,
qWarning("%s: %s", Q_FUNC_INFO, qPrintable(saver.errorString()));
return predefinedMacros;
}
Utils::SynchronousProcess cpp;
Utils::QtcProcess cpp;
cpp.setEnvironment(env);
cpp.setWorkingDirectory(Utils::TemporaryDirectory::masterDirectoryPath());
QStringList arguments;
@@ -1503,7 +1503,7 @@ static const MsvcToolChain *findMsvcToolChain(const QString &displayedVarsBat)
static QVersionNumber clangClVersion(const QString &clangClPath)
{
SynchronousProcess clangClProcess;
QtcProcess clangClProcess;
clangClProcess.setCommand({clangClPath, {"--version"}});
clangClProcess.runBlocking();
if (clangClProcess.result() != QtcProcess::FinishedWithSuccess)
@@ -1723,7 +1723,7 @@ Macros ClangClToolChain::msvcPredefinedMacros(const QStringList &cxxflags,
if (!cxxflags.contains("--driver-mode=g++"))
return MsvcToolChain::msvcPredefinedMacros(cxxflags, env);
SynchronousProcess cpp;
QtcProcess cpp;
cpp.setEnvironment(env);
cpp.setWorkingDirectory(Utils::TemporaryDirectory::masterDirectoryPath());
@@ -2053,7 +2053,7 @@ Utils::optional<QString> MsvcToolChain::generateEnvironmentSettings(const Utils:
return QString();
}
Utils::SynchronousProcess run;
Utils::QtcProcess run;
// As of WinSDK 7.1, there is logic preventing the path from being set
// correctly if "ORIGINALPATH" is already set. That can cause problems

View File

@@ -278,7 +278,7 @@ Interpreter::Interpreter(const FilePath &python, const QString &defaultName, boo
: id(QUuid::createUuid().toString())
, command(python)
{
SynchronousProcess pythonProcess;
QtcProcess pythonProcess;
pythonProcess.setProcessChannelMode(QProcess::MergedChannels);
pythonProcess.setTimeoutS(1);
pythonProcess.setCommand({python, {"--version"}});

View File

@@ -84,7 +84,7 @@ static QString pythonName(const FilePath &pythonPath)
return {};
QString name = nameForPython.value(pythonPath);
if (name.isEmpty()) {
SynchronousProcess pythonProcess;
QtcProcess pythonProcess;
pythonProcess.setTimeoutS(2);
pythonProcess.setCommand({pythonPath, {"--version"}});
pythonProcess.runBlocking();
@@ -107,7 +107,7 @@ FilePath getPylsModulePath(CommandLine pylsCommand)
pylsCommand.addArg("-h");
SynchronousProcess pythonProcess;
QtcProcess pythonProcess;
Environment env = pythonProcess.environment();
env.set("PYTHONVERBOSE", "x");
pythonProcess.setEnvironment(env);
@@ -161,7 +161,7 @@ static PythonLanguageServerState checkPythonLanguageServer(const FilePath &pytho
}
}
SynchronousProcess pythonProcess;
QtcProcess pythonProcess;
pythonProcess.setCommand(pythonLShelpCommand);
pythonProcess.runBlocking();
if (pythonProcess.allOutput().contains("Python Language Server"))

View File

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

View File

@@ -1026,7 +1026,7 @@ SubversionResponse SubversionPluginPrivate::runSvn(const QString &workingDir,
return response;
}
SynchronousProcess proc;
QtcProcess proc;
m_client->vcsFullySynchronousExec(proc, workingDir, arguments, flags, timeOutS, outputCodec);
response.error = proc.result() != QtcProcess::FinishedWithSuccess;

View File

@@ -88,7 +88,7 @@ static FormatTask format(FormatTask task)
// Format temporary file
QStringList options = task.command.options();
options.replaceInStrings(QLatin1String("%file"), sourceFile.filePath().toString());
SynchronousProcess process;
QtcProcess process;
process.setTimeoutS(5);
process.setCommand({executable, options});
process.runBlocking();

View File

@@ -72,7 +72,7 @@ QString findFallbackDefinitionsLocation()
// Try kde-config.
const QStringList programs = {"kde-config", "kde4-config"};
for (auto &program : programs) {
Utils::SynchronousProcess process;
Utils::QtcProcess process;
process.setTimeoutS(5);
process.setCommand({program, {"--prefix"}});
process.runBlocking();

View File

@@ -144,7 +144,7 @@ QString VcsBaseClientImpl::stripLastNewline(const QString &in)
return in;
}
void VcsBaseClientImpl::vcsFullySynchronousExec(SynchronousProcess &proc,
void VcsBaseClientImpl::vcsFullySynchronousExec(QtcProcess &proc,
const QString &workingDir, const CommandLine &cmdLine,
unsigned flags, int timeoutS, QTextCodec *codec) const
{
@@ -174,7 +174,7 @@ void VcsBaseClientImpl::annotateRevisionRequested(const QString &workingDirector
annotate(workingDirectory, file, changeCopy, line);
}
void VcsBaseClientImpl::vcsFullySynchronousExec(SynchronousProcess &proc,
void VcsBaseClientImpl::vcsFullySynchronousExec(QtcProcess &proc,
const QString &workingDir, const QStringList &args,
unsigned flags, int timeoutS, QTextCodec *codec) const
{
@@ -195,7 +195,7 @@ VcsCommand *VcsBaseClientImpl::vcsExec(const QString &workingDirectory, const QS
return command;
}
void VcsBaseClientImpl::vcsSynchronousExec(SynchronousProcess &proc, const QString &workingDir,
void VcsBaseClientImpl::vcsSynchronousExec(QtcProcess &proc, const QString &workingDir,
const QStringList &args,
unsigned flags,
QTextCodec *outputCodec) const
@@ -259,7 +259,7 @@ bool VcsBaseClient::synchronousCreateRepository(const QString &workingDirectory,
{
QStringList args(vcsCommandString(CreateRepositoryCommand));
args << extraOptions;
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDirectory, args);
if (proc.result() != QtcProcess::FinishedWithSuccess)
return false;
@@ -279,7 +279,7 @@ bool VcsBaseClient::synchronousClone(const QString &workingDir,
args << vcsCommandString(CloneCommand)
<< extraOptions << srcLocation << dstLocation;
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDir, args);
resetCachedVcsInfo(workingDir);
return proc.result() == QtcProcess::FinishedWithSuccess;
@@ -290,7 +290,7 @@ bool VcsBaseClient::synchronousAdd(const QString &workingDir, const QString &fil
{
QStringList args;
args << vcsCommandString(AddCommand) << extraOptions << filename;
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDir, args);
return proc.result() == QtcProcess::FinishedWithSuccess;
}
@@ -300,7 +300,7 @@ bool VcsBaseClient::synchronousRemove(const QString &workingDir, const QString &
{
QStringList args;
args << vcsCommandString(RemoveCommand) << extraOptions << filename;
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDir, args);
return proc.result() == QtcProcess::FinishedWithSuccess;
}
@@ -311,7 +311,7 @@ bool VcsBaseClient::synchronousMove(const QString &workingDir,
{
QStringList args;
args << vcsCommandString(MoveCommand) << extraOptions << from << to;
SynchronousProcess proc;
QtcProcess proc;
vcsFullySynchronousExec(proc, workingDir, args);
return proc.result() == QtcProcess::FinishedWithSuccess;
}
@@ -327,7 +327,7 @@ bool VcsBaseClient::synchronousPull(const QString &workingDir,
VcsCommand::SshPasswordPrompt
| VcsCommand::ShowStdOut
| VcsCommand::ShowSuccessMessage;
SynchronousProcess proc;
QtcProcess proc;
vcsSynchronousExec(proc, workingDir, args, flags);
const bool ok = proc.result() == QtcProcess::FinishedWithSuccess;
if (ok)
@@ -346,7 +346,7 @@ bool VcsBaseClient::synchronousPush(const QString &workingDir,
VcsCommand::SshPasswordPrompt
| VcsCommand::ShowStdOut
| VcsCommand::ShowSuccessMessage;
SynchronousProcess proc;
QtcProcess proc;
vcsSynchronousExec(proc, workingDir, args, flags);
return proc.result() == QtcProcess::FinishedWithSuccess;
}

View File

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

View File

@@ -71,7 +71,7 @@ const Environment VcsCommand::processEnvironment() const
return env;
}
void VcsCommand::runCommand(SynchronousProcess &proc,
void VcsCommand::runCommand(QtcProcess &proc,
const CommandLine &command,
const QString &workingDirectory)
{

View File

@@ -47,7 +47,7 @@ public:
const Utils::Environment processEnvironment() const override;
void runCommand(Utils::SynchronousProcess &process,
void runCommand(Utils::QtcProcess &process,
const Utils::CommandLine &command,
const QString &workDirectory = {}) override;

View File

@@ -845,7 +845,7 @@ void tst_QtcProcess::exitCode()
QCOMPARE(qtcP.exitCode() == 0, qtcP.result() == QtcProcess::FinishedWithSuccess);
}
{
SynchronousProcess sP;
QtcProcess sP;
sP.setCommand(command);
sP.setEnvironment(env);
sP.runBlocking();
@@ -876,7 +876,7 @@ void tst_QtcProcess::runBlockingStdOut()
QFETCH(bool, withEndl);
QFETCH(int, timeOutS);
SynchronousProcess sp;
QtcProcess sp;
QStringList args = QCoreApplication::arguments();
const QString binary = args.takeFirst();
sp.setCommand(CommandLine(binary, args));
@@ -893,7 +893,7 @@ void tst_QtcProcess::runBlockingStdOut()
});
sp.runBlocking();
// See also QTCREATORBUG-25667 for why it is a bad idea to use SynchronousProcess::runBlocking
// See also QTCREATORBUG-25667 for why it is a bad idea to use QtcProcess::runBlocking
// with interactive cli tools.
QEXPECT_FAIL("Unterminated stdout lost: early timeout", "", Continue);
QVERIFY2(sp.result() != QtcProcess::Hang, "Process run did not time out.");

View File

@@ -34,11 +34,11 @@
#include <cstdio>
static const char usage[] =
"Tests timeout behaviour of Utils:SynchronousProcess.\n"
"Tests timeout behavior of Utils::QtcProcess.\n"
"Usage:\n"
" 1) Test Utils:SynchronousProcess (graphically)\n"
" 1) Test Utils::QtcProcess (graphically)\n"
" process <cmd> <args>\n"
" 2) Test synchronous helpers of Utils:SynchronousProcess (tty)\n"
" 2) Test synchronous helpers of Utils::QtcProcess (tty)\n"
" process -s <cmd> <args>\n\n"
"slowprocess.sh is provided as an example script that produces slow\n"
"output. It takes an option -e to switch to stderr\n"

View File

@@ -52,7 +52,7 @@ void MainWindow::test()
args.pop_front();
const QString cmd = args.front();
args.pop_front();
Utils::SynchronousProcess process;
Utils::QtcProcess process;
process.setTimeoutS(2);
qDebug() << "Async: " << cmd << args;
process.setStdOutCallback([this](const QString &s) { append(s); });