aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@nokia.com>2011-08-15 11:37:04 +0000
committerTobias Hunger <tobias.hunger@nokia.com>2011-08-15 15:01:13 +0200
commitbf4ca06c1e0342ea8115a77a4030c161785454c7 (patch)
treee9c4d7e84015701ffda93936cc521d43795b3200
parent5c429665e48b98ce424a15af7f7addf20ea843d9 (diff)
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>
-rw-r--r--src/plugins/git/branchmodel.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/plugins/git/branchmodel.cpp b/src/plugins/git/branchmodel.cpp
index 5d1712aeee..3b562c6816 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 {