projectexplorer: fix crash on removing last profile

Change-Id: I1ad59e4cba107d6c0cd7f777648d6d2aba483b6c
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
hjk
2012-07-16 18:40:25 +02:00
committed by Daniel Teske
parent a5fb852b7c
commit d1aaa4589e

View File

@@ -364,6 +364,15 @@ void ProfileModel::markForRemoval(Profile *p)
if (!node) if (!node)
return; return;
if (node == m_defaultNode) {
ProfileNode *newDefault = 0;
if (!m_autoRoot->childNodes.isEmpty())
newDefault = m_autoRoot->childNodes.at(0);
else if (!m_manualRoot->childNodes.isEmpty())
newDefault = m_manualRoot->childNodes.at(0);
setDefaultNode(newDefault);
}
beginRemoveRows(index(m_manualRoot), m_manualRoot->childNodes.indexOf(node), m_manualRoot->childNodes.indexOf(node)); beginRemoveRows(index(m_manualRoot), m_manualRoot->childNodes.indexOf(node), m_manualRoot->childNodes.indexOf(node));
m_manualRoot->childNodes.removeOne(node); m_manualRoot->childNodes.removeOne(node);
node->parent = 0; node->parent = 0;
@@ -376,15 +385,6 @@ void ProfileModel::markForRemoval(Profile *p)
m_toRemoveList.append(node); m_toRemoveList.append(node);
} }
endRemoveRows(); endRemoveRows();
if (node == m_defaultNode) {
ProfileNode *newDefault = 0;
if (!m_autoRoot->childNodes.isEmpty())
newDefault = m_autoRoot->childNodes.at(0);
else if (!m_manualRoot->childNodes.isEmpty())
newDefault = m_manualRoot->childNodes.at(0);
setDefaultNode(newDefault);
}
} }
void ProfileModel::markForAddition(Profile *p) void ProfileModel::markForAddition(Profile *p)