Skip to content
Snippets Groups Projects
Commit 18906fac authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

Git: Protect against removal of the "Local Branches" node


... When a single local branch is being removed

Change-Id: I4321d045ebb6faaf5f864ff33cb4f34c15d2264b
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent d2cad7d1
No related branches found
No related tags found
No related merge requests found
......@@ -692,14 +692,18 @@ QModelIndex BranchModel::nodeToIndex(BranchNode *node) const
void BranchModel::removeNode(const QModelIndex &idx)
{
QModelIndex tmp = idx; // tmp is a leaf, so count must be 0.
while (indexToNode(tmp)->count() == 0) {
QModelIndex tmpParent = parent(tmp);
beginRemoveRows(tmpParent, tmp.row(), tmp.row());
indexToNode(tmpParent)->children.removeAt(tmp.row());
delete indexToNode(tmp);
QModelIndex nodeIndex = idx; // idx is a leaf, so count must be 0.
BranchNode *node = indexToNode(nodeIndex);
while (node->count() == 0 && node->parent != m_rootNode) {
BranchNode *parentNode = node->parent;
const QModelIndex parentIndex = nodeToIndex(parentNode);
const int nodeRow = nodeIndex.row();
beginRemoveRows(parentIndex, nodeRow, nodeRow);
parentNode->children.removeAt(nodeRow);
delete node;
endRemoveRows();
tmp = tmpParent;
node = parentNode;
nodeIndex = parentIndex;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment