diff --git a/src/plugins/git/branchmodel.cpp b/src/plugins/git/branchmodel.cpp index 5d1712aeee61372495cf2bffe3135e138b31bbb1..3b562c6816e166d270205d7dc1a64844ca3ce745 100644 --- a/src/plugins/git/branchmodel.cpp +++ b/src/plugins/git/branchmodel.cpp @@ -448,8 +448,11 @@ void BranchModel::checkoutBranch(const QModelIndex &idx) } if (m_client->synchronousCheckoutBranch(m_workingDirectory, branch, &errorMessage)) { if (errorMessage.isEmpty()) { - static_cast<BranchNode *>(currentBranch().internalPointer())->current = false; - emit dataChanged(currentBranch(), currentBranch()); + QModelIndex currentIdx = currentBranch(); + if (currentIdx.isValid()) { + static_cast<BranchNode *>(currentIdx.internalPointer())->current = false; + emit dataChanged(currentBranch(), currentBranch()); + } static_cast<BranchNode *>(idx.internalPointer())->current = true; emit dataChanged(idx, idx); } else {