forked from qt-creator/qt-creator
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:
@@ -642,11 +642,6 @@ bool RunWorkerFactory::canRun(RunConfiguration *runConfiguration, Core::Id runMo
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunWorkerFactory::setPriority(int priority)
|
|
||||||
{
|
|
||||||
m_priority = priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunWorkerFactory::setProducer(const WorkerCreator &producer)
|
void RunWorkerFactory::setProducer(const WorkerCreator &producer)
|
||||||
{
|
{
|
||||||
m_producer = 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 auto canRun = std::bind(&RunWorkerFactory::canRun, std::placeholders::_1, runConfig, runMode);
|
||||||
const QList<RunWorkerFactory *> candidates = Utils::filtered(g_runWorkerFactories, canRun);
|
const QList<RunWorkerFactory *> candidates = Utils::filtered(g_runWorkerFactories, canRun);
|
||||||
|
|
||||||
|
// This is legit, there might be combinations that cannot run.
|
||||||
if (candidates.empty())
|
if (candidates.empty())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
const auto higherPriority = std::bind(std::greater<>(),
|
// There should be at most one top-level producer feeling responsible per combination.
|
||||||
std::bind(&RunWorkerFactory::priority, std::placeholders::_1),
|
// Breaking a tie should be done by tightening the restrictions on one of them.
|
||||||
std::bind(&RunWorkerFactory::priority, std::placeholders::_2));
|
QTC_CHECK(candidates.size() == 1);
|
||||||
const auto bestFactory = std::max_element(candidates.begin(), candidates.end(), higherPriority);
|
return candidates.front()->producer();
|
||||||
|
|
||||||
return (*bestFactory)->producer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunControlPrivate::initiateStart()
|
void RunControlPrivate::initiateStart()
|
||||||
|
|||||||
@@ -382,12 +382,10 @@ public:
|
|||||||
|
|
||||||
bool canRun(RunConfiguration *runConfiguration, Core::Id runMode) const;
|
bool canRun(RunConfiguration *runConfiguration, Core::Id runMode) const;
|
||||||
|
|
||||||
void setPriority(int priority);
|
|
||||||
void setProducer(const WorkerCreator &producer);
|
void setProducer(const WorkerCreator &producer);
|
||||||
void addConstraint(const Constraint &constraint);
|
void addConstraint(const Constraint &constraint);
|
||||||
void addSupportedRunMode(Core::Id runMode);
|
void addSupportedRunMode(Core::Id runMode);
|
||||||
|
|
||||||
int priority() const { return m_priority; }
|
|
||||||
WorkerCreator producer() const { return m_producer; }
|
WorkerCreator producer() const { return m_producer; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -399,7 +397,6 @@ private:
|
|||||||
QList<Core::Id> m_supportedRunModes;
|
QList<Core::Id> m_supportedRunModes;
|
||||||
QList<Constraint> m_constraints;
|
QList<Constraint> m_constraints;
|
||||||
WorkerCreator m_producer;
|
WorkerCreator m_producer;
|
||||||
int m_priority = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -478,13 +475,12 @@ public:
|
|||||||
factory->addConstraint(constraint);
|
factory->addConstraint(constraint);
|
||||||
}
|
}
|
||||||
template <class Worker>
|
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;
|
auto factory = new RunWorkerFactory;
|
||||||
factory->setProducer([](RunControl *rc) { return new Worker(rc); });
|
factory->setProducer([](RunControl *rc) { return new Worker(rc); });
|
||||||
factory->addSupportedRunMode(runMode);
|
factory->addSupportedRunMode(runMode);
|
||||||
factory->addConstraint(constraint);
|
factory->addConstraint(constraint);
|
||||||
factory->setPriority(priority);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static WorkerCreator producer(RunConfiguration *runConfiguration, Core::Id runMode);
|
static WorkerCreator producer(RunConfiguration *runConfiguration, Core::Id runMode);
|
||||||
|
|||||||
Reference in New Issue
Block a user