From e38c8724e468d283778ed538c3ecbb12607a05ed Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Wed, 14 Nov 2018 17:02:19 +0200 Subject: Git: Fix checking out a branch after adding it Fallout from a9ac438ad8e8aa710810133802636aa82f6c821f. Change-Id: I07b36dd1bc5e9fb63f7d4552d9cb6ccd7ea2e22d Reviewed-by: Tobias Hunger --- src/plugins/git/branchview.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/git/branchview.cpp b/src/plugins/git/branchview.cpp index 4e17f31686..4cabc58077 100644 --- a/src/plugins/git/branchview.cpp +++ b/src/plugins/git/branchview.cpp @@ -314,14 +314,16 @@ bool BranchView::add() branchAddDialog.setTrackedBranchName(isTag ? QString() : trackedBranch, !isLocal); if (branchAddDialog.exec() == QDialog::Accepted) { - QModelIndex idx = m_model->addBranch(branchAddDialog.branchName(), branchAddDialog.track(), trackedIndex); + QModelIndex idx = m_model->addBranch(branchAddDialog.branchName(), branchAddDialog.track(), + trackedIndex); if (!idx.isValid()) return false; + QModelIndex mappedIdx = m_filterModel->mapFromSource(idx); QTC_ASSERT(m_branchView, return false); - m_branchView->selectionModel()->select(idx, QItemSelectionModel::Clear + m_branchView->selectionModel()->select(mappedIdx, QItemSelectionModel::Clear | QItemSelectionModel::Select | QItemSelectionModel::Current); - m_branchView->scrollTo(idx); + m_branchView->scrollTo(mappedIdx); if (QMessageBox::question(this, tr("Checkout"), tr("Checkout branch?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { return checkout(); -- cgit v1.2.1