forked from qt-creator/qt-creator
ProjectExplorer: Use the fromMap(toMap()) pattern to clone devices
Change-Id: Ie6e73f5ef1019907dd311aac116d71f08b5a5202 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -92,8 +92,6 @@ IosDevice::IosDevice()
|
||||
setFreePorts(ports);
|
||||
}
|
||||
|
||||
IosDevice::IosDevice(const IosDevice &other) = default;
|
||||
|
||||
IosDevice::IosDevice(const QString &uid)
|
||||
: m_lastPort(Constants::IOS_DEVICE_PORT_START)
|
||||
{
|
||||
@@ -133,11 +131,6 @@ DeviceProcessSignalOperation::Ptr IosDevice::signalOperation() const
|
||||
return DeviceProcessSignalOperation::Ptr();
|
||||
}
|
||||
|
||||
IDevice::Ptr IosDevice::clone() const
|
||||
{
|
||||
return IDevice::Ptr(new IosDevice(*this));
|
||||
}
|
||||
|
||||
void IosDevice::fromMap(const QVariantMap &map)
|
||||
{
|
||||
IDevice::fromMap(map);
|
||||
@@ -236,8 +229,8 @@ void IosDeviceManager::deviceConnected(const QString &uid, const QString &name)
|
||||
qCDebug(detectLog) << "updating ios device " << uid;
|
||||
IosDevice *newDev = nullptr;
|
||||
if (dev->type() == devType) {
|
||||
auto iosDev = static_cast<const IosDevice *>(dev.data());
|
||||
newDev = new IosDevice(*iosDev);
|
||||
newDev = new IosDevice();
|
||||
newDev->fromMap(dev->toMap());
|
||||
} else {
|
||||
newDev = new IosDevice(uid);
|
||||
}
|
||||
@@ -294,7 +287,8 @@ void IosDeviceManager::deviceInfo(IosToolHandler *, const QString &uid,
|
||||
skipUpdate = true;
|
||||
newDev = const_cast<IosDevice *>(iosDev);
|
||||
} else {
|
||||
newDev = new IosDevice(*iosDev);
|
||||
newDev = new IosDevice();
|
||||
newDev->fromMap(iosDev->toMap());
|
||||
}
|
||||
} else {
|
||||
newDev = new IosDevice(uid);
|
||||
|
||||
@@ -54,7 +54,6 @@ public:
|
||||
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;
|
||||
QString displayType() const override;
|
||||
|
||||
ProjectExplorer::IDevice::Ptr clone() const override;
|
||||
void fromMap(const QVariantMap &map) override;
|
||||
QVariantMap toMap() const override;
|
||||
QString uniqueDeviceID() const;
|
||||
@@ -69,7 +68,6 @@ protected:
|
||||
friend class IosDeviceFactory;
|
||||
friend class Ios::Internal::IosDeviceManager;
|
||||
IosDevice();
|
||||
IosDevice(const IosDevice &other);
|
||||
IosDevice(const QString &uid);
|
||||
|
||||
Dict m_extraInfo;
|
||||
|
||||
@@ -64,14 +64,6 @@ IosSimulator::IosSimulator()
|
||||
setDeviceState(DeviceReadyToUse);
|
||||
}
|
||||
|
||||
IosSimulator::IosSimulator(const IosSimulator &other)
|
||||
: IDevice(other), m_lastPort(other.m_lastPort)
|
||||
{
|
||||
setDisplayName(QCoreApplication::translate("Ios::Internal::IosSimulator", "iOS Simulator"));
|
||||
setDeviceState(DeviceReadyToUse);
|
||||
}
|
||||
|
||||
|
||||
IDevice::DeviceInfo IosSimulator::deviceInformation() const
|
||||
{
|
||||
return IDevice::DeviceInfo();
|
||||
@@ -92,11 +84,6 @@ DeviceProcessSignalOperation::Ptr IosSimulator::signalOperation() const
|
||||
return DeviceProcessSignalOperation::Ptr();
|
||||
}
|
||||
|
||||
IDevice::Ptr IosSimulator::clone() const
|
||||
{
|
||||
return IDevice::Ptr(new IosSimulator(*this));
|
||||
}
|
||||
|
||||
Utils::Port IosSimulator::nextPort() const
|
||||
{
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
|
||||
@@ -76,13 +76,12 @@ public:
|
||||
bool canAutoDetectPorts() const override;
|
||||
Utils::OsType osType() const override;
|
||||
|
||||
ProjectExplorer::IDevice::Ptr clone() const override;
|
||||
protected:
|
||||
friend class IosSimulatorFactory;
|
||||
friend class IosConfigurations;
|
||||
IosSimulator();
|
||||
IosSimulator(Core::Id id);
|
||||
IosSimulator(const IosSimulator &other);
|
||||
|
||||
private:
|
||||
mutable quint16 m_lastPort;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user