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:
@@ -80,12 +80,34 @@ namespace Internal {
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
QmlProfilerTool m_profilerTool;
|
||||
QmlProfilerOptionsPage m_profilerOptionsPage;
|
||||
QmlProfilerActions m_actions;
|
||||
QmlProfilerRunWorkerFactory m_profilerWorkerFactory{&m_profilerTool};
|
||||
};
|
||||
|
||||
bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||
@@ -102,13 +124,6 @@ void QmlProfilerPlugin::extensionsInitialized()
|
||||
|
||||
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,
|
||||
[this](RunControl *runControl) {
|
||||
auto runner = new QmlProfilerRunner(runControl);
|
||||
@@ -116,11 +131,6 @@ void QmlProfilerPlugin::extensionsInitialized()
|
||||
&d->m_profilerTool, &QmlProfilerTool::finalizeRunControl);
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user