From d1aaa4589e62172e767453850a43a12c3ad59758 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 16 Jul 2012 18:40:25 +0200 Subject: [PATCH] projectexplorer: fix crash on removing last profile Change-Id: I1ad59e4cba107d6c0cd7f777648d6d2aba483b6c Reviewed-by: Daniel Teske --- src/plugins/projectexplorer/profilemodel.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/plugins/projectexplorer/profilemodel.cpp b/src/plugins/projectexplorer/profilemodel.cpp index 9802d4b5553..8c34f04cfee 100644 --- a/src/plugins/projectexplorer/profilemodel.cpp +++ b/src/plugins/projectexplorer/profilemodel.cpp @@ -364,6 +364,15 @@ void ProfileModel::markForRemoval(Profile *p) if (!node) 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)); m_manualRoot->childNodes.removeOne(node); node->parent = 0; @@ -376,15 +385,6 @@ void ProfileModel::markForRemoval(Profile *p) m_toRemoveList.append(node); } 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)