diff options
40 files changed, 155 insertions, 103 deletions
diff --git a/src/libs/extensionsystem/pluginmanager.cpp b/src/libs/extensionsystem/pluginmanager.cpp index 052e7d59a6..2efc73e97e 100644 --- a/src/libs/extensionsystem/pluginmanager.cpp +++ b/src/libs/extensionsystem/pluginmanager.cpp @@ -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"; diff --git a/src/libs/utils/buildablehelperlibrary.cpp b/src/libs/utils/buildablehelperlibrary.cpp index 2b6d3742e1..ae288f22e9 100644 --- a/src/libs/utils/buildablehelperlibrary.cpp +++ b/src/libs/utils/buildablehelperlibrary.cpp @@ -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(); diff --git a/src/libs/utils/pathchooser.cpp b/src/libs/utils/pathchooser.cpp index 844883a23a..c87a64097f 100644 --- a/src/libs/utils/pathchooser.cpp +++ b/src/libs/utils/pathchooser.cpp @@ -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(); diff --git a/src/libs/utils/qtcprocess.cpp b/src/libs/utils/qtcprocess.cpp index 0717eecb6b..e1ce8682d0 100644 --- a/src/libs/utils/qtcprocess.cpp +++ b/src/libs/utils/qtcprocess.cpp @@ -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; } diff --git a/src/libs/utils/qtcprocess.h b/src/libs/utils/qtcprocess.h index 33c8999827..b19760a6ce 100644 --- a/src/libs/utils/qtcprocess.h +++ b/src/libs/utils/qtcprocess.h @@ -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); diff --git a/src/libs/utils/shellcommand.cpp b/src/libs/utils/shellcommand.cpp index 2e8d9b8098..dd811cc259 100644 --- a/src/libs/utils/shellcommand.cpp +++ b/src/libs/utils/shellcommand.cpp @@ -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 diff --git a/src/libs/utils/shellcommand.h b/src/libs/utils/shellcommand.h index f2a264293e..5c606cb656 100644 --- a/src/libs/utils/shellcommand.h +++ b/src/libs/utils/shellcommand.h @@ -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); diff --git a/src/plugins/android/androidavdmanager.cpp b/src/plugins/android/androidavdmanager.cpp index 151062ea55..9d6d8116f2 100644 --- a/src/plugins/android/androidavdmanager.cpp +++ b/src/plugins/android/androidavdmanager.cpp @@ -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(); diff --git a/src/plugins/android/androidbuildapkstep.cpp b/src/plugins/android/androidbuildapkstep.cpp index 52304754df..fa6351b43b 100644 --- a/src/plugins/android/androidbuildapkstep.cpp +++ b/src/plugins/android/androidbuildapkstep.cpp @@ -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 diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp index e236068c77..65d8031463 100644 --- a/src/plugins/android/androidconfigurations.cpp +++ b/src/plugins/android/androidconfigurations.cpp @@ -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; diff --git a/src/plugins/android/androidcreatekeystorecertificate.cpp b/src/plugins/android/androidcreatekeystorecertificate.cpp index 584c376922..8bd787c8ba 100644 --- a/src/plugins/android/androidcreatekeystorecertificate.cpp +++ b/src/plugins/android/androidcreatekeystorecertificate.cpp @@ -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"), diff --git a/src/plugins/android/androiddeployqtstep.cpp b/src/plugins/android/androiddeployqtstep.cpp index 9c16d8ad67..fcb1106ffb 100644 --- a/src/plugins/android/androiddeployqtstep.cpp +++ b/src/plugins/android/androiddeployqtstep.cpp @@ -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); diff --git a/src/plugins/android/androidmanager.cpp b/src/plugins/android/androidmanager.cpp index 967432341c..6023e80b2d 100644 --- a/src/plugins/android/androidmanager.cpp +++ b/src/plugins/android/androidmanager.cpp @@ -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; diff --git a/src/plugins/android/androidrunnerworker.cpp b/src/plugins/android/androidrunnerworker.cpp index 3574f38759..14cebeb425 100644 --- a/src/plugins/android/androidrunnerworker.cpp +++ b/src/plugins/android/androidrunnerworker.cpp @@ -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); diff --git a/src/plugins/android/androidsdkmanager.cpp b/src/plugins/android/androidsdkmanager.cpp index d78fc7fe9e..1800d67ccd 100644 --- a/src/plugins/android/androidsdkmanager.cpp +++ b/src/plugins/android/androidsdkmanager.cpp @@ -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(); diff --git a/src/plugins/baremetal/iarewtoolchain.cpp b/src/plugins/baremetal/iarewtoolchain.cpp index c8eaca57fc..38b5b0ed31 100644 --- a/src/plugins/baremetal/iarewtoolchain.cpp +++ b/src/plugins/baremetal/iarewtoolchain.cpp @@ -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; diff --git a/src/plugins/baremetal/keiltoolchain.cpp b/src/plugins/baremetal/keiltoolchain.cpp index a0bbdf7e4f..120b0aee2b 100644 --- a/src/plugins/baremetal/keiltoolchain.cpp +++ b/src/plugins/baremetal/keiltoolchain.cpp @@ -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 {}; diff --git a/src/plugins/baremetal/sdcctoolchain.cpp b/src/plugins/baremetal/sdcctoolchain.cpp index c6cd42d1b3..9c6bc61526 100644 --- a/src/plugins/baremetal/sdcctoolchain.cpp +++ b/src/plugins/baremetal/sdcctoolchain.cpp @@ -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 {}; diff --git a/src/plugins/beautifier/artisticstyle/artisticstylesettings.cpp b/src/plugins/beautifier/artisticstyle/artisticstylesettings.cpp index ee4c734311..4954975cd4 100644 --- a/src/plugins/beautifier/artisticstyle/artisticstylesettings.cpp +++ b/src/plugins/beautifier/artisticstyle/artisticstylesettings.cpp @@ -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; diff --git a/src/plugins/beautifier/uncrustify/uncrustifysettings.cpp b/src/plugins/beautifier/uncrustify/uncrustifysettings.cpp index e43d67b36c..61008fa8ea 100644 --- a/src/plugins/beautifier/uncrustify/uncrustifysettings.cpp +++ b/src/plugins/beautifier/uncrustify/uncrustifysettings.cpp @@ -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; diff --git a/src/plugins/clangtools/clangtoolrunner.cpp b/src/plugins/clangtools/clangtoolrunner.cpp index cb49456d97..6c27ed8aa7 100644 --- a/src/plugins/clangtools/clangtoolrunner.cpp +++ b/src/plugins/clangtools/clangtoolrunner.cpp @@ -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(); diff --git a/src/plugins/clangtools/executableinfo.cpp b/src/plugins/clangtools/executableinfo.cpp index 7348e420ba..71d9554056 100644 --- a/src/plugins/clangtools/executableinfo.cpp +++ b/src/plugins/clangtools/executableinfo.cpp @@ -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)) { diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp index 8f079c5952..4b1d0090b8 100644 --- a/src/plugins/clearcase/clearcaseplugin.cpp +++ b/src/plugins/clearcase/clearcaseplugin.cpp @@ -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(); diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp index 59ab709855..5d32fafbac 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp @@ -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)) { diff --git a/src/plugins/cmakeprojectmanager/cmaketool.cpp b/src/plugins/cmakeprojectmanager/cmaketool.cpp index 0158b5fd7a..e3c0ecee5a 100644 --- a/src/plugins/cmakeprojectmanager/cmaketool.cpp +++ b/src/plugins/cmakeprojectmanager/cmaketool.cpp @@ -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 diff --git a/src/plugins/coreplugin/plugininstallwizard.cpp b/src/plugins/coreplugin/plugininstallwizard.cpp index 60ae9b49b1..16200daf3f 100644 --- a/src/plugins/coreplugin/plugininstallwizard.cpp +++ b/src/plugins/coreplugin/plugininstallwizard.cpp @@ -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(); }; } diff --git a/src/plugins/debugger/debuggeritem.cpp b/src/plugins/debugger/debuggeritem.cpp index 31de7e6600..df3915a009 100644 --- a/src/plugins/debugger/debuggeritem.cpp +++ b/src/plugins/debugger/debuggeritem.cpp @@ -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; diff --git a/src/plugins/debugger/debuggeritemmanager.cpp b/src/plugins/debugger/debuggeritemmanager.cpp index 04c8723d2c..3b42bcf50f 100644 --- a/src/plugins/debugger/debuggeritemmanager.cpp +++ b/src/plugins/debugger/debuggeritemmanager.cpp @@ -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()) { diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index d4655f3a6b..3281aa431b 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -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(); diff --git a/src/plugins/ios/iosconfigurations.cpp b/src/plugins/ios/iosconfigurations.cpp index 26c6db1a37..80b7ba766d 100644 --- a/src/plugins/ios/iosconfigurations.cpp +++ b/src/plugins/ios/iosconfigurations.cpp @@ -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(); diff --git a/src/plugins/ios/iosprobe.cpp b/src/plugins/ios/iosprobe.cpp index d0b369947d..bfcb923ae7 100644 --- a/src/plugins/ios/iosprobe.cpp +++ b/src/plugins/ios/iosprobe.cpp @@ -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"); diff --git a/src/plugins/ios/simulatorcontrol.cpp b/src/plugins/ios/simulatorcontrol.cpp index 8c433d96ec..d0ff9f2c1e 100644 --- a/src/plugins/ios/simulatorcontrol.cpp +++ b/src/plugins/ios/simulatorcontrol.cpp @@ -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) diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index 0d99b4d887..237f0a30d4 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -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; diff --git a/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp b/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp index 62c9308527..90f4ba3ba7 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp @@ -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(); diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index 80dfa42ca1..b881b88977 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -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(), diff --git a/src/plugins/projectexplorer/msvctoolchain.cpp b/src/plugins/projectexplorer/msvctoolchain.cpp index 892a8421d5..17319f1ced 100644 --- a/src/plugins/projectexplorer/msvctoolchain.cpp +++ b/src/plugins/projectexplorer/msvctoolchain.cpp @@ -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(); diff --git a/src/plugins/python/pythonsettings.cpp b/src/plugins/python/pythonsettings.cpp index 9700630bf6..9e665ee1e8 100644 --- a/src/plugins/python/pythonsettings.cpp +++ b/src/plugins/python/pythonsettings.cpp @@ -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()) diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp index 60639492c6..d693c2597b 100644 --- a/src/plugins/python/pythonutils.cpp +++ b/src/plugins/python/pythonutils.cpp @@ -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 diff --git a/src/plugins/texteditor/formattexteditor.cpp b/src/plugins/texteditor/formattexteditor.cpp index 814164baea..57b30d39f2 100644 --- a/src/plugins/texteditor/formattexteditor.cpp +++ b/src/plugins/texteditor/formattexteditor.cpp @@ -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()); diff --git a/src/plugins/texteditor/highlightersettings.cpp b/src/plugins/texteditor/highlightersettings.cpp index f8d0a5902b..f954be4996 100644 --- a/src/plugins/texteditor/highlightersettings.cpp +++ b/src/plugins/texteditor/highlightersettings.cpp @@ -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')); |