forked from qt-creator/qt-creator
Utils: Remove CommandLine argument from QtcProcess::run{,Blocking}
Makes run() more similar to what start() looks like. Also add some asserts to make sure run() and related functions are only called on SyncronousProcesses, as these are currently the only ones where this works. Change-Id: Idee6076c3f40a484db5c17f5bb348698cc83d220 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -419,7 +419,8 @@ QString PluginManager::systemInformation()
|
||||
CommandLine qtDiag(HostOsInfo::withExecutableSuffix(
|
||||
QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qtdiag"));
|
||||
SynchronousProcess qtDiagProc;
|
||||
qtDiagProc.runBlocking(qtDiag);
|
||||
qtDiagProc.setCommand(qtDiag);
|
||||
qtDiagProc.runBlocking();
|
||||
if (qtDiagProc.result() == QtcProcess::Finished)
|
||||
result += qtDiagProc.allOutput() + "\n";
|
||||
result += "Plugin information:\n\n";
|
||||
|
||||
@@ -46,7 +46,8 @@ QString BuildableHelperLibrary::qtChooserToQmakePath(const QString &path)
|
||||
const QString toolDir = QLatin1String("QTTOOLDIR=\"");
|
||||
SynchronousProcess proc;
|
||||
proc.setTimeoutS(1);
|
||||
proc.runBlocking({path, {"-print-env"}});
|
||||
proc.setCommand({path, {"-print-env"}});
|
||||
proc.runBlocking();
|
||||
if (proc.result() != QtcProcess::Finished)
|
||||
return QString();
|
||||
const QString output = proc.stdOut();
|
||||
@@ -130,7 +131,8 @@ QString BuildableHelperLibrary::qtVersionForQMake(const QString &qmakePath)
|
||||
|
||||
SynchronousProcess qmake;
|
||||
qmake.setTimeoutS(5);
|
||||
qmake.runBlocking({qmakePath, {"--version"}});
|
||||
qmake.setCommand({qmakePath, {"--version"}});
|
||||
qmake.runBlocking();
|
||||
if (qmake.result() != QtcProcess::Finished) {
|
||||
qWarning() << qmake.exitMessage();
|
||||
return QString();
|
||||
|
||||
@@ -151,7 +151,8 @@ QString BinaryVersionToolTipEventFilter::toolVersion(const CommandLine &cmd)
|
||||
return QString();
|
||||
SynchronousProcess proc;
|
||||
proc.setTimeoutS(1);
|
||||
proc.runBlocking(cmd);
|
||||
proc.setCommand(cmd);
|
||||
proc.runBlocking();
|
||||
if (proc.result() != QtcProcess::Finished)
|
||||
return QString();
|
||||
return proc.allOutput();
|
||||
|
||||
@@ -131,6 +131,7 @@ public:
|
||||
bool m_startFailure = false;
|
||||
bool m_timeOutMessageBoxEnabled = false;
|
||||
bool m_waitingForUser = false;
|
||||
bool m_isSynchronousProcess = false;
|
||||
};
|
||||
|
||||
void QtcProcessPrivate::clearForRun()
|
||||
@@ -718,6 +719,8 @@ void ChannelBuffer::append(const QByteArray &text, bool emitSignals)
|
||||
// ----------- SynchronousProcess
|
||||
SynchronousProcess::SynchronousProcess()
|
||||
{
|
||||
d->m_isSynchronousProcess = true; // Only for QTC_ASSERTs above.
|
||||
|
||||
d->m_timer.setInterval(1000);
|
||||
connect(&d->m_timer, &QTimer::timeout, d, &QtcProcessPrivate::slotTimeout);
|
||||
connect(this, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
||||
@@ -741,6 +744,7 @@ SynchronousProcess::~SynchronousProcess()
|
||||
|
||||
void QtcProcess::setTimeoutS(int timeoutS)
|
||||
{
|
||||
QTC_CHECK(d->m_isSynchronousProcess);
|
||||
if (timeoutS > 0)
|
||||
d->m_maxHangTimerCount = qMax(2, timeoutS);
|
||||
else
|
||||
@@ -755,6 +759,7 @@ void QtcProcess::setCodec(QTextCodec *c)
|
||||
|
||||
void QtcProcess::setTimeOutMessageBoxEnabled(bool v)
|
||||
{
|
||||
QTC_CHECK(d->m_isSynchronousProcess);
|
||||
d->m_timeOutMessageBoxEnabled = v;
|
||||
}
|
||||
|
||||
@@ -765,6 +770,7 @@ void QtcProcess::setExitCodeInterpreter(const ExitCodeInterpreter &interpreter)
|
||||
|
||||
void QtcProcess::setWriteData(const QByteArray &writeData)
|
||||
{
|
||||
QTC_CHECK(d->m_isSynchronousProcess);
|
||||
d->m_writeData = writeData;
|
||||
}
|
||||
|
||||
@@ -775,11 +781,11 @@ static bool isGuiThread()
|
||||
}
|
||||
#endif
|
||||
|
||||
void QtcProcess::run(const CommandLine &cmd)
|
||||
void QtcProcess::run()
|
||||
{
|
||||
QTC_CHECK(d->m_isSynchronousProcess);
|
||||
// FIXME: Implement properly
|
||||
if (cmd.executable().needsDevice()) {
|
||||
setCommand(cmd);
|
||||
if (d->m_commandLine.executable().needsDevice()) {
|
||||
|
||||
// writeData ?
|
||||
start();
|
||||
@@ -793,16 +799,15 @@ void QtcProcess::run(const CommandLine &cmd)
|
||||
return;
|
||||
};
|
||||
|
||||
qCDebug(processLog).noquote() << "Starting:" << cmd.toUserOutput();
|
||||
qCDebug(processLog).noquote() << "Starting:" << d->m_commandLine.toUserOutput();
|
||||
ExecuteOnDestruction logResult([this] { qCDebug(processLog) << *this; });
|
||||
|
||||
d->clearForRun();
|
||||
|
||||
d->m_binary = cmd.executable();
|
||||
d->m_binary = d->m_commandLine.executable();
|
||||
// using QProcess::start() and passing program, args and OpenMode results in a different
|
||||
// quoting of arguments than using QProcess::setArguments() beforehand and calling start()
|
||||
// only with the OpenMode
|
||||
setCommand(cmd);
|
||||
if (!d->m_writeData.isEmpty()) {
|
||||
connect(this, &QProcess::started, this, [this] {
|
||||
write(d->m_writeData);
|
||||
@@ -833,11 +838,11 @@ void QtcProcess::run(const CommandLine &cmd)
|
||||
}
|
||||
}
|
||||
|
||||
void QtcProcess::runBlocking(const CommandLine &cmd)
|
||||
void QtcProcess::runBlocking()
|
||||
{
|
||||
QTC_CHECK(d->m_isSynchronousProcess);
|
||||
// FIXME: Implement properly
|
||||
if (cmd.executable().needsDevice()) {
|
||||
setCommand(cmd);
|
||||
if (d->m_commandLine.executable().needsDevice()) {
|
||||
|
||||
// writeData ?
|
||||
start();
|
||||
@@ -851,14 +856,13 @@ void QtcProcess::runBlocking(const CommandLine &cmd)
|
||||
return;
|
||||
};
|
||||
|
||||
qCDebug(processLog).noquote() << "Starting blocking:" << cmd.toUserOutput();
|
||||
qCDebug(processLog).noquote() << "Starting blocking:" << d->m_commandLine.toUserOutput();
|
||||
ExecuteOnDestruction logResult([this] { qCDebug(processLog) << *this; });
|
||||
|
||||
d->clearForRun();
|
||||
|
||||
d->m_binary = cmd.executable();
|
||||
d->m_binary = d->m_commandLine.executable();
|
||||
setOpenMode(QIODevice::ReadOnly);
|
||||
setCommand(cmd);
|
||||
start();
|
||||
if (!waitForStarted(d->m_maxHangTimerCount * 1000)) {
|
||||
d->m_result = QtcProcess::StartFailed;
|
||||
@@ -890,11 +894,13 @@ void QtcProcess::runBlocking(const CommandLine &cmd)
|
||||
|
||||
void QtcProcess::setStdOutCallback(const std::function<void (const QString &)> &callback)
|
||||
{
|
||||
QTC_CHECK(d->m_isSynchronousProcess);
|
||||
d->m_stdOut.outputCallback = callback;
|
||||
}
|
||||
|
||||
void QtcProcess::setStdErrCallback(const std::function<void (const QString &)> &callback)
|
||||
{
|
||||
QTC_CHECK(d->m_isSynchronousProcess);
|
||||
d->m_stdErr.outputCallback = callback;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,9 +90,14 @@ public:
|
||||
void setWriteData(const QByteArray &writeData);
|
||||
|
||||
// Starts a nested event loop and runs the command
|
||||
void run(const CommandLine &cmd);
|
||||
void run();
|
||||
|
||||
// Starts the command blocking the UI fully
|
||||
void runBlocking(const CommandLine &cmd);
|
||||
void runBlocking();
|
||||
|
||||
// FIXME: Remove. Kept for downstream for a while.
|
||||
void run(const CommandLine &cmd) { setCommand(cmd); run(); }
|
||||
void runBlocking(const CommandLine &cmd) { setCommand(cmd); runBlocking(); }
|
||||
|
||||
void setStdOutCallback(const std::function<void(const QString &)> &callback);
|
||||
void setStdErrCallback(const std::function<void(const QString &)> &callback);
|
||||
|
||||
@@ -323,12 +323,13 @@ void ShellCommand::runCommand(SynchronousProcess &proc,
|
||||
if (!(d->m_flags & SuppressCommandLogging))
|
||||
emit proxy->appendCommand(dir, command);
|
||||
|
||||
proc.setCommand(command);
|
||||
if ((d->m_flags & FullySynchronously)
|
||||
|| (!(d->m_flags & NoFullySync)
|
||||
&& QThread::currentThread() == QCoreApplication::instance()->thread())) {
|
||||
runFullySynchronous(proc, command, proxy, dir);
|
||||
runFullySynchronous(proc, proxy, dir);
|
||||
} else {
|
||||
runSynchronous(proc, command, proxy, dir);
|
||||
runSynchronous(proc, proxy, dir);
|
||||
}
|
||||
|
||||
if (!d->m_aborted) {
|
||||
@@ -343,7 +344,6 @@ void ShellCommand::runCommand(SynchronousProcess &proc,
|
||||
}
|
||||
|
||||
void ShellCommand::runFullySynchronous(SynchronousProcess &process,
|
||||
const CommandLine &cmd,
|
||||
QSharedPointer<OutputProxy> proxy,
|
||||
const QString &workingDirectory)
|
||||
{
|
||||
@@ -359,7 +359,7 @@ void ShellCommand::runFullySynchronous(SynchronousProcess &process,
|
||||
if (d->m_codec)
|
||||
process.setCodec(d->m_codec);
|
||||
|
||||
process.runBlocking(cmd);
|
||||
process.runBlocking();
|
||||
|
||||
if (!d->m_aborted) {
|
||||
const QString stdErr = process.stdErr();
|
||||
@@ -377,7 +377,6 @@ void ShellCommand::runFullySynchronous(SynchronousProcess &process,
|
||||
}
|
||||
|
||||
void ShellCommand::runSynchronous(SynchronousProcess &process,
|
||||
const CommandLine &cmd,
|
||||
QSharedPointer<OutputProxy> proxy,
|
||||
const QString &workingDirectory)
|
||||
{
|
||||
@@ -423,7 +422,7 @@ void ShellCommand::runSynchronous(SynchronousProcess &process,
|
||||
if (d->m_codec)
|
||||
process.setCodec(d->m_codec);
|
||||
|
||||
process.run(cmd);
|
||||
process.run();
|
||||
}
|
||||
|
||||
const QVariant &ShellCommand::cookie() const
|
||||
|
||||
@@ -167,12 +167,10 @@ private:
|
||||
|
||||
// Run without a event loop in fully blocking mode. No signals will be delivered.
|
||||
void runFullySynchronous(SynchronousProcess &proc,
|
||||
const CommandLine &cmd,
|
||||
QSharedPointer<OutputProxy> proxy,
|
||||
const QString &workingDirectory);
|
||||
// Run with an event loop. Signals will be delivered.
|
||||
void runSynchronous(SynchronousProcess &proc,
|
||||
const CommandLine &cmd,
|
||||
QSharedPointer<OutputProxy> proxy,
|
||||
const QString &workingDirectory);
|
||||
|
||||
|
||||
@@ -70,7 +70,8 @@ bool AndroidAvdManager::avdManagerCommand(const AndroidConfig &config, const QSt
|
||||
Environment env = AndroidConfigurations::toolsEnvironment(config);
|
||||
proc.setEnvironment(env);
|
||||
qCDebug(avdManagerLog) << "Running AVD Manager command:" << cmd.toUserOutput();
|
||||
proc.runBlocking(cmd);
|
||||
proc.setCommand(cmd);
|
||||
proc.runBlocking();
|
||||
if (proc.result() == Utils::QtcProcess::Finished) {
|
||||
if (output)
|
||||
*output = proc.allOutput();
|
||||
@@ -201,7 +202,8 @@ bool AndroidAvdManager::removeAvd(const QString &name) const
|
||||
qCDebug(avdManagerLog) << "Running command (removeAvd):" << command.toUserOutput();
|
||||
SynchronousProcess proc;
|
||||
proc.setTimeoutS(5);
|
||||
proc.runBlocking(command);
|
||||
proc.setCommand(command);
|
||||
proc.runBlocking();
|
||||
return proc.result() == QtcProcess::Finished && proc.exitCode() == 0;
|
||||
}
|
||||
|
||||
@@ -350,7 +352,8 @@ bool AndroidAvdManager::isAvdBooted(const QString &device) const
|
||||
qCDebug(avdManagerLog) << "Running command (isAvdBooted):" << command.toUserOutput();
|
||||
SynchronousProcess adbProc;
|
||||
adbProc.setTimeoutS(10);
|
||||
adbProc.runBlocking(command);
|
||||
adbProc.setCommand(command);
|
||||
adbProc.runBlocking();
|
||||
if (adbProc.result() != QtcProcess::Finished)
|
||||
return false;
|
||||
QString value = adbProc.allOutput().trimmed();
|
||||
|
||||
@@ -1009,7 +1009,8 @@ QAbstractItemModel *AndroidBuildApkStep::keystoreCertificates()
|
||||
|
||||
SynchronousProcess keytoolProc;
|
||||
keytoolProc.setTimeoutS(30);
|
||||
keytoolProc.run({AndroidConfigurations::currentConfig().keytoolPath(), params});
|
||||
keytoolProc.setCommand({AndroidConfigurations::currentConfig().keytoolPath(), params});
|
||||
keytoolProc.run();
|
||||
if (keytoolProc.result() > QtcProcess::FinishedError)
|
||||
QMessageBox::critical(nullptr, tr("Error"), tr("Failed to run keytool."));
|
||||
else
|
||||
|
||||
@@ -159,7 +159,8 @@ namespace {
|
||||
SynchronousProcess proc;
|
||||
proc.setProcessChannelMode(QProcess::MergedChannels);
|
||||
proc.setTimeoutS(30);
|
||||
proc.runBlocking({executable, {shell}});
|
||||
proc.setCommand({executable, {shell}});
|
||||
proc.runBlocking();
|
||||
if (proc.result() != QtcProcess::Finished)
|
||||
return true;
|
||||
return !proc.allOutput().contains("x86-64");
|
||||
@@ -561,7 +562,8 @@ QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(const FilePath &adbTo
|
||||
SynchronousProcess adbProc;
|
||||
adbProc.setTimeoutS(30);
|
||||
CommandLine cmd{adbToolPath, {"devices"}};
|
||||
adbProc.runBlocking(cmd);
|
||||
adbProc.setCommand(cmd);
|
||||
adbProc.runBlocking();
|
||||
if (adbProc.result() != QtcProcess::Finished) {
|
||||
if (error)
|
||||
*error = QApplication::translate("AndroidConfiguration", "Could not run: %1")
|
||||
@@ -629,7 +631,8 @@ QString AndroidConfig::getDeviceProperty(const FilePath &adbToolPath, const QStr
|
||||
|
||||
SynchronousProcess adbProc;
|
||||
adbProc.setTimeoutS(10);
|
||||
adbProc.runBlocking(cmd);
|
||||
adbProc.setCommand(cmd);
|
||||
adbProc.runBlocking();
|
||||
if (adbProc.result() != QtcProcess::Finished)
|
||||
return QString();
|
||||
|
||||
@@ -726,7 +729,8 @@ QStringList AndroidConfig::getAbis(const FilePath &adbToolPath, const QString &d
|
||||
arguments << "shell" << "getprop" << "ro.product.cpu.abilist";
|
||||
SynchronousProcess adbProc;
|
||||
adbProc.setTimeoutS(10);
|
||||
adbProc.runBlocking({adbToolPath, arguments});
|
||||
adbProc.setCommand({adbToolPath, arguments});
|
||||
adbProc.runBlocking();
|
||||
if (adbProc.result() != QtcProcess::Finished)
|
||||
return result;
|
||||
|
||||
@@ -748,7 +752,8 @@ QStringList AndroidConfig::getAbis(const FilePath &adbToolPath, const QString &d
|
||||
|
||||
SynchronousProcess abiProc;
|
||||
abiProc.setTimeoutS(10);
|
||||
abiProc.runBlocking({adbToolPath, arguments});
|
||||
abiProc.setCommand({adbToolPath, arguments});
|
||||
abiProc.runBlocking();
|
||||
if (abiProc.result() != QtcProcess::Finished)
|
||||
return result;
|
||||
|
||||
|
||||
@@ -198,7 +198,8 @@ void AndroidCreateKeystoreCertificate::buttonBoxAccepted()
|
||||
|
||||
SynchronousProcess genKeyCertProc;
|
||||
genKeyCertProc.setTimeoutS(15);
|
||||
genKeyCertProc.run(command);
|
||||
genKeyCertProc.setCommand(command);
|
||||
genKeyCertProc.run();
|
||||
|
||||
if (genKeyCertProc.result() != QtcProcess::Finished || genKeyCertProc.exitCode() != 0) {
|
||||
QMessageBox::critical(this, tr("Error"),
|
||||
|
||||
@@ -482,7 +482,8 @@ void AndroidDeployQtStep::runCommand(const CommandLine &command)
|
||||
emit addOutput(tr("Package deploy: Running command \"%1\".").arg(command.toUserOutput()),
|
||||
OutputFormat::NormalMessage);
|
||||
|
||||
buildProc.run(command);
|
||||
buildProc.setCommand(command);
|
||||
buildProc.run();
|
||||
if (buildProc.result() != QtcProcess::Finished || buildProc.exitCode() != 0) {
|
||||
const QString error = buildProc.exitMessage();
|
||||
emit addOutput(error, OutputFormat::ErrorMessage);
|
||||
|
||||
@@ -538,7 +538,8 @@ bool AndroidManager::checkKeystorePassword(const QString &keystorePath, const QS
|
||||
{"-list", "-keystore", keystorePath, "--storepass", keystorePasswd});
|
||||
SynchronousProcess proc;
|
||||
proc.setTimeoutS(10);
|
||||
proc.run(cmd);
|
||||
proc.setCommand(cmd);
|
||||
proc.run();
|
||||
return proc.result() == QtcProcess::Finished && proc.exitCode() == 0;
|
||||
}
|
||||
|
||||
@@ -554,7 +555,8 @@ bool AndroidManager::checkCertificatePassword(const QString &keystorePath, const
|
||||
|
||||
SynchronousProcess proc;
|
||||
proc.setTimeoutS(10);
|
||||
proc.run({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
|
||||
proc.setCommand({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
|
||||
proc.run();
|
||||
return proc.result() == QtcProcess::Finished && proc.exitCode() == 0;
|
||||
}
|
||||
|
||||
@@ -567,7 +569,8 @@ bool AndroidManager::checkCertificateExists(const QString &keystorePath,
|
||||
|
||||
SynchronousProcess proc;
|
||||
proc.setTimeoutS(10);
|
||||
proc.run({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
|
||||
proc.setCommand({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
|
||||
proc.run();
|
||||
return proc.result() == QtcProcess::Finished && proc.exitCode() == 0;
|
||||
}
|
||||
|
||||
@@ -723,7 +726,8 @@ SdkToolResult AndroidManager::runCommand(const CommandLine &command,
|
||||
cmdProc.setTimeoutS(timeoutS);
|
||||
cmdProc.setWriteData(writeData);
|
||||
qCDebug(androidManagerLog) << "Running command (sync):" << command.toUserOutput();
|
||||
cmdProc.run(command);
|
||||
cmdProc.setCommand(command);
|
||||
cmdProc.run();
|
||||
cmdResult.m_stdOut = cmdProc.stdOut().trimmed();
|
||||
cmdResult.m_stdErr = cmdProc.stdErr().trimmed();
|
||||
cmdResult.m_success = cmdProc.result() == QtcProcess::Finished;
|
||||
|
||||
@@ -138,7 +138,8 @@ static void findProcessPID(QFutureInterface<qint64> &fi, QStringList selector,
|
||||
do {
|
||||
QThread::msleep(200);
|
||||
SynchronousProcess proc;
|
||||
proc.runBlocking({adbPath, args});
|
||||
proc.setCommand({adbPath, args});
|
||||
proc.runBlocking();
|
||||
const QByteArray out = proc.allRawOutput();
|
||||
if (preNougat) {
|
||||
processPID = extractPID(out, packageName);
|
||||
|
||||
@@ -154,7 +154,8 @@ static bool sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
|
||||
proc.setEnvironment(AndroidConfigurations::toolsEnvironment(config));
|
||||
proc.setTimeoutS(timeout);
|
||||
proc.setTimeOutMessageBoxEnabled(true);
|
||||
proc.run({config.sdkManagerToolPath(), newArgs});
|
||||
proc.setCommand({config.sdkManagerToolPath(), newArgs});
|
||||
proc.run();
|
||||
if (output)
|
||||
*output = proc.allOutput();
|
||||
return proc.result() == QtcProcess::Finished;
|
||||
@@ -194,7 +195,8 @@ static void sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
|
||||
QObject::connect(&sdkManager, &AndroidSdkManager::cancelActiveOperations,
|
||||
&proc, &SynchronousProcess::stopProcess);
|
||||
}
|
||||
proc.run({config.sdkManagerToolPath(), newArgs});
|
||||
proc.setCommand({config.sdkManagerToolPath(), newArgs});
|
||||
proc.run();
|
||||
if (assertionFound) {
|
||||
output.success = false;
|
||||
output.stdOutput = proc.stdOut();
|
||||
|
||||
@@ -111,7 +111,8 @@ static Macros dumpPredefinedMacros(const FilePath &compiler, const QStringList &
|
||||
cmd.addArg("--predef_macros");
|
||||
cmd.addArg(outpath);
|
||||
|
||||
cpp.runBlocking(cmd);
|
||||
cpp.setCommand(cmd);
|
||||
cpp.runBlocking();
|
||||
if (cpp.result() != QtcProcess::Finished || cpp.exitCode() != 0) {
|
||||
qWarning() << cpp.exitMessage();
|
||||
return {};
|
||||
@@ -145,18 +146,17 @@ static HeaderPaths dumpHeaderPaths(const FilePath &compiler, const Id languageId
|
||||
return {};
|
||||
fakeIn.close();
|
||||
|
||||
SynchronousProcess cpp;
|
||||
cpp.setEnvironment(env);
|
||||
cpp.setTimeoutS(10);
|
||||
|
||||
CommandLine cmd(compiler, {fakeIn.fileName()});
|
||||
if (languageId == ProjectExplorer::Constants::CXX_LANGUAGE_ID)
|
||||
cmd.addArg(cppLanguageOption(compiler));
|
||||
cmd.addArg("--preinclude");
|
||||
cmd.addArg(".");
|
||||
|
||||
// Note: Response should retutn an error, just don't check on errors.
|
||||
cpp.runBlocking(cmd);
|
||||
SynchronousProcess cpp;
|
||||
cpp.setEnvironment(env);
|
||||
cpp.setTimeoutS(10);
|
||||
cpp.setCommand(cmd);
|
||||
cpp.runBlocking();
|
||||
|
||||
HeaderPaths headerPaths;
|
||||
|
||||
|
||||
@@ -138,9 +138,9 @@ static Macros dumpMcsPredefinedMacros(const FilePath &compiler, const Environmen
|
||||
SynchronousProcess cpp;
|
||||
cpp.setEnvironment(env);
|
||||
cpp.setTimeoutS(10);
|
||||
cpp.setCommand({compiler, {fakeIn.fileName()}});
|
||||
|
||||
const CommandLine cmd(compiler, {fakeIn.fileName()});
|
||||
cpp.runBlocking(cmd);
|
||||
cpp.runBlocking();
|
||||
QString output = cpp.allOutput();
|
||||
Macros macros;
|
||||
QTextStream stream(&output);
|
||||
@@ -268,8 +268,8 @@ static Macros dumpC166PredefinedMacros(const FilePath &compiler, const Environme
|
||||
}
|
||||
};
|
||||
|
||||
const CommandLine cmd(compiler, {fakeIn.fileName()});
|
||||
cpp.runBlocking(cmd);
|
||||
cpp.setCommand({compiler, {fakeIn.fileName()}});
|
||||
cpp.runBlocking();
|
||||
const QString output = cpp.allOutput();
|
||||
extractMacros(output);
|
||||
return macros;
|
||||
@@ -284,9 +284,9 @@ static Macros dumpArmPredefinedMacros(const FilePath &compiler, const QStringLis
|
||||
QStringList args = extraArgs;
|
||||
args.push_back("-E");
|
||||
args.push_back("--list-macros");
|
||||
const CommandLine cmd(compiler, args);
|
||||
cpp.setCommand({compiler, args});
|
||||
|
||||
cpp.runBlocking(cmd);
|
||||
cpp.runBlocking();
|
||||
if (cpp.result() != QtcProcess::Finished || cpp.exitCode() != 0) {
|
||||
qWarning() << cpp.exitMessage();
|
||||
return {};
|
||||
|
||||
@@ -90,10 +90,9 @@ static Macros dumpPredefinedMacros(const FilePath &compiler, const Environment &
|
||||
SynchronousProcess cpp;
|
||||
cpp.setEnvironment(env);
|
||||
cpp.setTimeoutS(10);
|
||||
cpp.setCommand({compiler, {compilerTargetFlag(abi), "-dM", "-E", fakeIn.fileName()}});
|
||||
|
||||
const CommandLine cmd(compiler, {compilerTargetFlag(abi), "-dM", "-E", fakeIn.fileName()});
|
||||
|
||||
cpp.runBlocking(cmd);
|
||||
cpp.runBlocking();
|
||||
if (cpp.result() != QtcProcess::Finished || cpp.exitCode() != 0) {
|
||||
qWarning() << cpp.exitMessage();
|
||||
return {};
|
||||
@@ -112,10 +111,9 @@ static HeaderPaths dumpHeaderPaths(const FilePath &compiler, const Environment &
|
||||
SynchronousProcess cpp;
|
||||
cpp.setEnvironment(env);
|
||||
cpp.setTimeoutS(10);
|
||||
cpp.setCommand({compiler, {compilerTargetFlag(abi), "--print-search-dirs"}});
|
||||
|
||||
const CommandLine cmd(compiler, {compilerTargetFlag(abi), "--print-search-dirs"});
|
||||
|
||||
cpp.runBlocking(cmd);
|
||||
cpp.runBlocking();
|
||||
if (cpp.result() != QtcProcess::Finished || cpp.exitCode() != 0) {
|
||||
qWarning() << cpp.exitMessage();
|
||||
return {};
|
||||
|
||||
@@ -84,7 +84,8 @@ static int parseVersion(const QString &text)
|
||||
static int updateVersionHelper(const Utils::FilePath &command)
|
||||
{
|
||||
Utils::SynchronousProcess process;
|
||||
process.runBlocking({command, {"--version"}});
|
||||
process.setCommand({command, {"--version"}});
|
||||
process.runBlocking();
|
||||
if (process.result() != Utils::QtcProcess::Finished)
|
||||
return 0;
|
||||
|
||||
@@ -181,7 +182,8 @@ void ArtisticStyleSettings::createDocumentationFile() const
|
||||
{
|
||||
Utils::SynchronousProcess process;
|
||||
process.setTimeoutS(2);
|
||||
process.runBlocking({command(), {"-h"}});
|
||||
process.setCommand({command(), {"-h"}});
|
||||
process.runBlocking();
|
||||
if (process.result() != Utils::QtcProcess::Finished)
|
||||
return;
|
||||
|
||||
|
||||
@@ -150,7 +150,8 @@ void UncrustifySettings::createDocumentationFile() const
|
||||
{
|
||||
Utils::SynchronousProcess process;
|
||||
process.setTimeoutS(2);
|
||||
process.runBlocking({command(), {"--show-config"}});
|
||||
process.setCommand({command(), {"--show-config"}});
|
||||
process.runBlocking();
|
||||
if (process.result() != Utils::QtcProcess::Finished)
|
||||
return;
|
||||
|
||||
|
||||
@@ -107,8 +107,9 @@ bool ClangToolRunner::supportsVFSOverlay() const
|
||||
static QMap<QString, bool> vfsCapabilities;
|
||||
auto it = vfsCapabilities.find(m_executable);
|
||||
if (it == vfsCapabilities.end()) {
|
||||
Utils::SynchronousProcess p;
|
||||
p.runBlocking(Utils::CommandLine(m_executable, {"--help"}));
|
||||
SynchronousProcess p;
|
||||
p.setCommand({m_executable, {"--help"}});
|
||||
p.runBlocking();
|
||||
it = vfsCapabilities.insert(m_executable, p.allOutput().contains("vfsoverlay"));
|
||||
}
|
||||
return it.value();
|
||||
|
||||
@@ -54,8 +54,9 @@ static QString runExecutable(const Utils::CommandLine &commandLine,
|
||||
Environment env = Environment::systemEnvironment();
|
||||
Environment::setupEnglishOutput(&env);
|
||||
cpp.setEnvironment(env);
|
||||
cpp.setCommand(commandLine);
|
||||
|
||||
cpp.runBlocking(commandLine);
|
||||
cpp.runBlocking();
|
||||
if (cpp.result() != QtcProcess::Finished
|
||||
&& (failSilently == FailSilently::No
|
||||
|| cpp.result() != QtcProcess::FinishedError)) {
|
||||
|
||||
@@ -2358,7 +2358,8 @@ QString ClearCasePluginPrivate::runExtDiff(const QString &workingDir, const QStr
|
||||
process.setTimeoutS(timeOutS);
|
||||
process.setWorkingDirectory(workingDir);
|
||||
process.setCodec(outputCodec ? outputCodec : QTextCodec::codecForName("UTF-8"));
|
||||
process.run(diff);
|
||||
process.setCommand(diff);
|
||||
process.run();
|
||||
if (process.result() != QtcProcess::Finished)
|
||||
return QString();
|
||||
return process.allOutput();
|
||||
|
||||
@@ -239,8 +239,8 @@ static FilePath qmakeFromCMakeCache(const CMakeConfig &config)
|
||||
}
|
||||
|
||||
qCDebug(cmInputLog) << "CMake probing for qmake path: " << cmakeExecutable.toUserOutput() << args;
|
||||
cmake.runBlocking({cmakeExecutable, args});
|
||||
|
||||
cmake.setCommand({cmakeExecutable, args});
|
||||
cmake.runBlocking();
|
||||
|
||||
QFile qmakeLocationTxt(qtcQMakeProbeDir.path() + "/qmake-location.txt");
|
||||
if (!qmakeLocationTxt.open(QIODevice::ReadOnly)) {
|
||||
|
||||
@@ -200,8 +200,8 @@ void CMakeTool::runCMake(SynchronousProcess &cmake, const QStringList &args, int
|
||||
Environment::setupEnglishOutput(&env);
|
||||
cmake.setEnvironment(env);
|
||||
cmake.setTimeOutMessageBoxEnabled(false);
|
||||
|
||||
cmake.runBlocking({cmakeExecutable(), args});
|
||||
cmake.setCommand({cmakeExecutable(), args});
|
||||
cmake.runBlocking();
|
||||
}
|
||||
|
||||
QVariantMap CMakeTool::toMap() const
|
||||
|
||||
@@ -429,7 +429,8 @@ static std::function<void(QFileInfo)> postCopyOperation()
|
||||
// to get it loaded as a plugin in Qt Creator.
|
||||
SynchronousProcess xattr;
|
||||
xattr.setTimeoutS(1);
|
||||
xattr.runBlocking({"/usr/bin/xattr", {"-d", "com.apple.quarantine", fi.absoluteFilePath()}});
|
||||
xattr.setCommand({"/usr/bin/xattr", {"-d", "com.apple.quarantine", fi.absoluteFilePath()}});
|
||||
xattr.runBlocking();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,8 @@ static QString getConfigurationOfGdbCommand(const FilePath &command, const Utils
|
||||
// run gdb with the --configuration opion
|
||||
SynchronousProcess proc;
|
||||
proc.setEnvironment(sysEnv);
|
||||
proc.runBlocking({command, {"--configuration"}});
|
||||
proc.setCommand({command, {"--configuration"}});
|
||||
proc.runBlocking();
|
||||
return proc.allOutput();
|
||||
}
|
||||
|
||||
@@ -185,7 +186,8 @@ void DebuggerItem::reinitializeFromFile(const Utils::Environment &sysEnv)
|
||||
|
||||
SynchronousProcess proc;
|
||||
proc.setEnvironment(sysEnv);
|
||||
proc.runBlocking({m_command, {version}});
|
||||
proc.setCommand({m_command, {version}});
|
||||
proc.runBlocking();
|
||||
if (proc.result() != QtcProcess::Finished) {
|
||||
m_engineType = NoEngineType;
|
||||
return;
|
||||
|
||||
@@ -745,7 +745,8 @@ void DebuggerItemManagerPrivate::autoDetectGdbOrLldbDebuggers()
|
||||
if (HostOsInfo::isMacHost()) {
|
||||
SynchronousProcess proc;
|
||||
proc.setTimeoutS(2);
|
||||
proc.runBlocking({"xcrun", {"--find", "lldb"}});
|
||||
proc.setCommand({"xcrun", {"--find", "lldb"}});
|
||||
proc.runBlocking();
|
||||
if (proc.result() == QtcProcess::Finished) {
|
||||
QString lPath = proc.allOutput().trimmed();
|
||||
if (!lPath.isEmpty()) {
|
||||
|
||||
@@ -4978,7 +4978,8 @@ CoreInfo CoreInfo::readExecutableNameFromCore(const Runnable &debugger, const QS
|
||||
Environment envLang(QProcess::systemEnvironment());
|
||||
Environment::setupEnglishOutput(&envLang);
|
||||
proc.setEnvironment(envLang);
|
||||
proc.runBlocking({debugger.executable, args});
|
||||
proc.setCommand({debugger.executable, args});
|
||||
proc.runBlocking();
|
||||
|
||||
if (proc.result() == QtcProcess::Finished) {
|
||||
QString output = proc.stdOut();
|
||||
|
||||
@@ -235,8 +235,8 @@ static QByteArray decodeProvisioningProfile(const QString &path)
|
||||
Utils::SynchronousProcess p;
|
||||
p.setTimeoutS(3);
|
||||
// path is assumed to be valid file path to .mobileprovision
|
||||
const QStringList args = {"smime", "-inform", "der", "-verify", "-in", path};
|
||||
p.runBlocking({"openssl", args});
|
||||
p.setCommand({"openssl", {"smime", "-inform", "der", "-verify", "-in", path}});
|
||||
p.runBlocking();
|
||||
if (p.result() != Utils::QtcProcess::Finished)
|
||||
qCDebug(iosCommonLog) << "Reading signed provisioning file failed" << path;
|
||||
return p.stdOut().toLatin1();
|
||||
|
||||
@@ -67,8 +67,8 @@ void XcodeProbe::detectDeveloperPaths()
|
||||
{
|
||||
Utils::SynchronousProcess selectedXcode;
|
||||
selectedXcode.setTimeoutS(5);
|
||||
const CommandLine xcodeSelect{"/usr/bin/xcode-select", {"--print-path"}};
|
||||
selectedXcode.run(xcodeSelect);
|
||||
selectedXcode.setCommand({"/usr/bin/xcode-select", {"--print-path"}});
|
||||
selectedXcode.run();
|
||||
if (selectedXcode.result() != QtcProcess::Finished)
|
||||
qCWarning(probeLog)
|
||||
<< QString::fromLatin1("Could not detect selected Xcode using xcode-select");
|
||||
|
||||
@@ -83,7 +83,8 @@ static bool runCommand(const CommandLine &command, QString *stdOutput, QString *
|
||||
{
|
||||
SynchronousProcess p;
|
||||
p.setTimeoutS(-1);
|
||||
p.runBlocking(command);
|
||||
p.setCommand(command);
|
||||
p.runBlocking();
|
||||
if (stdOutput)
|
||||
*stdOutput = p.stdOut();
|
||||
if (allOutput)
|
||||
|
||||
@@ -1272,7 +1272,8 @@ PerforceResponse PerforcePluginPrivate::synchronousProcess(const QString &workin
|
||||
process.setStdOutCallback([](const QString &lines) { VcsOutputWindow::append(lines); });
|
||||
}
|
||||
process.setTimeOutMessageBoxEnabled(true);
|
||||
process.run({m_settings.p4BinaryPath.value(), args});
|
||||
process.setCommand({m_settings.p4BinaryPath.value(), args});
|
||||
process.run();
|
||||
|
||||
PerforceResponse response;
|
||||
response.error = true;
|
||||
|
||||
@@ -112,7 +112,8 @@ static bool
|
||||
if (CustomWizard::verbose())
|
||||
qDebug("In %s, running:\n%s\n", qPrintable(workingDirectory),
|
||||
qPrintable(cmd.toUserOutput()));
|
||||
process.run(cmd);
|
||||
process.setCommand(cmd);
|
||||
process.run();
|
||||
if (process.result() != Utils::QtcProcess::Finished) {
|
||||
*errorMessage = QString("Generator script failed: %1").arg(process.exitMessage());
|
||||
const QString stdErr = process.stdErr();
|
||||
|
||||
@@ -87,8 +87,8 @@ static QByteArray runGcc(const FilePath &gcc, const QStringList &arguments, cons
|
||||
|
||||
cpp.setEnvironment(environment);
|
||||
cpp.setTimeoutS(10);
|
||||
CommandLine cmdLine(gcc, arguments);
|
||||
cpp.runBlocking(cmdLine);
|
||||
cpp.setCommand({gcc, arguments});
|
||||
cpp.runBlocking();
|
||||
if (cpp.result() != QtcProcess::Finished || cpp.exitCode() != 0) {
|
||||
Core::MessageManager::writeFlashing({"Compiler feature detection failure!",
|
||||
cpp.exitMessage(),
|
||||
|
||||
@@ -238,9 +238,9 @@ static QVector<VisualStudioInstallation> detectVisualStudioFromVsWhere(const QSt
|
||||
vsWhereProcess.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
const int timeoutS = 5;
|
||||
vsWhereProcess.setTimeoutS(timeoutS);
|
||||
const CommandLine cmd(vswhere,
|
||||
{"-products", "*", "-prerelease", "-legacy", "-format", "json", "-utf8"});
|
||||
vsWhereProcess.runBlocking(cmd);
|
||||
vsWhereProcess.setCommand({vswhere,
|
||||
{"-products", "*", "-prerelease", "-legacy", "-format", "json", "-utf8"}});
|
||||
vsWhereProcess.runBlocking();
|
||||
switch (vsWhereProcess.result()) {
|
||||
case QtcProcess::Finished:
|
||||
break;
|
||||
@@ -621,7 +621,8 @@ Macros MsvcToolChain::msvcPredefinedMacros(const QStringList &cxxflags,
|
||||
if (language() == ProjectExplorer::Constants::C_LANGUAGE_ID)
|
||||
arguments << QLatin1String("/TC");
|
||||
arguments << toProcess << QLatin1String("/EP") << saver.filePath().toUserOutput();
|
||||
cpp.runBlocking({binary, arguments});
|
||||
cpp.setCommand({binary, arguments});
|
||||
cpp.runBlocking();
|
||||
if (cpp.result() != QtcProcess::Finished || cpp.exitCode() != 0)
|
||||
return predefinedMacros;
|
||||
|
||||
@@ -1495,7 +1496,8 @@ static const MsvcToolChain *findMsvcToolChain(const QString &displayedVarsBat)
|
||||
static QVersionNumber clangClVersion(const QString &clangClPath)
|
||||
{
|
||||
SynchronousProcess clangClProcess;
|
||||
clangClProcess.runBlocking({clangClPath, {"--version"}});
|
||||
clangClProcess.setCommand({clangClPath, {"--version"}});
|
||||
clangClProcess.runBlocking();
|
||||
if (clangClProcess.result() != QtcProcess::Finished || clangClProcess.exitCode() != 0)
|
||||
return {};
|
||||
const QRegularExpressionMatch match = QRegularExpression(
|
||||
@@ -1721,6 +1723,8 @@ Macros ClangClToolChain::msvcPredefinedMacros(const QStringList &cxxflags,
|
||||
arguments.append(gccPredefinedMacrosOptions(language()));
|
||||
arguments.append("-");
|
||||
cpp.runBlocking({clangPath(), arguments});
|
||||
cpp.setCommand({compilerCommand(), arguments});
|
||||
cpp.runBlocking();
|
||||
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.");
|
||||
@@ -2058,7 +2062,8 @@ Utils::optional<QString> MsvcToolChain::generateEnvironmentSettings(const Utils:
|
||||
qDebug() << "readEnvironmentSetting: " << call << cmd.toUserOutput()
|
||||
<< " Env: " << runEnv.size();
|
||||
run.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
run.runBlocking(cmd);
|
||||
run.setCommand(cmd);
|
||||
run.runBlocking();
|
||||
|
||||
if (run.result() != QtcProcess::Finished) {
|
||||
const QString message = !run.stdErr().isEmpty() ? run.stdErr() : run.exitMessage();
|
||||
|
||||
@@ -281,7 +281,8 @@ Interpreter::Interpreter(const FilePath &python, const QString &defaultName, boo
|
||||
SynchronousProcess pythonProcess;
|
||||
pythonProcess.setProcessChannelMode(QProcess::MergedChannels);
|
||||
pythonProcess.setTimeoutS(1);
|
||||
pythonProcess.runBlocking({python, {"--version"}});
|
||||
pythonProcess.setCommand({python, {"--version"}});
|
||||
pythonProcess.runBlocking();
|
||||
if (pythonProcess.result() == QtcProcess::Finished)
|
||||
name = pythonProcess.stdOut().trimmed();
|
||||
if (name.isEmpty())
|
||||
|
||||
@@ -86,8 +86,8 @@ static QString pythonName(const FilePath &pythonPath)
|
||||
if (name.isEmpty()) {
|
||||
SynchronousProcess pythonProcess;
|
||||
pythonProcess.setTimeoutS(2);
|
||||
const CommandLine pythonVersionCommand(pythonPath, {"--version"});
|
||||
pythonProcess.runBlocking(pythonVersionCommand);
|
||||
pythonProcess.setCommand({pythonPath, {"--version"}});
|
||||
pythonProcess.runBlocking();
|
||||
if (pythonProcess.result() != QtcProcess::Finished)
|
||||
return {};
|
||||
name = pythonProcess.allOutput().trimmed();
|
||||
@@ -109,7 +109,8 @@ FilePath getPylsModulePath(CommandLine pylsCommand)
|
||||
Environment env = pythonProcess.environment();
|
||||
env.set("PYTHONVERBOSE", "x");
|
||||
pythonProcess.setEnvironment(env);
|
||||
pythonProcess.runBlocking(pylsCommand);
|
||||
pythonProcess.setCommand(pylsCommand);
|
||||
pythonProcess.runBlocking();
|
||||
|
||||
static const QString pylsInitPattern = "(.*)"
|
||||
+ QRegularExpression::escape(
|
||||
@@ -159,12 +160,13 @@ static PythonLanguageServerState checkPythonLanguageServer(const FilePath &pytho
|
||||
}
|
||||
|
||||
SynchronousProcess pythonProcess;
|
||||
pythonProcess.runBlocking(pythonLShelpCommand);
|
||||
pythonProcess.setCommand(pythonLShelpCommand);
|
||||
pythonProcess.runBlocking();
|
||||
if (pythonProcess.allOutput().contains("Python Language Server"))
|
||||
return {PythonLanguageServerState::AlreadyInstalled, modulePath};
|
||||
|
||||
const CommandLine pythonPipVersionCommand(python, {"-m", "pip", "-V"});
|
||||
pythonProcess.runBlocking(pythonPipVersionCommand);
|
||||
pythonProcess.setCommand({python, {"-m", "pip", "-V"}});
|
||||
pythonProcess.runBlocking();
|
||||
if (pythonProcess.allOutput().startsWith("pip "))
|
||||
return {PythonLanguageServerState::CanBeInstalled, FilePath()};
|
||||
else
|
||||
|
||||
@@ -90,7 +90,8 @@ static FormatTask format(FormatTask task)
|
||||
options.replaceInStrings(QLatin1String("%file"), sourceFile.filePath().toString());
|
||||
SynchronousProcess process;
|
||||
process.setTimeoutS(5);
|
||||
process.runBlocking({executable, options});
|
||||
process.setCommand({executable, options});
|
||||
process.runBlocking();
|
||||
if (process.result() != QtcProcess::Finished) {
|
||||
task.error = QString(QT_TRANSLATE_NOOP("TextEditor", "Failed to format: %1."))
|
||||
.arg(process.exitMessage());
|
||||
|
||||
@@ -74,7 +74,8 @@ QString findFallbackDefinitionsLocation()
|
||||
for (auto &program : programs) {
|
||||
Utils::SynchronousProcess process;
|
||||
process.setTimeoutS(5);
|
||||
process.runBlocking({program, {"--prefix"}});
|
||||
process.setCommand({program, {"--prefix"}});
|
||||
process.runBlocking();
|
||||
if (process.result() == Utils::QtcProcess::Finished) {
|
||||
QString output = process.stdOut();
|
||||
output.remove(QLatin1Char('\n'));
|
||||
|
||||
Reference in New Issue
Block a user