ProjectExplorer: Fix handling on restrictions of usable kits

Fixup after 45d6a34f: An empty list of target device restrictions
means 'no restriction'.

Change-Id: I15773e75e58c3ba543d62e13d728cf08dccc3650
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
hjk
2018-01-10 15:06:52 +01:00
parent 4f49b46eaa
commit 048a05584c
2 changed files with 12 additions and 6 deletions

View File

@@ -335,11 +335,18 @@ int IBuildConfigurationFactory::priority(const Target *parent) const
return canHandle(parent) ? m_basePriority : -1; return canHandle(parent) ? m_basePriority : -1;
} }
bool IBuildConfigurationFactory::supportsTargetDeviceType(Core::Id id) const
{
if (m_supportedTargetDeviceTypes.isEmpty())
return true;
return m_supportedTargetDeviceTypes.contains(id);
}
int IBuildConfigurationFactory::priority(const Kit *k, const QString &projectPath) const int IBuildConfigurationFactory::priority(const Kit *k, const QString &projectPath) const
{ {
QTC_ASSERT(!m_supportedProjectMimeTypeName.isEmpty(), return -1); QTC_ASSERT(!m_supportedProjectMimeTypeName.isEmpty(), return -1);
if (k && Utils::mimeTypeForFile(projectPath).matchesName(m_supportedProjectMimeTypeName) && if (k && Utils::mimeTypeForFile(projectPath).matchesName(m_supportedProjectMimeTypeName)
m_supportedTargetDeviceTypes.contains(DeviceTypeKitInformation::deviceTypeId(k))) { && supportsTargetDeviceType(DeviceTypeKitInformation::deviceTypeId(k))) {
return m_basePriority; return m_basePriority;
} }
return -1; return -1;
@@ -437,10 +444,8 @@ bool IBuildConfigurationFactory::canHandle(const Target *target) const
if (!target->project()->supportsKit(target->kit())) if (!target->project()->supportsKit(target->kit()))
return false; return false;
if (!m_supportedTargetDeviceTypes.isEmpty()) if (!supportsTargetDeviceType(DeviceTypeKitInformation::deviceTypeId(target->kit())))
if (!m_supportedTargetDeviceTypes.contains( return false;
DeviceTypeKitInformation::deviceTypeId(target->kit())))
return false;
return true; return true;
} }

View File

@@ -153,6 +153,7 @@ public:
virtual bool canHandle(const ProjectExplorer::Target *t) const; virtual bool canHandle(const ProjectExplorer::Target *t) const;
protected: protected:
bool supportsTargetDeviceType(Core::Id id) const;
void setSupportedProjectType(Core::Id id); void setSupportedProjectType(Core::Id id);
void setSupportedProjectMimeTypeName(const QString &mimeTypeName); void setSupportedProjectMimeTypeName(const QString &mimeTypeName);
void setSupportedTargetDeviceTypes(const QList<Core::Id> &ids); void setSupportedTargetDeviceTypes(const QList<Core::Id> &ids);