forked from qt-creator/qt-creator
Git: Fix crash when fetch is done while context menu is active
Blind shot. Task-number: QTCREATORBUG-29266 Change-Id: Ie9e8be9e6ead7a3c49cdde7c3b80b4735f7b19af Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
b3df9a4fcf
commit
5bd2cd0115
@@ -132,12 +132,15 @@ BranchView::BranchView()
|
|||||||
|
|
||||||
m_branchView->selectionModel()->clear();
|
m_branchView->selectionModel()->clear();
|
||||||
m_repository = GitPlugin::currentState().topLevel();
|
m_repository = GitPlugin::currentState().topLevel();
|
||||||
refreshCurrentRepository();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BranchView::refreshIfSame(const FilePath &repository)
|
void BranchView::refreshIfSame(const FilePath &repository)
|
||||||
{
|
{
|
||||||
if (m_repository == repository)
|
if (m_repository != repository)
|
||||||
|
return;
|
||||||
|
if (m_blockRefresh)
|
||||||
|
m_postponedRefresh = true;
|
||||||
|
else
|
||||||
refreshCurrentRepository();
|
refreshCurrentRepository();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,6 +231,7 @@ void BranchView::slotCustomContextMenu(const QPoint &point)
|
|||||||
std::unique_ptr<TaskTree> taskTree;
|
std::unique_ptr<TaskTree> taskTree;
|
||||||
QAction *mergeAction = nullptr;
|
QAction *mergeAction = nullptr;
|
||||||
|
|
||||||
|
SetInContext block(m_blockRefresh);
|
||||||
QMenu contextMenu;
|
QMenu contextMenu;
|
||||||
contextMenu.addAction(Tr::tr("&Add..."), this, &BranchView::add);
|
contextMenu.addAction(Tr::tr("&Add..."), this, &BranchView::add);
|
||||||
const std::optional<QString> remote = m_model->remoteName(index);
|
const std::optional<QString> remote = m_model->remoteName(index);
|
||||||
@@ -256,10 +260,8 @@ void BranchView::slotCustomContextMenu(const QPoint &point)
|
|||||||
contextMenu.addSeparator();
|
contextMenu.addSeparator();
|
||||||
contextMenu.addAction(Tr::tr("&Diff"), this, [this] {
|
contextMenu.addAction(Tr::tr("&Diff"), this, [this] {
|
||||||
const QString fullName = m_model->fullName(selectedIndex(), true);
|
const QString fullName = m_model->fullName(selectedIndex(), true);
|
||||||
if (!fullName.isEmpty()) {
|
if (!fullName.isEmpty())
|
||||||
SetInContext block(m_blockRefresh);
|
|
||||||
GitClient::instance()->diffBranch(m_repository, fullName);
|
GitClient::instance()->diffBranch(m_repository, fullName);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
contextMenu.addAction(Tr::tr("&Log"), this, [this] { log(selectedIndex()); });
|
contextMenu.addAction(Tr::tr("&Log"), this, [this] { log(selectedIndex()); });
|
||||||
contextMenu.addAction(Tr::tr("Reflo&g"), this, [this] { reflog(selectedIndex()); });
|
contextMenu.addAction(Tr::tr("Reflo&g"), this, [this] { reflog(selectedIndex()); });
|
||||||
@@ -303,6 +305,10 @@ void BranchView::slotCustomContextMenu(const QPoint &point)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
contextMenu.exec(m_branchView->viewport()->mapToGlobal(point));
|
contextMenu.exec(m_branchView->viewport()->mapToGlobal(point));
|
||||||
|
if (m_postponedRefresh) {
|
||||||
|
refreshCurrentRepository();
|
||||||
|
m_postponedRefresh = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BranchView::expandAndResize()
|
void BranchView::expandAndResize()
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ private:
|
|||||||
BranchFilterModel *m_filterModel = nullptr;
|
BranchFilterModel *m_filterModel = nullptr;
|
||||||
Utils::FilePath m_repository;
|
Utils::FilePath m_repository;
|
||||||
bool m_blockRefresh = false;
|
bool m_blockRefresh = false;
|
||||||
|
bool m_postponedRefresh = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BranchViewFactory : public Core::INavigationWidgetFactory
|
class BranchViewFactory : public Core::INavigationWidgetFactory
|
||||||
|
|||||||
Reference in New Issue
Block a user