From 048a05584c262b898590ecca6fef4ecd40472bdd Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 10 Jan 2018 15:06:52 +0100 Subject: [PATCH] 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 --- .../projectexplorer/buildconfiguration.cpp | 17 +++++++++++------ .../projectexplorer/buildconfiguration.h | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp index a550d49a4ee..2df9cdb0260 100644 --- a/src/plugins/projectexplorer/buildconfiguration.cpp +++ b/src/plugins/projectexplorer/buildconfiguration.cpp @@ -335,11 +335,18 @@ int IBuildConfigurationFactory::priority(const Target *parent) const 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 { QTC_ASSERT(!m_supportedProjectMimeTypeName.isEmpty(), return -1); - if (k && Utils::mimeTypeForFile(projectPath).matchesName(m_supportedProjectMimeTypeName) && - m_supportedTargetDeviceTypes.contains(DeviceTypeKitInformation::deviceTypeId(k))) { + if (k && Utils::mimeTypeForFile(projectPath).matchesName(m_supportedProjectMimeTypeName) + && supportsTargetDeviceType(DeviceTypeKitInformation::deviceTypeId(k))) { return m_basePriority; } return -1; @@ -437,10 +444,8 @@ bool IBuildConfigurationFactory::canHandle(const Target *target) const if (!target->project()->supportsKit(target->kit())) return false; - if (!m_supportedTargetDeviceTypes.isEmpty()) - if (!m_supportedTargetDeviceTypes.contains( - DeviceTypeKitInformation::deviceTypeId(target->kit()))) - return false; + if (!supportsTargetDeviceType(DeviceTypeKitInformation::deviceTypeId(target->kit()))) + return false; return true; } diff --git a/src/plugins/projectexplorer/buildconfiguration.h b/src/plugins/projectexplorer/buildconfiguration.h index 6d2b295a271..a1a6d1161e0 100644 --- a/src/plugins/projectexplorer/buildconfiguration.h +++ b/src/plugins/projectexplorer/buildconfiguration.h @@ -153,6 +153,7 @@ public: virtual bool canHandle(const ProjectExplorer::Target *t) const; protected: + bool supportsTargetDeviceType(Core::Id id) const; void setSupportedProjectType(Core::Id id); void setSupportedProjectMimeTypeName(const QString &mimeTypeName); void setSupportedTargetDeviceTypes(const QList &ids);