ProjectExplorer: Decommission RunWorkerFactory::priority

The only ever user (AppManager) doesn't need it for disambiguation
anymore.

Change-Id: Iea2f4d545bf9afb0610bf73c4ec7b2f29357edc0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
hjk
2018-06-04 10:28:16 +02:00
parent ed2fbeeecf
commit b9a8e77a82
2 changed files with 6 additions and 16 deletions

View File

@@ -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<RunWorkerFactory *> 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()

View File

@@ -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<Core::Id> m_supportedRunModes;
QList<Constraint> m_constraints;
WorkerCreator m_producer;
int m_priority = 0;
};
/**
@@ -478,13 +475,12 @@ public:
factory->addConstraint(constraint);
}
template <class Worker>
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);