WinRt: Streamline WinRt device construction

Remove create() and init() functions and ctors except default constructor.

Change-Id: I2746ca88bc1e63bdfb05d027c0816b3c8af5ea35
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
hjk
2019-01-15 08:33:33 +01:00
parent 09d54fded3
commit aeb3600eef
3 changed files with 8 additions and 28 deletions

View File

@@ -43,24 +43,6 @@ namespace WinRt {
namespace Internal {
WinRtDevice::WinRtDevice()
{
initFreePorts();
}
WinRtDevice::WinRtDevice(Core::Id internalId, int deviceId)
: m_deviceId(deviceId)
{
setupId(AutoDetected, internalId);
initFreePorts();
}
WinRtDevice::WinRtDevice(const WinRtDevice &other)
: IDevice(other), m_deviceId(other.m_deviceId)
{
initFreePorts();
}
void WinRtDevice::initFreePorts()
{
Utils::PortList portList;
portList.addRange(Utils::Port(ProjectExplorer::Constants::DESKTOP_PORT_START),

View File

@@ -32,11 +32,12 @@ namespace Internal {
class WinRtDevice : public ProjectExplorer::IDevice
{
friend class WinRtDeviceFactory;
public:
typedef QSharedPointer<WinRtDevice> Ptr;
typedef QSharedPointer<const WinRtDevice> ConstPtr;
static Ptr create() { return Ptr(new WinRtDevice); }
QString displayType() const override;
ProjectExplorer::IDeviceWidget *createWidget() override;
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;
@@ -47,16 +48,11 @@ public:
static QString displayNameForType(Core::Id type);
int deviceId() const { return m_deviceId; }
void setDeviceId(int deviceId) { m_deviceId = deviceId; }
protected:
private:
WinRtDevice();
WinRtDevice(Core::Id internalId, int deviceId);
WinRtDevice(const WinRtDevice &other);
private:
void initFreePorts();
private:
int m_deviceId = -1;
};

View File

@@ -63,7 +63,7 @@ WinRtDeviceFactory::WinRtDeviceFactory(Core::Id deviceType)
this, &WinRtDeviceFactory::onPrerequisitesLoaded, Qt::QueuedConnection);
}
setDisplayName(WinRtDevice::displayNameForType(deviceType));
setConstructionFunction([] { return IDevice::Ptr(new WinRtDevice); });
setConstructionFunction(&WinRtDevice::create);
setCombinedIcon(":/winrt/images/winrtdevicesmall.png",
":/winrt/images/winrtdevice.png");
}
@@ -281,7 +281,9 @@ void WinRtDeviceFactory::parseRunnerOutput(const QByteArray &output) const
continue;
}
WinRtDevice *device = new WinRtDevice(internalId, deviceId);
auto device = WinRtDevice::create();
device->setupId(IDevice::AutoDetected, internalId);
device->setDeviceId(deviceId);
device->setType(deviceType);
device->setMachineType(machineType);
device->setDisplayName(name);