Git: Fix crash when menu is closed before fast-forward check result

Fixes: QTCREATORBUG-28958
Change-Id: Ic3bfde2f355fdb3d44b0614e9ba176ff550d97c8
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Orgad Shaneh
2023-03-28 10:32:50 +03:00
committed by Orgad Shaneh
parent 143dedf2f5
commit 0f3f5fb4d8

View File

@@ -224,6 +224,7 @@ void BranchView::slotCustomContextMenu(const QPoint &point)
const bool hasActions = m_model->isLeaf(index);
const bool currentLocal = m_model->isLocal(currentBranch);
std::unique_ptr<TaskTree> taskTree;
QAction *mergeAction = nullptr;
QMenu contextMenu;
contextMenu.addAction(Tr::tr("&Add..."), this, &BranchView::add);
@@ -267,10 +268,10 @@ void BranchView::slotCustomContextMenu(const QPoint &point)
resetMenu->addAction(Tr::tr("&Mixed"), this, [this] { reset("mixed"); });
resetMenu->addAction(Tr::tr("&Soft"), this, [this] { reset("soft"); });
contextMenu.addMenu(resetMenu);
QAction *mergeAction = contextMenu.addAction(Tr::tr("&Merge \"%1\" into \"%2\"")
.arg(indexName, currentName),
this,
[this] { merge(false); });
mergeAction = contextMenu.addAction(Tr::tr("&Merge \"%1\" into \"%2\"")
.arg(indexName, currentName),
this,
[this] { merge(false); });
taskTree.reset(onFastForwardMerge([&] {
auto ffMerge = new QAction(
Tr::tr("&Merge \"%1\" into \"%2\" (Fast-Forward)").arg(indexName, currentName));
@@ -279,6 +280,7 @@ void BranchView::slotCustomContextMenu(const QPoint &point)
mergeAction->setText(Tr::tr("Merge \"%1\" into \"%2\" (No &Fast-Forward)")
.arg(indexName, currentName));
}));
connect(mergeAction, &QObject::destroyed, taskTree.get(), &TaskTree::stop);
contextMenu.addAction(Tr::tr("&Rebase \"%1\" on \"%2\"")
.arg(currentName, indexName),