From 603ea1c6799daa631665f09911873137b103499f Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 24 May 2022 10:11:08 +0200 Subject: [PATCH] ProjectExplorer: Introduce DeviceKitAspect::deviceFilePath() A convenience method redirecting to IDevice::filePath. Change-Id: I1bd4a6500fa051641873020244d97e307f579e72 Reviewed-by: Jarek Kobus Reviewed-by: Christian Stenger Reviewed-by: Qt CI Bot --- src/plugins/debugger/analyzer/startremotedialog.cpp | 7 ++----- src/plugins/projectexplorer/kitinformation.cpp | 7 +++++++ src/plugins/projectexplorer/kitinformation.h | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/plugins/debugger/analyzer/startremotedialog.cpp b/src/plugins/debugger/analyzer/startremotedialog.cpp index e148c0f5bff..700b688fad8 100644 --- a/src/plugins/debugger/analyzer/startremotedialog.cpp +++ b/src/plugins/debugger/analyzer/startremotedialog.cpp @@ -131,11 +131,8 @@ void StartRemoteDialog::validate() Runnable StartRemoteDialog::runnable() const { - Kit *kit = d->kitChooser->currentKit(); - IDevice::ConstPtr device = DeviceKitAspect::device(kit); - FilePath filePath = FilePath::fromString(d->executable->text()); - if (device) - filePath = device->filePath(d->arguments->text()); + const Kit *kit = d->kitChooser->currentKit(); + const FilePath filePath = DeviceKitAspect::deviceFilePath(kit, d->executable->text()); Runnable r; r.command = {filePath, d->arguments->text(), CommandLine::Raw}; diff --git a/src/plugins/projectexplorer/kitinformation.cpp b/src/plugins/projectexplorer/kitinformation.cpp index 994a21465c9..a39c091dba3 100644 --- a/src/plugins/projectexplorer/kitinformation.cpp +++ b/src/plugins/projectexplorer/kitinformation.cpp @@ -1110,6 +1110,13 @@ void DeviceKitAspect::setDeviceId(Kit *k, Utils::Id id) k->setValue(DeviceKitAspect::id(), id.toSetting()); } +FilePath DeviceKitAspect::deviceFilePath(const Kit *k, const QString &pathOnDevice) +{ + if (IDevice::ConstPtr dev = device(k)) + return dev->filePath(pathOnDevice); + return FilePath::fromString(pathOnDevice); +} + void DeviceKitAspect::kitsWereLoaded() { const QList kits = KitManager::kits(); diff --git a/src/plugins/projectexplorer/kitinformation.h b/src/plugins/projectexplorer/kitinformation.h index de0939b8388..a925d84ba47 100644 --- a/src/plugins/projectexplorer/kitinformation.h +++ b/src/plugins/projectexplorer/kitinformation.h @@ -161,6 +161,7 @@ public: static Utils::Id deviceId(const Kit *k); static void setDevice(Kit *k, IDeviceConstPtr dev); static void setDeviceId(Kit *k, Utils::Id dataId); + static Utils::FilePath deviceFilePath(const Kit *k, const QString &pathOnDevice); private: QVariant defaultValue(const Kit *k) const;