From e3d87f9d0f4bdee956e35636412878f4d384f0c3 Mon Sep 17 00:00:00 2001 From: Artem Sokolovskii Date: Wed, 25 Aug 2021 13:48:44 +0200 Subject: [PATCH] Use QtcProcess Change-Id: Ie41a40534f231c68797205e4dd817f5e98963b07 Reviewed-by: hjk --- .../boot2qt/device-detection/qdbwatcher.cpp | 4 ++-- src/plugins/boot2qt/qdbplugin.cpp | 23 ++++++++++--------- src/plugins/debugger/moduleshandler.cpp | 2 +- .../qmakeprojectmanager/externaleditors.cpp | 4 ++-- .../qmakeprojectmanager/externaleditors.h | 3 ++- src/plugins/valgrind/callgrindtool.cpp | 2 +- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/plugins/boot2qt/device-detection/qdbwatcher.cpp b/src/plugins/boot2qt/device-detection/qdbwatcher.cpp index 377c84f21ce..3d54227a514 100644 --- a/src/plugins/boot2qt/device-detection/qdbwatcher.cpp +++ b/src/plugins/boot2qt/device-detection/qdbwatcher.cpp @@ -29,9 +29,9 @@ #include "hostmessages.h" #include +#include #include -#include #include namespace Qdb { @@ -147,7 +147,7 @@ void QdbWatcher::forkHostServer() showMessage(message, true); return; } - if (QProcess::startDetached(qdbFilePath.toString(), {"server"})) + if (Utils::QtcProcess::startDetached({qdbFilePath, {"server"}})) showMessage(tr("QDB host server started."), false); else showMessage(tr("Could not start QDB host server in %1").arg(qdbFilePath.toString()), true); diff --git a/src/plugins/boot2qt/qdbplugin.cpp b/src/plugins/boot2qt/qdbplugin.cpp index 37bd47e9c46..95ccb37de89 100644 --- a/src/plugins/boot2qt/qdbplugin.cpp +++ b/src/plugins/boot2qt/qdbplugin.cpp @@ -52,33 +52,34 @@ #include #include +#include #include #include -#include using namespace ProjectExplorer; +using namespace Utils; namespace Qdb { namespace Internal { -static Utils::FilePath flashWizardFilePath() +static FilePath flashWizardFilePath() { return findTool(QdbTool::FlashingWizard); } static void startFlashingWizard() { - const QString filePath = flashWizardFilePath().toUserOutput(); - if (Utils::HostOsInfo::isWindowsHost()) { - if (QProcess::startDetached(QLatin1String("explorer.exe"), {filePath})) + const FilePath filePath = flashWizardFilePath(); + if (HostOsInfo::isWindowsHost()) { + if (QtcProcess::startDetached({"explorer.exe", {filePath.toString()}})) return; - } else if (QProcess::startDetached(filePath, {})) { + } else if (QtcProcess::startDetached({filePath, {}})) { return; } const QString message = QCoreApplication::translate("Qdb", "Flash wizard \"%1\" failed to start."); - showMessage(message.arg(filePath), true); + showMessage(message.arg(filePath.toUserOutput()), true); } static bool isFlashActionDisabled() @@ -94,7 +95,7 @@ void registerFlashAction(QObject *parentForAction) { if (isFlashActionDisabled()) return; - const Utils::FilePath fileName = flashWizardFilePath(); + const FilePath fileName = flashWizardFilePath(); if (!fileName.exists()) { const QString message = QCoreApplication::translate("Qdb", "Flash wizard executable \"%1\" not found."); @@ -146,7 +147,7 @@ public: Runnable r = runControl->runnable(); // FIXME: Spaces! r.command.setArguments(r.command.executable().toString() + ' ' + r.command.arguments()); - r.command.setExecutable(Utils::FilePath::fromString(Constants::AppcontrollerFilepath)); + r.command.setExecutable(FilePath::fromString(Constants::AppcontrollerFilepath)); doStart(r, runControl->device()); }); } @@ -156,7 +157,7 @@ template class QdbDeployStepFactory : public ProjectExplorer::BuildStepFactory { public: - explicit QdbDeployStepFactory(Utils::Id id) + explicit QdbDeployStepFactory(Id id) { registerStep(id); setDisplayName(Step::displayName()); @@ -184,7 +185,7 @@ public: QdbDeployStepFactory m_makeInstallStepFactory{RemoteLinux::Constants::MakeInstallStepId}; - const QList supportedRunConfigs { + const QList supportedRunConfigs { m_runConfigFactory.runConfigurationId(), "QmlProjectManager.QmlRunConfiguration" }; diff --git a/src/plugins/debugger/moduleshandler.cpp b/src/plugins/debugger/moduleshandler.cpp index 8ab9d3e2772..922c8bec2af 100644 --- a/src/plugins/debugger/moduleshandler.cpp +++ b/src/plugins/debugger/moduleshandler.cpp @@ -192,7 +192,7 @@ bool ModulesModel::contextMenuEvent(const ItemViewEvent &ev) addAction(menu, tr("Show Dependencies of \"%1\"").arg(moduleName), tr("Show Dependencies"), moduleNameValid && !moduleName.isEmpty() && HostOsInfo::isWindowsHost(), - [modulePath] { QProcess::startDetached("depends", {modulePath}); }); + [modulePath] { QtcProcess::startDetached({{"depends"}, {modulePath}}); }); addAction(menu, tr("Load Symbols for All Modules"), enabled && canLoadSymbols, diff --git a/src/plugins/qmakeprojectmanager/externaleditors.cpp b/src/plugins/qmakeprojectmanager/externaleditors.cpp index 538740e0804..fe953a00498 100644 --- a/src/plugins/qmakeprojectmanager/externaleditors.cpp +++ b/src/plugins/qmakeprojectmanager/externaleditors.cpp @@ -170,7 +170,7 @@ bool ExternalQtEditor::getEditorLaunchData(const Utils::FilePath &filePath, data->workingDirectory.clear(); QVector qtVersionsToCheck; // deduplicated after being filled if (const Project *project = SessionManager::projectForFile(filePath)) { - data->workingDirectory = project->projectDirectory().toString(); + data->workingDirectory = project->projectDirectory(); // active kit if (const Target *target = project->activeTarget()) { qtVersionsToCheck << QtSupport::QtKitAspect::qtVersion(target->kit()); @@ -214,7 +214,7 @@ bool ExternalQtEditor::startEditorProcess(const LaunchData &data, QString *error if (debug) qDebug() << Q_FUNC_INFO << '\n' << data.binary << data.arguments << data.workingDirectory; qint64 pid = 0; - if (!QProcess::startDetached(data.binary, data.arguments, data.workingDirectory, &pid)) { + if (!QtcProcess::startDetached({FilePath::fromString(data.binary), data.arguments}, data.workingDirectory, &pid)) { *errorMessage = msgStartFailed(data.binary, data.arguments); return false; } diff --git a/src/plugins/qmakeprojectmanager/externaleditors.h b/src/plugins/qmakeprojectmanager/externaleditors.h index 8a750f6a2d8..d4b4c5becdc 100644 --- a/src/plugins/qmakeprojectmanager/externaleditors.h +++ b/src/plugins/qmakeprojectmanager/externaleditors.h @@ -26,6 +26,7 @@ #pragma once #include +#include #include #include @@ -68,7 +69,7 @@ public: struct LaunchData { QString binary; QStringList arguments; - QString workingDirectory; + Utils::FilePath workingDirectory; }; protected: diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp index 0c3ed37883a..a169bee9e12 100644 --- a/src/plugins/valgrind/callgrindtool.cpp +++ b/src/plugins/valgrind/callgrindtool.cpp @@ -378,7 +378,7 @@ CallgrindToolPrivate::CallgrindToolPrivate() action->setIcon(kCachegrindIcon.icon()); action->setToolTip(CallgrindTool::tr("Open results in KCachegrind.")); connect(action, &QAction::triggered, this, [this, settings] { - QProcess::startDetached(settings->kcachegrindExecutable.value(), { m_lastFileName }); + QtcProcess::startDetached({FilePath::fromString(settings->kcachegrindExecutable.value()), { m_lastFileName }}); }); // dump action