Fix possible crash in git branch dialog

Do not crash when checking out a branch while not currently
on any branch.

Task-number: QTCREATORBUG-5784
Change-Id: I5d007e91c1778e6f09a5d543990d948bc1427599
Reviewed-on: http://codereview.qt.nokia.com/2958
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Robert Löhning <robert.loehning@nokia.com>
This commit is contained in:
Tobias Hunger
2011-08-15 11:37:04 +00:00
parent 5c429665e4
commit bf4ca06c1e

View File

@@ -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 {