ProjectExplorer: Consolidate RunConfigurationFactory::ids

It was already only one id string with two names. Since it is not
an id for the factory but the id of the created run configuration,
settle of  runConfigurationId() as accessor.

The factory and id fields in RunConfigurationCreationInfo were
redundant. factory always implies (runconfiguration)id (but not
necessarily the other way round, in theory different factories
are possible for the same runconfiguration type for different
devices). So drop the id field here.

In one case now factory pointers instead of ids are compared, but
this is neutral there as this happens in a context of a fixed Target,
device and project are fixed there, so id and factory are equally
unique.

Change-Id: I859aa91486a2dd4abfc7369540a3322d6ec6260d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2020-06-12 07:50:52 +02:00
parent fcef4709bb
commit beee392dd8
17 changed files with 42 additions and 44 deletions

View File

@@ -120,22 +120,22 @@ public:
RunWorkerFactory runWorkerFactory{ RunWorkerFactory runWorkerFactory{
RunWorkerFactory::make<AndroidRunSupport>(), RunWorkerFactory::make<AndroidRunSupport>(),
{NORMAL_RUN_MODE}, {NORMAL_RUN_MODE},
{runConfigFactory.id()} {runConfigFactory.runConfigurationId()}
}; };
RunWorkerFactory debugWorkerFactory{ RunWorkerFactory debugWorkerFactory{
RunWorkerFactory::make<AndroidDebugSupport>(), RunWorkerFactory::make<AndroidDebugSupport>(),
{DEBUG_RUN_MODE}, {DEBUG_RUN_MODE},
{runConfigFactory.id()} {runConfigFactory.runConfigurationId()}
}; };
RunWorkerFactory profilerWorkerFactory{ RunWorkerFactory profilerWorkerFactory{
RunWorkerFactory::make<AndroidQmlToolingSupport>(), RunWorkerFactory::make<AndroidQmlToolingSupport>(),
{QML_PROFILER_RUN_MODE}, {QML_PROFILER_RUN_MODE},
{runConfigFactory.id()} {runConfigFactory.runConfigurationId()}
}; };
RunWorkerFactory qmlPreviewWorkerFactory{ RunWorkerFactory qmlPreviewWorkerFactory{
RunWorkerFactory::make<AndroidQmlToolingSupport>(), RunWorkerFactory::make<AndroidQmlToolingSupport>(),
{QML_PREVIEW_RUN_MODE}, {QML_PREVIEW_RUN_MODE},
{runConfigFactory.id()} {runConfigFactory.runConfigurationId()}
}; };
RunWorkerFactory qmlPreviewWorkerFactory2{ RunWorkerFactory qmlPreviewWorkerFactory2{
RunWorkerFactory::make<AndroidQmlPreviewWorker>(), RunWorkerFactory::make<AndroidQmlPreviewWorker>(),

View File

@@ -82,7 +82,8 @@ public:
RunWorkerFactory runWorkerFactory{ RunWorkerFactory runWorkerFactory{
RunWorkerFactory::make<BareMetalDebugSupport>(), RunWorkerFactory::make<BareMetalDebugSupport>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE, ProjectExplorer::Constants::DEBUG_RUN_MODE}, {ProjectExplorer::Constants::NORMAL_RUN_MODE, ProjectExplorer::Constants::DEBUG_RUN_MODE},
{runConfigurationFactory.id(), customRunConfigurationFactory.id()} {runConfigurationFactory.runConfigurationId(),
customRunConfigurationFactory.runConfigurationId()}
}; };
}; };

View File

@@ -184,7 +184,7 @@ public:
m_makeInstallStepFactory{RemoteLinux::Constants::MakeInstallStepId}; m_makeInstallStepFactory{RemoteLinux::Constants::MakeInstallStepId};
const QList<Core::Id> supportedRunConfigs { const QList<Core::Id> supportedRunConfigs {
m_runConfigFactory.id(), m_runConfigFactory.runConfigurationId(),
"QmlProjectManager.QmlRunConfiguration" "QmlProjectManager.QmlRunConfiguration"
}; };

View File

@@ -85,17 +85,17 @@ public:
RunWorkerFactory runWorkerFactory{ RunWorkerFactory runWorkerFactory{
RunWorkerFactory::make<IosRunSupport>(), RunWorkerFactory::make<IosRunSupport>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE}, {ProjectExplorer::Constants::NORMAL_RUN_MODE},
{runConfigurationFactory.id()} {runConfigurationFactory.runConfigurationId()}
}; };
RunWorkerFactory debugWorkerFactory{ RunWorkerFactory debugWorkerFactory{
RunWorkerFactory::make<IosDebugSupport>(), RunWorkerFactory::make<IosDebugSupport>(),
{ProjectExplorer::Constants::DEBUG_RUN_MODE}, {ProjectExplorer::Constants::DEBUG_RUN_MODE},
{runConfigurationFactory.id()} {runConfigurationFactory.runConfigurationId()}
}; };
RunWorkerFactory qmlProfilerWorkerFactory{ RunWorkerFactory qmlProfilerWorkerFactory{
RunWorkerFactory::make<IosQmlProfilerSupport>(), RunWorkerFactory::make<IosQmlProfilerSupport>(),
{ProjectExplorer::Constants::QML_PROFILER_RUN_MODE}, {ProjectExplorer::Constants::QML_PROFILER_RUN_MODE},
{runConfigurationFactory.id()} {runConfigurationFactory.runConfigurationId()}
}; };
}; };

View File

@@ -88,7 +88,7 @@ private:
RunWorkerFactory RunWorkerFactory
m_mesonRunWorkerFactory{RunWorkerFactory::make<ProjectExplorer::SimpleTargetRunner>(), m_mesonRunWorkerFactory{RunWorkerFactory::make<ProjectExplorer::SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE}, {ProjectExplorer::Constants::NORMAL_RUN_MODE},
{m_runConfigurationFactory.id()}}; {m_runConfigurationFactory.runConfigurationId()}};
void saveAll() void saveAll()
{ {
m_toolsSettings.saveMesonTools(MesonTools::tools(), ICore::dialogParent()); m_toolsSettings.saveMesonTools(MesonTools::tools(), ICore::dialogParent());

View File

@@ -78,17 +78,17 @@ public:
RunWorkerFactory nimRunWorkerFactory { RunWorkerFactory nimRunWorkerFactory {
RunWorkerFactory::make<SimpleTargetRunner>(), RunWorkerFactory::make<SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE}, {ProjectExplorer::Constants::NORMAL_RUN_MODE},
{nimRunConfigFactory.id()} {nimRunConfigFactory.runConfigurationId()}
}; };
RunWorkerFactory nimbleRunWorkerFactory { RunWorkerFactory nimbleRunWorkerFactory {
RunWorkerFactory::make<SimpleTargetRunner>(), RunWorkerFactory::make<SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE}, {ProjectExplorer::Constants::NORMAL_RUN_MODE},
{nimbleRunConfigFactory.id()} {nimbleRunConfigFactory.runConfigurationId()}
}; };
RunWorkerFactory nimbleTestWorkerFactory { RunWorkerFactory nimbleTestWorkerFactory {
RunWorkerFactory::make<SimpleTargetRunner>(), RunWorkerFactory::make<SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE}, {ProjectExplorer::Constants::NORMAL_RUN_MODE},
{nimbleTestConfigFactory.id()} {nimbleTestConfigFactory.runConfigurationId()}
}; };
NimbleBuildStepFactory nimbleBuildStepFactory; NimbleBuildStepFactory nimbleBuildStepFactory;
NimbleTaskStepFactory nimbleTaskStepFactory; NimbleTaskStepFactory nimbleTaskStepFactory;

View File

@@ -184,7 +184,7 @@ void AddRunConfigDialog::accept()
const TreeItem * const item = model->itemForIndex(proxyModel->mapToSource(selected.first())); const TreeItem * const item = model->itemForIndex(proxyModel->mapToSource(selected.first()));
QTC_ASSERT(item, return); QTC_ASSERT(item, return);
m_creationInfo = static_cast<const CandidateTreeItem *>(item)->creationInfo(); m_creationInfo = static_cast<const CandidateTreeItem *>(item)->creationInfo();
QTC_ASSERT(m_creationInfo.id.isValid(), return); QTC_ASSERT(m_creationInfo.factory, return);
QDialog::accept(); QDialog::accept();
} }

View File

@@ -624,7 +624,7 @@ public:
RunWorkerFactory m_customExecutableRunWorkerFactory{ RunWorkerFactory m_customExecutableRunWorkerFactory{
RunWorkerFactory::make<SimpleTargetRunner>(), RunWorkerFactory::make<SimpleTargetRunner>(),
{Constants::NORMAL_RUN_MODE}, {Constants::NORMAL_RUN_MODE},
{m_customExecutableRunConfigFactory.id()} {m_customExecutableRunConfigFactory.runConfigurationId()}
}; };
ProjectFileWizardExtension m_projectFileWizardExtension; ProjectFileWizardExtension m_projectFileWizardExtension;
@@ -657,7 +657,9 @@ public:
RunWorkerFactory desktopRunWorkerFactory{ RunWorkerFactory desktopRunWorkerFactory{
RunWorkerFactory::make<SimpleTargetRunner>(), RunWorkerFactory::make<SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE}, {ProjectExplorer::Constants::NORMAL_RUN_MODE},
{qmakeRunConfigFactory.id(), qbsRunConfigFactory.id(), cmakeRunConfigFactory.id()} {qmakeRunConfigFactory.runConfigurationId(),
qbsRunConfigFactory.runConfigurationId(),
cmakeRunConfigFactory.runConfigurationId()}
}; };
}; };

View File

@@ -458,7 +458,6 @@ RunConfigurationFactory::availableCreators(Target *target) const
displayName = decoratedTargetName(displayName, target); displayName = decoratedTargetName(displayName, target);
RunConfigurationCreationInfo rci; RunConfigurationCreationInfo rci;
rci.factory = this; rci.factory = this;
rci.id = m_runConfigBaseId;
rci.buildKey = ti.buildKey; rci.buildKey = ti.buildKey;
rci.projectFilePath = ti.projectFilePath; rci.projectFilePath = ti.projectFilePath;
rci.displayName = displayName; rci.displayName = displayName;
@@ -532,7 +531,6 @@ RunConfiguration *RunConfigurationFactory::create(Target *target) const
RunConfiguration *RunConfigurationCreationInfo::create(Target *target) const RunConfiguration *RunConfigurationCreationInfo::create(Target *target) const
{ {
QTC_ASSERT(factory->canHandle(target), return nullptr); QTC_ASSERT(factory->canHandle(target), return nullptr);
QTC_ASSERT(id == factory->runConfigurationBaseId(), return nullptr);
RunConfiguration *rc = factory->create(target); RunConfiguration *rc = factory->create(target);
if (!rc) if (!rc)
@@ -550,7 +548,7 @@ RunConfiguration *RunConfigurationFactory::restore(Target *parent, const QVarian
for (RunConfigurationFactory *factory : g_runConfigurationFactories) { for (RunConfigurationFactory *factory : g_runConfigurationFactories) {
if (factory->canHandle(parent)) { if (factory->canHandle(parent)) {
const Core::Id id = idFromMap(map); const Core::Id id = idFromMap(map);
if (id.name().startsWith(factory->m_runConfigBaseId.name())) { if (id.name().startsWith(factory->m_runConfigurationId.name())) {
RunConfiguration *rc = factory->create(parent); RunConfiguration *rc = factory->create(parent);
if (rc->fromMap(map)) { if (rc->fromMap(map)) {
rc->update(); rc->update();
@@ -601,7 +599,6 @@ FixedRunConfigurationFactory::availableCreators(Target *parent) const
: m_fixedBuildTarget; : m_fixedBuildTarget;
RunConfigurationCreationInfo rci; RunConfigurationCreationInfo rci;
rci.factory = this; rci.factory = this;
rci.id = runConfigurationBaseId();
rci.displayName = displayName; rci.displayName = displayName;
return {rci}; return {rci};
} }

View File

@@ -207,7 +207,6 @@ public:
RunConfiguration *create(Target *target) const; RunConfiguration *create(Target *target) const;
const RunConfigurationFactory *factory = nullptr; const RunConfigurationFactory *factory = nullptr;
Core::Id id;
QString buildKey; QString buildKey;
QString displayName; QString displayName;
QString displayNameUniquifier; QString displayNameUniquifier;
@@ -228,8 +227,7 @@ public:
static RunConfiguration *clone(Target *parent, RunConfiguration *source); static RunConfiguration *clone(Target *parent, RunConfiguration *source);
static const QList<RunConfigurationCreationInfo> creatorsForTarget(Target *parent); static const QList<RunConfigurationCreationInfo> creatorsForTarget(Target *parent);
Core::Id id() const { return m_runConfigBaseId; } Core::Id runConfigurationId() const { return m_runConfigurationId; }
Core::Id runConfigurationBaseId() const { return m_runConfigBaseId; }
static QString decoratedTargetName(const QString &targetName, Target *kit); static QString decoratedTargetName(const QString &targetName, Target *kit);
@@ -239,16 +237,16 @@ protected:
using RunConfigurationCreator = std::function<RunConfiguration *(Target *)>; using RunConfigurationCreator = std::function<RunConfiguration *(Target *)>;
template <class RunConfig> template <class RunConfig>
void registerRunConfiguration(Core::Id runConfigBaseId) void registerRunConfiguration(Core::Id runConfigurationId)
{ {
m_creator = [runConfigBaseId](Target *t) -> RunConfiguration * { m_creator = [runConfigurationId](Target *t) -> RunConfiguration * {
return new RunConfig(t, runConfigBaseId); return new RunConfig(t, runConfigurationId);
}; };
m_runConfigBaseId = runConfigBaseId; m_runConfigurationId = runConfigurationId;
} }
void addSupportedProjectType(Core::Id id); void addSupportedProjectType(Core::Id projectTypeId);
void addSupportedTargetDeviceType(Core::Id id); void addSupportedTargetDeviceType(Core::Id deviceTypeId);
void setDecorateDisplayNames(bool on); void setDecorateDisplayNames(bool on);
private: private:
@@ -257,7 +255,7 @@ private:
friend class RunConfigurationCreationInfo; friend class RunConfigurationCreationInfo;
RunConfigurationCreator m_creator; RunConfigurationCreator m_creator;
Core::Id m_runConfigBaseId; Core::Id m_runConfigurationId;
QList<Core::Id> m_supportedProjectTypes; QList<Core::Id> m_supportedProjectTypes;
QList<Core::Id> m_supportedTargetDeviceTypes; QList<Core::Id> m_supportedTargetDeviceTypes;
bool m_decorateDisplayNames = false; bool m_decorateDisplayNames = false;

View File

@@ -201,11 +201,11 @@ void RunSettingsWidget::showAddRunConfigDialog()
if (dlg.exec() != QDialog::Accepted) if (dlg.exec() != QDialog::Accepted)
return; return;
RunConfigurationCreationInfo rci = dlg.creationInfo(); RunConfigurationCreationInfo rci = dlg.creationInfo();
QTC_ASSERT(rci.id.isValid(), return); QTC_ASSERT(rci.factory, return);
RunConfiguration *newRC = rci.create(m_target); RunConfiguration *newRC = rci.create(m_target);
if (!newRC) if (!newRC)
return; return;
QTC_CHECK(newRC->id() == rci.id); QTC_CHECK(newRC->id() == rci.factory->runConfigurationId());
m_target->addRunConfiguration(newRC); m_target->addRunConfiguration(newRC);
m_target->setActiveRunConfiguration(newRC); m_target->setActiveRunConfiguration(newRC);
m_removeRunToolButton->setEnabled(m_target->runConfigurations().size() > 1); m_removeRunToolButton->setEnabled(m_target->runConfigurations().size() > 1);

View File

@@ -625,7 +625,7 @@ void Target::updateDefaultRunConfigurations()
bool present = false; bool present = false;
for (const RunConfigurationCreationInfo &item : creators) { for (const RunConfigurationCreationInfo &item : creators) {
QString buildKey = rc->buildKey(); QString buildKey = rc->buildKey();
if (item.id == rc->id() && item.buildKey == buildKey) { if (item.factory->runConfigurationId() == rc->id() && item.buildKey == buildKey) {
existing.append(item); existing.append(item);
present = true; present = true;
} }
@@ -643,7 +643,7 @@ void Target::updateDefaultRunConfigurations()
continue; continue;
bool exists = false; bool exists = false;
for (const RunConfigurationCreationInfo &ex : existing) { for (const RunConfigurationCreationInfo &ex : existing) {
if (ex.id == item.id && ex.buildKey == item.buildKey) if (ex.factory == item.factory && ex.buildKey == item.buildKey)
exists = true; exists = true;
} }
if (exists) if (exists)
@@ -652,7 +652,7 @@ void Target::updateDefaultRunConfigurations()
RunConfiguration *rc = item.create(this); RunConfiguration *rc = item.create(this);
if (!rc) if (!rc)
continue; continue;
QTC_CHECK(rc->id() == item.id); QTC_CHECK(rc->id() == item.factory->runConfigurationId());
if (!rc->isConfigured()) if (!rc->isConfigured())
newUnconfigured << rc; newUnconfigured << rc;
else else

View File

@@ -64,7 +64,7 @@ public:
RunWorkerFactory runWorkerFactory{ RunWorkerFactory runWorkerFactory{
RunWorkerFactory::make<SimpleTargetRunner>(), RunWorkerFactory::make<SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE}, {ProjectExplorer::Constants::NORMAL_RUN_MODE},
{runConfigFactory.id()} {runConfigFactory.runConfigurationId()}
}; };
}; };

View File

@@ -47,7 +47,7 @@ public:
RunWorkerFactory runWorkerFactory{ RunWorkerFactory runWorkerFactory{
RunWorkerFactory::make<SimpleTargetRunner>(), RunWorkerFactory::make<SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE}, {ProjectExplorer::Constants::NORMAL_RUN_MODE},
{runConfigFactory.id()} {runConfigFactory.runConfigurationId()}
}; };
}; };

View File

@@ -132,17 +132,17 @@ public:
RunWorkerFactory runWorkerFactory{ RunWorkerFactory runWorkerFactory{
RunWorkerFactory::make<SimpleTargetRunner>(), RunWorkerFactory::make<SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE}, {ProjectExplorer::Constants::NORMAL_RUN_MODE},
{runConfigFactory.id()} {runConfigFactory.runConfigurationId()}
}; };
RunWorkerFactory debugWorkerFactory{ RunWorkerFactory debugWorkerFactory{
RunWorkerFactory::make<QnxDebugSupport>(), RunWorkerFactory::make<QnxDebugSupport>(),
{ProjectExplorer::Constants::DEBUG_RUN_MODE}, {ProjectExplorer::Constants::DEBUG_RUN_MODE},
{runConfigFactory.id()} {runConfigFactory.runConfigurationId()}
}; };
RunWorkerFactory qmlProfilerWorkerFactory{ RunWorkerFactory qmlProfilerWorkerFactory{
RunWorkerFactory::make<QnxQmlProfilerSupport>(), RunWorkerFactory::make<QnxQmlProfilerSupport>(),
{}, // FIXME: Shouldn't this use the run mode id somehow? {}, // FIXME: Shouldn't this use the run mode id somehow?
{runConfigFactory.id()} {runConfigFactory.runConfigurationId()}
}; };
}; };

View File

@@ -83,8 +83,8 @@ public:
GenericDeployStepFactory<MakeInstallStep> makeInstallStepFactory; GenericDeployStepFactory<MakeInstallStep> makeInstallStepFactory;
const QList<Core::Id> supportedRunConfigs { const QList<Core::Id> supportedRunConfigs {
runConfigurationFactory.id(), runConfigurationFactory.runConfigurationId(),
customRunConfigurationFactory.id(), customRunConfigurationFactory.runConfigurationId(),
"QmlProjectManager.QmlRunConfiguration" "QmlProjectManager.QmlRunConfiguration"
}; };

View File

@@ -62,13 +62,13 @@ public:
RunWorkerFactory runWorkerFactory{ RunWorkerFactory runWorkerFactory{
RunWorkerFactory::make<WinRtRunner>(), RunWorkerFactory::make<WinRtRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE}, {ProjectExplorer::Constants::NORMAL_RUN_MODE},
{runConfigFactory.id()} {runConfigFactory.runConfigurationId()}
}; };
RunWorkerFactory debugWorkerFactory{ RunWorkerFactory debugWorkerFactory{
RunWorkerFactory::make<WinRtDebugSupport>(), RunWorkerFactory::make<WinRtDebugSupport>(),
{ProjectExplorer::Constants::DEBUG_RUN_MODE}, {ProjectExplorer::Constants::DEBUG_RUN_MODE},
{runConfigFactory.id()}, {runConfigFactory.runConfigurationId()},
{Internal::Constants::WINRT_DEVICE_TYPE_LOCAL} {Internal::Constants::WINRT_DEVICE_TYPE_LOCAL}
}; };
}; };