diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 12c3e5f678e..5380acb4783 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1995,17 +1995,6 @@ static RunControlFactory findRunControlFactory(RunConfiguration *config, Core::I }; } - IRunControlFactory *runControlFactory = ExtensionSystem::PluginManager::getObject( - [&config, &mode](IRunControlFactory *factory) { - return factory->canRun(config, mode); - }); - - if (runControlFactory) { - return [runControlFactory](RunConfiguration *rc, Id runMode, QString *errorMessage) { - return runControlFactory->create(rc, runMode, errorMessage); - }; - } - return {}; } diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index 58958c08f2c..2ffb0d200d0 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -48,7 +48,6 @@ namespace Utils { class ProcessHandle; } namespace ProjectExplorer { class RunControl; class RunConfiguration; -class IRunControlFactory; class Project; class Node; class FolderNode; diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 566ecc69129..5e59a9e3d28 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -367,7 +367,7 @@ IRunConfigurationAspect *RunConfiguration::extraAspect(Core::Id id) const A target specific \l RunConfiguration implementation can specify what information it considers necessary to execute a process - on the target. Target specific) \n IRunControlFactory implementation + on the target. Target specific) \n RunWorker implementation can use that information either unmodified or tweak it or ignore it when setting up a RunControl. @@ -473,29 +473,6 @@ QList IRunConfigurationFactory::find(Target *parent) }); } -/*! - \class ProjectExplorer::IRunControlFactory - - \brief The IRunControlFactory class creates RunControl objects matching a - run configuration. -*/ - -/*! - \fn RunConfigWidget *ProjectExplorer::IRunConfigurationAspect::createConfigurationWidget() - - Returns a widget used to configure this runner. Ownership is transferred to - the caller. - - Returns null if @p \a runConfiguration is not suitable for RunControls from this - factory, or no user-accessible - configuration is required. -*/ - -IRunControlFactory::IRunControlFactory(QObject *parent) - : QObject(parent) -{ -} - using WorkerFactories = std::vector; static WorkerFactories &theWorkerFactories() @@ -513,37 +490,6 @@ bool RunControl::WorkerFactory::canRun(RunConfiguration *runConfiguration, Core: return constraint(runConfiguration); } -bool IRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id runMode) const -{ - for (const RunControl::WorkerFactory &factory : theWorkerFactories()) { - if (factory.canRun(runConfiguration, runMode)) - return true; - }; - return false; -} - -RunControl *IRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id runMode, QString *) -{ - WorkerFactories candidates; - for (const RunControl::WorkerFactory &factory : theWorkerFactories()) { - if (factory.canRun(runConfiguration, runMode)) - candidates.push_back(factory); - } - - if (candidates.empty()) - return nullptr; - - RunControl::WorkerFactory bestFactory = *candidates.begin(); - for (const RunControl::WorkerFactory &factory : candidates) { - if (factory.priority > bestFactory.priority) - bestFactory = factory; - } - - auto runControl = new RunControl(runConfiguration, runMode); - bestFactory.producer(runControl); - return runControl; -} - /*! \class ProjectExplorer::RunControl \brief The RunControl class instances represent one item that is run. @@ -558,18 +504,6 @@ RunControl *IRunControlFactory::create(RunConfiguration *runConfiguration, Core: */ -const char PRIORITY_KEY[] = "RunControlFactoryPriority"; - -int ProjectExplorer::IRunControlFactory::priority() const -{ - return property(PRIORITY_KEY).toInt(); // 0 by default. -} - -void IRunControlFactory::setPriority(int priority) -{ - setProperty(PRIORITY_KEY, priority); -} - namespace Internal { enum class RunWorkerState @@ -797,12 +731,22 @@ RunWorker *RunControl::createWorker(Core::Id id) RunControl::WorkerCreator RunControl::producer(RunConfiguration *runConfiguration, Core::Id runMode) { - for (const auto &factory : theWorkerFactories()) { - if (factory.runMode == runMode - && (!factory.constraint || factory.constraint(runConfiguration))) - return factory.producer; + WorkerFactories candidates; + for (const RunControl::WorkerFactory &factory : theWorkerFactories()) { + if (factory.canRun(runConfiguration, runMode)) + candidates.push_back(factory); } - return {}; + + if (candidates.empty()) + return {}; + + RunControl::WorkerFactory bestFactory = *candidates.begin(); + for (const RunControl::WorkerFactory &factory : candidates) { + if (factory.priority > bestFactory.priority) + bestFactory = factory; + } + + return bestFactory.producer; } void RunControl::addWorkerFactory(const RunControl::WorkerFactory &workerFactory) diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 4d49d434ea4..8fabadb6549 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -301,20 +301,6 @@ private: virtual RunConfiguration *doRestore(Target *parent, const QVariantMap &map) = 0; }; -class PROJECTEXPLORER_EXPORT IRunControlFactory : public QObject -{ - Q_OBJECT -public: - explicit IRunControlFactory(QObject *parent = nullptr); - - virtual bool canRun(RunConfiguration *runConfiguration, Core::Id runMode) const; - virtual RunControl *create(RunConfiguration *runConfiguration, Core::Id runMode, QString *errorMessage); - - int priority() const; -protected: - void setPriority(int priority); // Higher values will be preferred. -}; - class PROJECTEXPLORER_EXPORT RunConfigWidget : public QWidget { Q_OBJECT