iOS: Fix incorrect device type in run configuration

Task-number: QTCREATORBUG-20413
Change-Id: I5b96273161401e83567da80770f0f1c3482b7311
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Vikas Pachdha
2018-05-14 16:16:03 +02:00
parent 5912a93fd5
commit 5cd1bb6f73
2 changed files with 18 additions and 8 deletions

View File

@@ -108,10 +108,19 @@ IosRunConfiguration::IosRunConfiguration(Target *target, Core::Id id)
void IosRunConfiguration::deviceChanges() void IosRunConfiguration::deviceChanges()
{ {
updateDeviceType();
updateDisplayNames(); updateDisplayNames();
updateEnabledState(); updateEnabledState();
} }
void IosRunConfiguration::updateDeviceType()
{
if (DeviceTypeKitInformation::deviceTypeId(target()->kit()) == Constants::IOS_DEVICE_TYPE)
m_deviceType = IosDeviceType(IosDeviceType::IosDevice);
else if (m_deviceType.type == IosDeviceType::IosDevice)
m_deviceType = IosDeviceType(IosDeviceType::SimulatedDevice);
}
QWidget *IosRunConfiguration::createConfigurationWidget() QWidget *IosRunConfiguration::createConfigurationWidget()
{ {
return new IosRunConfigurationWidget(this); return new IosRunConfigurationWidget(this);
@@ -119,10 +128,6 @@ QWidget *IosRunConfiguration::createConfigurationWidget()
void IosRunConfiguration::updateDisplayNames() void IosRunConfiguration::updateDisplayNames()
{ {
if (DeviceTypeKitInformation::deviceTypeId(target()->kit()) == Constants::IOS_DEVICE_TYPE)
m_deviceType = IosDeviceType(IosDeviceType::IosDevice);
else if (m_deviceType.type == IosDeviceType::IosDevice)
m_deviceType = IosDeviceType(IosDeviceType::SimulatedDevice);
IDevice::ConstPtr dev = DeviceKitInformation::device(target()->kit()); IDevice::ConstPtr dev = DeviceKitInformation::device(target()->kit());
const QString devName = dev.isNull() ? IosDevice::name() : dev->displayName(); const QString devName = dev.isNull() ? IosDevice::name() : dev->displayName();
setDefaultDisplayName(tr("Run on %1").arg(devName)); setDefaultDisplayName(tr("Run on %1").arg(devName));
@@ -235,10 +240,7 @@ bool IosRunConfiguration::fromMap(const QVariantMap &map)
bool deviceTypeIsInt; bool deviceTypeIsInt;
map.value(deviceTypeKey).toInt(&deviceTypeIsInt); map.value(deviceTypeKey).toInt(&deviceTypeIsInt);
if (deviceTypeIsInt || !m_deviceType.fromMap(map.value(deviceTypeKey).toMap())) { if (deviceTypeIsInt || !m_deviceType.fromMap(map.value(deviceTypeKey).toMap())) {
if (DeviceTypeKitInformation::deviceTypeId(target()->kit()) == Constants::IOS_DEVICE_TYPE) updateDeviceType();
m_deviceType = IosDeviceType(IosDeviceType::IosDevice);
else
m_deviceType = IosDeviceType(IosDeviceType::SimulatedDevice);
} }
updateDisplayNames(); updateDisplayNames();
@@ -332,6 +334,12 @@ void IosRunConfiguration::setDeviceType(const IosDeviceType &deviceType)
m_deviceType = deviceType; m_deviceType = deviceType;
} }
void IosRunConfiguration::doAdditionalSetup(const RunConfigurationCreationInfo &)
{
updateDeviceType();
updateDisplayNames();
}
IosRunConfigurationWidget::IosRunConfigurationWidget(IosRunConfiguration *runConfiguration) IosRunConfigurationWidget::IosRunConfigurationWidget(IosRunConfiguration *runConfiguration)
: m_runConfiguration(runConfiguration) : m_runConfiguration(runConfiguration)
{ {

View File

@@ -57,6 +57,7 @@ public:
IosDeviceType deviceType() const; IosDeviceType deviceType() const;
void setDeviceType(const IosDeviceType &deviceType); void setDeviceType(const IosDeviceType &deviceType);
void doAdditionalSetup(const ProjectExplorer::RunConfigurationCreationInfo &) override;
bool fromMap(const QVariantMap &map) override; bool fromMap(const QVariantMap &map) override;
QVariantMap toMap() const override; QVariantMap toMap() const override;
@@ -66,6 +67,7 @@ signals:
private: private:
void deviceChanges(); void deviceChanges();
friend class IosRunConfigurationWidget; friend class IosRunConfigurationWidget;
void updateDeviceType();
void updateDisplayNames(); void updateDisplayNames();
void updateEnabledState() final; void updateEnabledState() final;
bool canRunForNode(const ProjectExplorer::Node *node) const final; bool canRunForNode(const ProjectExplorer::Node *node) const final;