forked from qt-creator/qt-creator
ProjectExplorer: Replace one overload of RunControl::registerWorker
... by using factory members in the plugin pimpl. This also (intentionally) transfers ownership of the factories to the plugins, effectively progressing on the "FIXME:" in runcontrol.h:164. Change-Id: Ia75ee034d25a75b5d5bff6b2fa2b3471347d1a14 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -88,6 +88,25 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class QmlPreviewRunWorkerFactory : public RunWorkerFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QmlPreviewRunWorkerFactory()
|
||||||
|
{
|
||||||
|
addSupportedRunMode(QML_PREVIEW_RUN_MODE);
|
||||||
|
setProducer([](RunControl *runControl) -> RunWorker * {
|
||||||
|
const Runnable runnable = runControl->runConfiguration()->runnable();
|
||||||
|
return new AndroidQmlToolingSupport(runControl, runnable.executable);
|
||||||
|
});
|
||||||
|
addConstraint([](RunConfiguration *runConfig) {
|
||||||
|
return runConfig->isEnabled()
|
||||||
|
&& runConfig->id().name().startsWith("QmlProjectManager.QmlRunConfiguration")
|
||||||
|
&& DeviceTypeKitAspect::deviceTypeId(runConfig->target()->kit())
|
||||||
|
== Android::Constants::ANDROID_DEVICE_TYPE;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class AndroidPluginPrivate : public QObject
|
class AndroidPluginPrivate : public QObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -131,6 +150,7 @@ public:
|
|||||||
AndroidPackageInstallationFactory packackeInstallationFactory;
|
AndroidPackageInstallationFactory packackeInstallationFactory;
|
||||||
AndroidManifestEditorFactory manifestEditorFactory;
|
AndroidManifestEditorFactory manifestEditorFactory;
|
||||||
AndroidRunConfigurationFactory runConfigFactory;
|
AndroidRunConfigurationFactory runConfigFactory;
|
||||||
|
|
||||||
SimpleRunWorkerFactory<AndroidRunConfiguration, AndroidRunSupport> runWorkerFactory;
|
SimpleRunWorkerFactory<AndroidRunConfiguration, AndroidRunSupport> runWorkerFactory;
|
||||||
SimpleRunWorkerFactory<AndroidRunConfiguration, AndroidDebugSupport>
|
SimpleRunWorkerFactory<AndroidRunConfiguration, AndroidDebugSupport>
|
||||||
debugWorkerFactory{DEBUG_RUN_MODE};
|
debugWorkerFactory{DEBUG_RUN_MODE};
|
||||||
@@ -138,6 +158,8 @@ public:
|
|||||||
profilerWorkerFactory{QML_PROFILER_RUN_MODE};
|
profilerWorkerFactory{QML_PROFILER_RUN_MODE};
|
||||||
SimpleRunWorkerFactory<AndroidRunConfiguration, AndroidQmlToolingSupport>
|
SimpleRunWorkerFactory<AndroidRunConfiguration, AndroidQmlToolingSupport>
|
||||||
qmlPreviewWorkerFactory{QML_PREVIEW_RUN_MODE};
|
qmlPreviewWorkerFactory{QML_PREVIEW_RUN_MODE};
|
||||||
|
QmlPreviewRunWorkerFactory qmlPreviewWorkerFactory2;
|
||||||
|
|
||||||
AndroidBuildApkStepFactory buildApkStepFactory;
|
AndroidBuildApkStepFactory buildApkStepFactory;
|
||||||
AndroidGdbServerKitAspect gdbServerKitAspect;
|
AndroidGdbServerKitAspect gdbServerKitAspect;
|
||||||
};
|
};
|
||||||
@@ -152,16 +174,6 @@ bool AndroidPlugin::initialize(const QStringList &arguments, QString *errorMessa
|
|||||||
Q_UNUSED(arguments);
|
Q_UNUSED(arguments);
|
||||||
Q_UNUSED(errorMessage);
|
Q_UNUSED(errorMessage);
|
||||||
|
|
||||||
RunControl::registerWorker(QML_PREVIEW_RUN_MODE, [](RunControl *runControl) -> RunWorker* {
|
|
||||||
const Runnable runnable = runControl->runConfiguration()->runnable();
|
|
||||||
return new AndroidQmlToolingSupport(runControl, runnable.executable);
|
|
||||||
}, [](RunConfiguration *runConfig) {
|
|
||||||
return runConfig->isEnabled()
|
|
||||||
&& runConfig->id().name().startsWith("QmlProjectManager.QmlRunConfiguration")
|
|
||||||
&& DeviceTypeKitAspect::deviceTypeId(runConfig->target()->kit())
|
|
||||||
== Android::Constants::ANDROID_DEVICE_TYPE;
|
|
||||||
});
|
|
||||||
|
|
||||||
d = new AndroidPluginPrivate;
|
d = new AndroidPluginPrivate;
|
||||||
|
|
||||||
connect(KitManager::instance(), &KitManager::kitsLoaded,
|
connect(KitManager::instance(), &KitManager::kitsLoaded,
|
||||||
|
@@ -257,14 +257,6 @@ public:
|
|||||||
|
|
||||||
static void registerWorkerCreator(Core::Id id, const WorkerCreator &workerCreator);
|
static void registerWorkerCreator(Core::Id id, const WorkerCreator &workerCreator);
|
||||||
|
|
||||||
static void registerWorker(Core::Id runMode, const WorkerCreator &producer,
|
|
||||||
const Constraint &constraint = {})
|
|
||||||
{
|
|
||||||
auto factory = new RunWorkerFactory;
|
|
||||||
factory->setProducer(producer);
|
|
||||||
factory->addSupportedRunMode(runMode);
|
|
||||||
factory->addConstraint(constraint);
|
|
||||||
}
|
|
||||||
template <class Worker>
|
template <class Worker>
|
||||||
static void registerWorker(Core::Id runMode, const Constraint &constraint)
|
static void registerWorker(Core::Id runMode, const Constraint &constraint)
|
||||||
{
|
{
|
||||||
|
@@ -80,12 +80,34 @@ namespace Internal {
|
|||||||
|
|
||||||
Q_GLOBAL_STATIC(QmlProfilerSettings, qmlProfilerGlobalSettings)
|
Q_GLOBAL_STATIC(QmlProfilerSettings, qmlProfilerGlobalSettings)
|
||||||
|
|
||||||
|
bool constraint(RunConfiguration *runConfiguration)
|
||||||
|
{
|
||||||
|
Target *target = runConfiguration ? runConfiguration->target() : nullptr;
|
||||||
|
Kit *kit = target ? target->kit() : nullptr;
|
||||||
|
return DeviceTypeKitAspect::deviceTypeId(kit)
|
||||||
|
== ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
class QmlProfilerRunWorkerFactory : public RunWorkerFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QmlProfilerRunWorkerFactory(QmlProfilerTool *tool)
|
||||||
|
{
|
||||||
|
addSupportedRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||||
|
setProducer([tool](RunControl *runControl) {
|
||||||
|
return new LocalQmlProfilerSupport(tool, runControl);
|
||||||
|
});
|
||||||
|
addConstraint(constraint);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class QmlProfilerPluginPrivate
|
class QmlProfilerPluginPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QmlProfilerTool m_profilerTool;
|
QmlProfilerTool m_profilerTool;
|
||||||
QmlProfilerOptionsPage m_profilerOptionsPage;
|
QmlProfilerOptionsPage m_profilerOptionsPage;
|
||||||
QmlProfilerActions m_actions;
|
QmlProfilerActions m_actions;
|
||||||
|
QmlProfilerRunWorkerFactory m_profilerWorkerFactory{&m_profilerTool};
|
||||||
};
|
};
|
||||||
|
|
||||||
bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString)
|
bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||||
@@ -102,13 +124,6 @@ void QmlProfilerPlugin::extensionsInitialized()
|
|||||||
|
|
||||||
RunConfiguration::registerAspect<QmlProfilerRunConfigurationAspect>();
|
RunConfiguration::registerAspect<QmlProfilerRunConfigurationAspect>();
|
||||||
|
|
||||||
auto constraint = [](RunConfiguration *runConfiguration) {
|
|
||||||
Target *target = runConfiguration ? runConfiguration->target() : nullptr;
|
|
||||||
Kit *kit = target ? target->kit() : nullptr;
|
|
||||||
return DeviceTypeKitAspect::deviceTypeId(kit)
|
|
||||||
== ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
|
|
||||||
};
|
|
||||||
|
|
||||||
RunControl::registerWorkerCreator(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE,
|
RunControl::registerWorkerCreator(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE,
|
||||||
[this](RunControl *runControl) {
|
[this](RunControl *runControl) {
|
||||||
auto runner = new QmlProfilerRunner(runControl);
|
auto runner = new QmlProfilerRunner(runControl);
|
||||||
@@ -116,11 +131,6 @@ void QmlProfilerPlugin::extensionsInitialized()
|
|||||||
&d->m_profilerTool, &QmlProfilerTool::finalizeRunControl);
|
&d->m_profilerTool, &QmlProfilerTool::finalizeRunControl);
|
||||||
return runner;
|
return runner;
|
||||||
});
|
});
|
||||||
|
|
||||||
RunControl::registerWorker(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE,
|
|
||||||
[this](ProjectExplorer::RunControl *runControl) {
|
|
||||||
return new LocalQmlProfilerSupport(&d->m_profilerTool, runControl);
|
|
||||||
}, constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtensionSystem::IPlugin::ShutdownFlag QmlProfilerPlugin::aboutToShutdown()
|
ExtensionSystem::IPlugin::ShutdownFlag QmlProfilerPlugin::aboutToShutdown()
|
||||||
|
Reference in New Issue
Block a user