From 9a78f717e4082a9f928db8afa5ee8ae01c33028f Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 27 Jul 2023 13:45:51 +0200 Subject: [PATCH] ProjectExplorer: Change signature to Project::toMap(QVariantMap &) More aspect-friendly. Change-Id: Ia107dbab65f3772b315d735e4c46f9dfe1043d5a Reviewed-by: Jarek Kobus --- src/plugins/nim/project/nimbleproject.cpp | 7 +++---- src/plugins/nim/project/nimbleproject.h | 2 +- src/plugins/nim/project/nimproject.cpp | 9 ++++----- src/plugins/projectexplorer/project.cpp | 12 ++++++------ src/plugins/projectexplorer/project.h | 2 +- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/plugins/nim/project/nimbleproject.cpp b/src/plugins/nim/project/nimbleproject.cpp index 5777724afbd..aeb16c8a8df 100644 --- a/src/plugins/nim/project/nimbleproject.cpp +++ b/src/plugins/nim/project/nimbleproject.cpp @@ -26,11 +26,10 @@ NimbleProject::NimbleProject(const Utils::FilePath &fileName) setBuildSystemCreator([] (Target *t) { return new NimbleBuildSystem(t); }); } -QVariantMap NimbleProject::toMap() const +void NimbleProject::toMap(QVariantMap &map) const { - QVariantMap result = Project::toMap(); - result[Constants::C_NIMPROJECT_EXCLUDEDFILES] = m_excludedFiles; - return result; + Project::toMap(map); + map[Constants::C_NIMPROJECT_EXCLUDEDFILES] = m_excludedFiles; } Project::RestoreResult NimbleProject::fromMap(const QVariantMap &map, QString *errorMessage) diff --git a/src/plugins/nim/project/nimbleproject.h b/src/plugins/nim/project/nimbleproject.h index 9abbc90dcc4..4a71514e898 100644 --- a/src/plugins/nim/project/nimbleproject.h +++ b/src/plugins/nim/project/nimbleproject.h @@ -16,7 +16,7 @@ public: NimbleProject(const Utils::FilePath &filename); // Keep for compatibility with Qt Creator 4.10 - QVariantMap toMap() const final; + void toMap(QVariantMap &map) const final; QStringList excludedFiles() const; void setExcludedFiles(const QStringList &excludedFiles); diff --git a/src/plugins/nim/project/nimproject.cpp b/src/plugins/nim/project/nimproject.cpp index 0e3240600f9..ed74cf43744 100644 --- a/src/plugins/nim/project/nimproject.cpp +++ b/src/plugins/nim/project/nimproject.cpp @@ -27,7 +27,7 @@ public: Tasks projectIssues(const Kit *k) const final; // Keep for compatibility with Qt Creator 4.10 - QVariantMap toMap() const final; + void toMap(QVariantMap &map) const final; QStringList excludedFiles() const; void setExcludedFiles(const QStringList &excludedFiles); @@ -63,11 +63,10 @@ Tasks NimProject::projectIssues(const Kit *k) const return result; } -QVariantMap NimProject::toMap() const +void NimProject::toMap(QVariantMap &map) const { - QVariantMap result = Project::toMap(); - result[Constants::C_NIMPROJECT_EXCLUDEDFILES] = m_excludedFiles; - return result; + Project::toMap(map); + map[Constants::C_NIMPROJECT_EXCLUDEDFILES] = m_excludedFiles; } Project::RestoreResult NimProject::fromMap(const QVariantMap &map, QString *errorMessage) diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp index d917672c6b9..c541d04773c 100644 --- a/src/plugins/projectexplorer/project.cpp +++ b/src/plugins/projectexplorer/project.cpp @@ -634,8 +634,11 @@ void Project::saveSettings() emit aboutToSaveSettings(); if (!d->m_accessor) d->m_accessor = std::make_unique(this); - if (!targets().isEmpty()) - d->m_accessor->saveSettings(toMap(), ICore::dialogParent()); + if (!targets().isEmpty()) { + QVariantMap map; + toMap(map); + d->m_accessor->saveSettings(map, ICore::dialogParent()); + } } Project::RestoreResult Project::restoreSettings(QString *errorMessage) @@ -688,11 +691,10 @@ FilePaths Project::files(const NodeMatcher &filter) const creating new build configurations. */ -QVariantMap Project::toMap() const +void Project::toMap(QVariantMap &map) const { const QList ts = targets(); - QVariantMap map; map.insert(QLatin1String(ACTIVE_TARGET_KEY), ts.indexOf(d->m_activeTarget)); map.insert(QLatin1String(TARGET_COUNT_KEY), ts.size()); for (int i = 0; i < ts.size(); ++i) @@ -701,8 +703,6 @@ QVariantMap Project::toMap() const map.insert(QLatin1String(EDITOR_SETTINGS_KEY), d->m_editorConfiguration.toMap()); if (!d->m_pluginSettings.isEmpty()) map.insert(QLatin1String(PLUGIN_SETTINGS_KEY), d->m_pluginSettings); - - return map; } /*! diff --git a/src/plugins/projectexplorer/project.h b/src/plugins/projectexplorer/project.h index 832fc3c9423..93c1611bb1e 100644 --- a/src/plugins/projectexplorer/project.h +++ b/src/plugins/projectexplorer/project.h @@ -111,7 +111,7 @@ public: const NodeMatcher &extraMatcher = {}) const; Utils::FilePaths binariesForSourceFile(const Utils::FilePath &sourceFile) const; - virtual QVariantMap toMap() const; + virtual void toMap(QVariantMap &map) const; Core::Context projectContext() const; Core::Context projectLanguages() const;