Commit a3141e9d authored by dt's avatar dt
Browse files

Fix crash on cloning and removing buildconfigurations

parent 22ab8d56
......@@ -306,13 +306,18 @@ void BuildSettingsWidget::cloneConfiguration(const QString &sourceConfiguration)
return;
QString newDisplayName = newBuildConfiguration;
// Check that the internal name is not taken and use a different one otherwise
if (m_project->buildConfiguration(newBuildConfiguration)) {
int i = 2;
while (m_project->buildConfiguration(newBuildConfiguration + QString::number(i)))
++i;
newBuildConfiguration += QString::number(i);
}
QStringList buildConfigurationDisplayNames;
foreach(BuildConfiguration *bc, m_project->buildConfigurations())
buildConfigurationDisplayNames << bc->displayName();
newDisplayName = Project::makeUnique(newDisplayName, buildConfigurationDisplayNames);
QStringList buildConfigurationNames;
foreach(BuildConfiguration *bc, m_project->buildConfigurations())
buildConfigurationNames << bc->name();
newBuildConfiguration = Project::makeUnique(newBuildConfiguration, buildConfigurationNames);
qDebug()<<"BuildSettingsWidget::cloneConfiguration source:"<<sourceConfiguration<<"to: "<<newBuildConfiguration;
m_project->copyBuildConfiguration(sourceConfiguration, newBuildConfiguration);
m_project->setDisplayNameFor(m_project->buildConfiguration(newBuildConfiguration), newDisplayName);
......
......@@ -150,15 +150,10 @@ void Project::addBuildConfiguration(BuildConfiguration *configuration)
void Project::removeBuildConfiguration(BuildConfiguration *configuration)
{
//todo: this might be error prone
if (!buildConfigurations().contains(configuration))
if (!m_buildConfigurationValues.contains(configuration))
return;
for (int i = 0; i != m_buildConfigurationValues.size(); ++i)
if (m_buildConfigurationValues.at(i)->name() == configuration->name()) {
delete m_buildConfigurationValues.at(i);
m_buildConfigurationValues.removeAt(i);
break;
}
m_buildConfigurationValues.removeOne(configuration);
for (int i = 0; i != m_buildSteps.size(); ++i)
m_buildSteps.at(i)->removeBuildConfiguration(configuration->name());
......@@ -166,6 +161,7 @@ void Project::removeBuildConfiguration(BuildConfiguration *configuration)
m_cleanSteps.at(i)->removeBuildConfiguration(configuration->name());
emit removedBuildConfiguration(this, configuration->name());
delete configuration;
}
void Project::copyBuildConfiguration(const QString &source, const QString &dest)
......
......@@ -141,6 +141,7 @@ public:
virtual QStringList includePaths(const QString &fileName) const;
virtual QStringList frameworkPaths(const QString &fileName) const;
static QString makeUnique(const QString &preferedName, const QStringList &usedNames);
signals:
void fileListChanged();
......@@ -183,7 +184,6 @@ protected:
virtual bool restoreSettingsImpl(PersistentSettingsReader &reader);
private:
static QString makeUnique(const QString &preferedName, const QStringList &usedNames);
QList<BuildStep *> m_buildSteps;
QList<BuildStep *> m_cleanSteps;
QMap<QString, QVariant> m_values;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment