forked from qt-creator/qt-creator
ProjectExplorer: Re-work setup runworker factories
This combines two of the previous three paths to create run workers, and refers to RunConfigurations by id, not by type where possible to decrease coupling between the classes. Only allow "type of run configuration" and "type of device" as the only possible kind of restriction and require a uniform RunWorker constructor signature. Adapt user code to fit that pattern. Change-Id: I5a6d49c9a144785fd0235d7586f244b56f67b366 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -80,34 +80,18 @@ 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};
|
||||
RunWorkerFactory m_profilerWorkerFactory{
|
||||
RunWorkerFactory::make<LocalQmlProfilerSupport>(),
|
||||
{ProjectExplorer::Constants::QML_PROFILER_RUN_MODE},
|
||||
{},
|
||||
{ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE}
|
||||
};
|
||||
};
|
||||
|
||||
bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||
|
||||
Reference in New Issue
Block a user