From b9a8e77a829eafe2171d9ab0bc34efe422cddf17 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 4 Jun 2018 10:28:16 +0200 Subject: [PATCH] ProjectExplorer: Decommission RunWorkerFactory::priority The only ever user (AppManager) doesn't need it for disambiguation anymore. Change-Id: Iea2f4d545bf9afb0610bf73c4ec7b2f29357edc0 Reviewed-by: Ulf Hermann --- src/plugins/projectexplorer/runconfiguration.cpp | 16 +++++----------- src/plugins/projectexplorer/runconfiguration.h | 6 +----- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index cbf24c37e21..21ddbf03360 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -642,11 +642,6 @@ bool RunWorkerFactory::canRun(RunConfiguration *runConfiguration, Core::Id runMo return true; } -void RunWorkerFactory::setPriority(int priority) -{ - m_priority = priority; -} - void RunWorkerFactory::setProducer(const WorkerCreator &producer) { m_producer = producer; @@ -971,15 +966,14 @@ RunWorkerFactory::WorkerCreator RunControl::producer(RunConfiguration *runConfig const auto canRun = std::bind(&RunWorkerFactory::canRun, std::placeholders::_1, runConfig, runMode); const QList candidates = Utils::filtered(g_runWorkerFactories, canRun); + // This is legit, there might be combinations that cannot run. if (candidates.empty()) return {}; - const auto higherPriority = std::bind(std::greater<>(), - std::bind(&RunWorkerFactory::priority, std::placeholders::_1), - std::bind(&RunWorkerFactory::priority, std::placeholders::_2)); - const auto bestFactory = std::max_element(candidates.begin(), candidates.end(), higherPriority); - - return (*bestFactory)->producer(); + // There should be at most one top-level producer feeling responsible per combination. + // Breaking a tie should be done by tightening the restrictions on one of them. + QTC_CHECK(candidates.size() == 1); + return candidates.front()->producer(); } void RunControlPrivate::initiateStart() diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index aaac5f7595c..33c72a9654c 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -382,12 +382,10 @@ public: bool canRun(RunConfiguration *runConfiguration, Core::Id runMode) const; - void setPriority(int priority); void setProducer(const WorkerCreator &producer); void addConstraint(const Constraint &constraint); void addSupportedRunMode(Core::Id runMode); - int priority() const { return m_priority; } WorkerCreator producer() const { return m_producer; } private: @@ -399,7 +397,6 @@ private: QList m_supportedRunModes; QList m_constraints; WorkerCreator m_producer; - int m_priority = 0; }; /** @@ -478,13 +475,12 @@ public: factory->addConstraint(constraint); } template - static void registerWorker(Core::Id runMode, const Constraint &constraint, int priority = 0) + static void registerWorker(Core::Id runMode, const Constraint &constraint) { auto factory = new RunWorkerFactory; factory->setProducer([](RunControl *rc) { return new Worker(rc); }); factory->addSupportedRunMode(runMode); factory->addConstraint(constraint); - factory->setPriority(priority); } static WorkerCreator producer(RunConfiguration *runConfiguration, Core::Id runMode);