forked from qt-creator/qt-creator
ProjectExplorer: Use CommandLine instead of Runnable
Lighter and sufficient for all use cases. Change-Id: Ic6749a1a9e3e6906ce71b87b237cc94a6d8a4cbf Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -148,7 +148,7 @@ void DockerDeviceProcess::interrupt()
|
||||
|
||||
class DockerPortsGatheringMethod : public PortsGatheringMethod
|
||||
{
|
||||
Runnable runnable(QAbstractSocket::NetworkLayerProtocol protocol) const override
|
||||
CommandLine commandLine(QAbstractSocket::NetworkLayerProtocol protocol) const override
|
||||
{
|
||||
// We might encounter the situation that protocol is given IPv6
|
||||
// but the consumer of the free port information decides to open
|
||||
@@ -161,10 +161,8 @@ class DockerPortsGatheringMethod : public PortsGatheringMethod
|
||||
Q_UNUSED(protocol)
|
||||
|
||||
// /proc/net/tcp* covers /proc/net/tcp and /proc/net/tcp6
|
||||
Runnable runnable;
|
||||
runnable.command.setExecutable("sed");
|
||||
runnable.command.setArguments("-e 's/.*: [[:xdigit:]]*:\\([[:xdigit:]]\\{4\\}\\).*/\\1/g' /proc/net/tcp*");
|
||||
return runnable;
|
||||
return {"sed", "-e 's/.*: [[:xdigit:]]*:\\([[:xdigit:]]\\{4\\}\\).*/\\1/g' /proc/net/tcp*",
|
||||
CommandLine::Raw};
|
||||
}
|
||||
|
||||
QList<Utils::Port> usedPorts(const QByteArray &output) const override
|
||||
|
@@ -125,7 +125,7 @@ DeviceEnvironmentFetcher::Ptr DesktopDevice::environmentFetcher() const
|
||||
|
||||
class DesktopPortsGatheringMethod : public PortsGatheringMethod
|
||||
{
|
||||
Runnable runnable(QAbstractSocket::NetworkLayerProtocol protocol) const override
|
||||
CommandLine commandLine(QAbstractSocket::NetworkLayerProtocol protocol) const override
|
||||
{
|
||||
// We might encounter the situation that protocol is given IPv6
|
||||
// but the consumer of the free port information decides to open
|
||||
@@ -137,12 +137,11 @@ class DesktopPortsGatheringMethod : public PortsGatheringMethod
|
||||
|
||||
Q_UNUSED(protocol)
|
||||
|
||||
Runnable runnable;
|
||||
if (HostOsInfo::isWindowsHost() || HostOsInfo::isMacHost())
|
||||
runnable.command = CommandLine{"netstat", {"-a", "-n"}};
|
||||
else if (HostOsInfo::isLinuxHost())
|
||||
runnable.command = CommandLine{"/bin/sh", {"-c", "cat /proc/net/tcp*"}};
|
||||
return runnable;
|
||||
return {"netstat", {"-a", "-n"}};
|
||||
if (HostOsInfo::isLinuxHost())
|
||||
return {"/bin/sh", {"-c", "cat /proc/net/tcp*"}};
|
||||
return {};
|
||||
}
|
||||
|
||||
QList<Utils::Port> usedPorts(const QByteArray &output) const override
|
||||
|
@@ -86,7 +86,8 @@ void DeviceUsedPortsGatherer::start(const IDevice::ConstPtr &device)
|
||||
connect(d->process.data(), &DeviceProcess::readyReadStandardError,
|
||||
this, &DeviceUsedPortsGatherer::handleRemoteStdErr);
|
||||
|
||||
const Runnable runnable = d->portsGatheringMethod->runnable(protocol);
|
||||
Runnable runnable;
|
||||
runnable.command = d->portsGatheringMethod->commandLine(protocol);
|
||||
d->process->start(runnable);
|
||||
}
|
||||
|
||||
|
@@ -63,7 +63,6 @@ class Connection;
|
||||
class DeviceProcess;
|
||||
class DeviceProcessList;
|
||||
class Kit;
|
||||
class Runnable;
|
||||
class Task;
|
||||
|
||||
namespace Internal { class IDevicePrivate; }
|
||||
@@ -116,7 +115,7 @@ public:
|
||||
using Ptr = QSharedPointer<const PortsGatheringMethod>;
|
||||
|
||||
virtual ~PortsGatheringMethod() = default;
|
||||
virtual Runnable runnable(QAbstractSocket::NetworkLayerProtocol protocol) const = 0;
|
||||
virtual Utils::CommandLine commandLine(QAbstractSocket::NetworkLayerProtocol protocol) const = 0;
|
||||
virtual QList<Utils::Port> usedPorts(const QByteArray &commandOutput) const = 0;
|
||||
};
|
||||
|
||||
|
@@ -58,12 +58,10 @@ class QnxPortsGatheringMethod : public PortsGatheringMethod
|
||||
{
|
||||
// TODO: The command is probably needlessly complicated because the parsing method
|
||||
// used to be fixed. These two can now be matched to each other.
|
||||
Runnable runnable(QAbstractSocket::NetworkLayerProtocol protocol) const override
|
||||
CommandLine commandLine(QAbstractSocket::NetworkLayerProtocol protocol) const override
|
||||
{
|
||||
Q_UNUSED(protocol)
|
||||
Runnable runnable;
|
||||
runnable.command = {"netstat", {"-na"}};
|
||||
return runnable;
|
||||
return {"netstat", {"-na"}};
|
||||
}
|
||||
|
||||
QList<Port> usedPorts(const QByteArray &output) const override
|
||||
|
@@ -146,7 +146,7 @@ private:
|
||||
|
||||
class LinuxPortsGatheringMethod : public PortsGatheringMethod
|
||||
{
|
||||
Runnable runnable(QAbstractSocket::NetworkLayerProtocol protocol) const override
|
||||
CommandLine commandLine(QAbstractSocket::NetworkLayerProtocol protocol) const override
|
||||
{
|
||||
// We might encounter the situation that protocol is given IPv6
|
||||
// but the consumer of the free port information decides to open
|
||||
@@ -159,10 +159,8 @@ class LinuxPortsGatheringMethod : public PortsGatheringMethod
|
||||
Q_UNUSED(protocol)
|
||||
|
||||
// /proc/net/tcp* covers /proc/net/tcp and /proc/net/tcp6
|
||||
Runnable runnable;
|
||||
runnable.command.setExecutable("sed");
|
||||
runnable.command.setArguments("-e 's/.*: [[:xdigit:]]*:\\([[:xdigit:]]\\{4\\}\\).*/\\1/g' /proc/net/tcp*");
|
||||
return runnable;
|
||||
return {"sed", "-e 's/.*: [[:xdigit:]]*:\\([[:xdigit:]]\\{4\\}\\).*/\\1/g' /proc/net/tcp*",
|
||||
CommandLine::Raw};
|
||||
}
|
||||
|
||||
QList<Utils::Port> usedPorts(const QByteArray &output) const override
|
||||
|
Reference in New Issue
Block a user