RemoteLinux: Reuse IDevice::portsGatheringRecipe()

Instead of DeviceUsedPortsGatherer.

Change-Id: I3b2250bdc1d5b6ed0455c643671a80bd0bb32c05
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Jarek Kobus
2024-11-15 15:16:42 +01:00
parent 042e670c3c
commit de5485aba9

View File

@@ -5,9 +5,7 @@
#include "linuxdevice.h"
#include "remotelinuxtr.h"
#include "utils/async.h"
#include <projectexplorer/devicesupport/deviceusedportsgatherer.h>
#include <projectexplorer/devicesupport/filetransfer.h>
#include <projectexplorer/projectexplorerconstants.h>
@@ -161,28 +159,33 @@ GroupItem GenericLinuxDeviceTesterPrivate::unameTask() const
GroupItem GenericLinuxDeviceTesterPrivate::gathererTask() const
{
const auto onSetup = [this](DeviceUsedPortsGatherer &gatherer) {
const Storage<PortsOutputData> portsStorage;
const auto onSetup = [this] {
emit q->progressMessage(Tr::tr("Checking if specified ports are available..."));
gatherer.setDevice(m_device);
};
const auto onDone = [this](const DeviceUsedPortsGatherer &gatherer, DoneWith result) {
if (result != DoneWith::Success) {
emit q->errorMessage(Tr::tr("Error gathering ports: %1").arg(gatherer.errorString()) + '\n'
const auto onDone = [this, portsStorage] {
const auto ports = *portsStorage;
if (!ports) {
emit q->errorMessage(Tr::tr("Error gathering ports: %1").arg(ports.error()) + '\n'
+ Tr::tr("Some tools will not work out of the box.\n"));
} else if (gatherer.usedPorts().isEmpty()) {
} else if (ports->isEmpty()) {
emit q->progressMessage(Tr::tr("All specified ports are available.") + '\n');
} else {
const QString portList = transform(gatherer.usedPorts(), [](const Port &port) {
const QString portList = transform(*ports, [](const Port &port) {
return QString::number(port.number());
}).join(", ");
emit q->errorMessage(Tr::tr("The following specified ports are currently in use: %1")
.arg(portList) + '\n');
}
return true;
};
return Group {
finishAllAndSuccess,
DeviceUsedPortsGathererTask(onSetup, onDone)
portsStorage,
onGroupSetup(onSetup),
m_device->portsGatheringRecipe(portsStorage),
onGroupDone(onDone)
};
}