From 232e8712a5e34b21f8f8fdd0b509a985a48be9e8 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 19 Mar 2018 13:18:27 +0100 Subject: [PATCH] ProjectExplorer: Streamline RunConfigurationFactory interface canHandle() is only used locally in the implementation, so make it private and de-virtualize. canCreateHelper() did nothing except returning true anymore, so remove it. Change-Id: Ifac39e077e3c296b2b2dfc9fbb29c20884e056a3 Reviewed-by: Christian Kandeler --- .../projectexplorer/runconfiguration.cpp | 21 +++++-------------- .../projectexplorer/runconfiguration.h | 6 ++---- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index fbef8e738cf..e097ffa9295 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -499,15 +499,12 @@ RunConfigurationFactory::availableCreators(Target *parent) const } /*! - Specifies a list of device types for which this RunConfigurationFactory - can create RunConfiguration. + Adds a list of device types for which this RunConfigurationFactory + can create RunConfigurations. - Not calling this function or using an empty list means no restriction. + If this function is never called for a RunConfiguarionFactory, + the factory will create RunConfigurations for all device types. */ -void RunConfigurationFactory::setSupportedTargetDeviceTypes(const QList &ids) -{ - m_supportedTargetDeviceTypes = ids; -} void RunConfigurationFactory::addSupportedTargetDeviceType(Core::Id id) { @@ -544,20 +541,12 @@ bool RunConfigurationFactory::canHandle(Target *target) const return true; } -bool RunConfigurationFactory::canCreateHelper(Target *, const QString &) const -{ - return true; -} - RunConfiguration *RunConfigurationCreationInfo::create(Target *target) const { QTC_ASSERT(factory->canHandle(target), return nullptr); QTC_ASSERT(id == factory->runConfigurationBaseId(), return nullptr); - - if (!factory->canCreateHelper(target, targetName)) - return nullptr; - QTC_ASSERT(factory->m_creator, return nullptr); + RunConfiguration *rc = factory->m_creator(target); if (!rc) return nullptr; diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index e4a2bb65d18..50c27b34ec0 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -320,8 +320,6 @@ public: static const QList allRunConfigurationFactories(); - virtual bool canHandle(Target *target) const; - static RunConfiguration *restore(Target *parent, const QVariantMap &map); static RunConfiguration *clone(Target *parent, RunConfiguration *source); static const QList allFactories(); @@ -333,7 +331,6 @@ public: protected: virtual QList availableCreators(Target *parent) const; - virtual bool canCreateHelper(Target *parent, const QString &buildTarget) const; using RunConfigurationCreator = std::function; @@ -345,11 +342,12 @@ protected: } void addSupportedProjectType(Core::Id id); - void setSupportedTargetDeviceTypes(const QList &ids); void addSupportedTargetDeviceType(Core::Id id); void setDecorateDisplayNames(bool on); private: + bool canHandle(Target *target) const; + friend class RunConfigurationCreationInfo; RunConfigurationCreator m_creator; Core::Id m_runConfigBaseId;