From a741261f10bd9c5295d3e99736e49f31db43fa6f Mon Sep 17 00:00:00 2001
From: dt <qtc-committer@nokia.com>
Date: Mon, 30 Nov 2009 14:45:09 +0100
Subject: [PATCH] Fist set the display name then addBuildConfiguration on clone

---
 src/plugins/cmakeprojectmanager/cmakeproject.cpp            | 1 -
 src/plugins/genericprojectmanager/genericproject.cpp        | 1 -
 src/plugins/projectexplorer/buildconfiguration.h            | 2 +-
 src/plugins/projectexplorer/buildsettingspropertiespage.cpp | 1 +
 src/plugins/qt4projectmanager/qt4project.cpp                | 1 -
 5 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
index 45b78955d36..98258c13375 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
@@ -138,7 +138,6 @@ BuildConfiguration *CMakeBuildConfigurationFactory::clone(ProjectExplorer::Build
 {
     CMakeBuildConfiguration *old = static_cast<CMakeBuildConfiguration *>(source);
     CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(old);
-    m_project->addBuildConfiguration(bc);
     return bc;
 }
 
diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp
index 9f149855597..242e04c8c89 100644
--- a/src/plugins/genericprojectmanager/genericproject.cpp
+++ b/src/plugins/genericprojectmanager/genericproject.cpp
@@ -159,7 +159,6 @@ BuildConfiguration *GenericBuildConfigurationFactory::create(const QString &type
 BuildConfiguration *GenericBuildConfigurationFactory::clone(BuildConfiguration *source) const
 {
     GenericBuildConfiguration *bc = new GenericBuildConfiguration(static_cast<GenericBuildConfiguration *>(source));
-    m_project->addBuildConfiguration(bc);
     return bc;
 }
 
diff --git a/src/plugins/projectexplorer/buildconfiguration.h b/src/plugins/projectexplorer/buildconfiguration.h
index 216c1a24db6..49a4215493a 100644
--- a/src/plugins/projectexplorer/buildconfiguration.h
+++ b/src/plugins/projectexplorer/buildconfiguration.h
@@ -114,7 +114,7 @@ public:
     // project mode for editing
     virtual BuildConfiguration *create(const QString &type) const = 0;
 
-    // clones a given BuildConfiguration and adds it to the project
+    // clones a given BuildConfiguration, should not add it to the project
     virtual BuildConfiguration *clone(BuildConfiguration *source) const = 0;
 
     // restores a BuildConfiguration with the name and adds it to the project
diff --git a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp
index 12f8e13983f..3978b744a35 100644
--- a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp
+++ b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp
@@ -339,6 +339,7 @@ void BuildSettingsWidget::cloneConfiguration(BuildConfiguration *sourceConfigura
 
     m_buildConfiguration = m_project->buildConfigurationFactory()->clone(sourceConfiguration);
     m_buildConfiguration->setDisplayName(newDisplayName);
+    m_project->addBuildConfiguration(m_buildConfiguration);
 
     updateBuildSettings();
 }
diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp
index 9bfbc47e178..88d2afad297 100644
--- a/src/plugins/qt4projectmanager/qt4project.cpp
+++ b/src/plugins/qt4projectmanager/qt4project.cpp
@@ -298,7 +298,6 @@ BuildConfiguration *Qt4BuildConfigurationFactory::clone(BuildConfiguration *sour
 {
     Qt4BuildConfiguration *oldbc = static_cast<Qt4BuildConfiguration *>(source);
     Qt4BuildConfiguration *newbc = new Qt4BuildConfiguration(oldbc);
-    m_project->addBuildConfiguration(newbc);
     return newbc;
 }
 
-- 
GitLab