aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhjk <[email protected]>2025-09-17 17:54:12 +0200
committerhjk <[email protected]>2025-09-19 10:38:00 +0000
commit51bdd17e5e7f71db53b8442f79950d635b904a8c (patch)
tree3e7a001b0ca73187e5cd478f12f865d33331d205
parenta909e0bfd76795f2433d262c9bff7b5913557427 (diff)
ProjectExplorer: Pass around DeviceConstRef in DeviceToolAspectFactory
So we don't accidentally create additional strong IDevice::ConstPtr copies. Change-Id: I46debbd51ff10373b3bdb17dec2e792fa16d5f3f Reviewed-by: Marcus Tillmanns <[email protected]> Reviewed-by: Christian Kandeler <[email protected]> Reviewed-by: Jarek Kobus <[email protected]>
-rw-r--r--src/plugins/cppeditor/cppeditorplugin.cpp2
-rw-r--r--src/plugins/projectexplorer/devicesupport/idevice.cpp4
-rw-r--r--src/plugins/projectexplorer/devicesupport/idevice.h9
-rw-r--r--src/plugins/qnx/qnxplugin.cpp8
4 files changed, 13 insertions, 10 deletions
diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp
index 06ec60d2efc..00396c5018f 100644
--- a/src/plugins/cppeditor/cppeditorplugin.cpp
+++ b/src/plugins/cppeditor/cppeditorplugin.cpp
@@ -159,7 +159,7 @@ public:
setToolType(DeviceToolAspect::SourceTool);
setFilePattern({"clangd"});
setLabelText(Tr::tr("Clangd executable:"));
- setChecker([](const IDevicePtr &, const FilePath &candidate) {
+ setChecker([](const DeviceConstRef &, const FilePath &candidate) {
return checkClangdVersion(candidate);
});
}
diff --git a/src/plugins/projectexplorer/devicesupport/idevice.cpp b/src/plugins/projectexplorer/devicesupport/idevice.cpp
index 15e74bdef11..9c6a2c10e72 100644
--- a/src/plugins/projectexplorer/devicesupport/idevice.cpp
+++ b/src/plugins/projectexplorer/devicesupport/idevice.cpp
@@ -268,7 +268,7 @@ QStringList DeviceToolAspectFactory::filePattern() const
return m_filePattern;
}
-Result<> DeviceToolAspectFactory::check(const IDevicePtr &device, const FilePath &candidate) const
+Result<> DeviceToolAspectFactory::check(const DeviceConstRef &device, const FilePath &candidate) const
{
if (!m_checker)
return ResultOk;
@@ -320,7 +320,7 @@ void IDevice::autoDetectDeviceTools()
}
}
-DeviceToolAspect *DeviceToolAspectFactory::createAspect(const IDevicePtr &device) const
+DeviceToolAspect *DeviceToolAspectFactory::createAspect(const DeviceConstRef &device) const
{
auto toolAspect = new DeviceToolAspect;
toolAspect->setToolId(m_toolId);
diff --git a/src/plugins/projectexplorer/devicesupport/idevice.h b/src/plugins/projectexplorer/devicesupport/idevice.h
index 5aa2921e45f..048c8b877da 100644
--- a/src/plugins/projectexplorer/devicesupport/idevice.h
+++ b/src/plugins/projectexplorer/devicesupport/idevice.h
@@ -44,6 +44,7 @@ namespace Layouting { class Layout; }
namespace ProjectExplorer {
+class DeviceConstRef;
class FileTransferInterface;
class FileTransferSetupData;
class Kit;
@@ -89,14 +90,14 @@ public:
DeviceToolAspectFactory();
~DeviceToolAspectFactory();
- DeviceToolAspect *createAspect(const IDevicePtr &device) const;
+ DeviceToolAspect *createAspect(const DeviceConstRef &device) const;
Utils::Id toolId() const;
QStringList filePattern() const;
- Utils::Result<> check(const IDevicePtr &device, const Utils::FilePath &) const;
+ Utils::Result<> check(const DeviceConstRef &device, const Utils::FilePath &) const;
protected:
- using Checker = std::function<Utils::Result<>(const IDevicePtr &device, const Utils::FilePath &)>;
+ using Checker = std::function<Utils::Result<>(const DeviceConstRef &device, const Utils::FilePath &)>;
void setToolId(const Utils::Id &toolId);
void setFilePattern(const QStringList &filePattern);
void setLabelText(const QString &labelText);
@@ -106,7 +107,7 @@ protected:
void setToolType(DeviceToolAspect::ToolType toolType);
private:
- void autoDetect(const IDevicePtr &device, const Utils::FilePaths &searchPaths);
+ void autoDetect(const DeviceConstRef &device, const Utils::FilePaths &searchPaths);
Utils::Id m_toolId;
QString m_labelText;
diff --git a/src/plugins/qnx/qnxplugin.cpp b/src/plugins/qnx/qnxplugin.cpp
index 2f396d5ec7b..369d466bd66 100644
--- a/src/plugins/qnx/qnxplugin.cpp
+++ b/src/plugins/qnx/qnxplugin.cpp
@@ -90,10 +90,12 @@ public:
"/opt/qnx800/qnxsdp-env.sh", "/opt/qnx800/qnxsdp-env.bat"});
setLabelText(Tr::tr("QNX sdpenv.sh:"));
setToolTip(Tr::tr("QNX Software Development Platform environment file."));
- setChecker([](const IDevicePtr &device, const FilePath &candidate) -> Result<> {
- if (device->osType() == OsTypeWindows && candidate.suffix() == "bat")
+ setChecker([](const DeviceConstRef &device, const FilePath &candidate) -> Result<> {
+ IDevice::ConstPtr dev = device.lock();
+ QTC_ASSERT(dev, return ResultError(ResultAssert));
+ if (dev->osType() == OsTypeWindows && candidate.suffix() == "bat")
return ResultOk;
- if (device->osType() != OsTypeWindows && candidate.suffix() == "sh")
+ if (dev->osType() != OsTypeWindows && candidate.suffix() == "sh")
return ResultOk;
return ResultError(Tr::tr("File suffix does not match OS type."));
});