From fdabbfcbcfe35bce731a2eff3fe13e2d6df238b9 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 23 Feb 2024 12:17:37 +0100 Subject: [PATCH] Diff: Fix that dialog for "Revert Chunk" closes right away MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On macOS. Change-Id: Ifbe402c44779e4062a5dfb5d7c09da7ac845acce Reviewed-by: Jarek Kobus Reviewed-by: Reviewed-by: Orgad Shaneh Reviewed-by: André Hartmann --- .../diffeditor/diffeditorwidgetcontroller.cpp | 9 ++++++--- src/plugins/vcsbase/vcsbaseeditor.cpp | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/plugins/diffeditor/diffeditorwidgetcontroller.cpp b/src/plugins/diffeditor/diffeditorwidgetcontroller.cpp index 0f3a57ee086..9decc5f1a60 100644 --- a/src/plugins/diffeditor/diffeditorwidgetcontroller.cpp +++ b/src/plugins/diffeditor/diffeditorwidgetcontroller.cpp @@ -267,9 +267,12 @@ void DiffEditorWidgetController::addPatchAction(QMenu *menu, int fileIndex, int const QString actionName = patchAction == PatchAction::Apply ? Tr::tr("Apply Chunk...") : Tr::tr("Revert Chunk..."); QAction *action = menu->addAction(actionName); - connect(action, &QAction::triggered, this, [this, fileIndex, chunkIndex, patchAction] { - patch(patchAction, fileIndex, chunkIndex); - }); + connect( + action, + &QAction::triggered, + this, + [this, fileIndex, chunkIndex, patchAction] { patch(patchAction, fileIndex, chunkIndex); }, + Qt::QueuedConnection); const bool enabled = chunkExists(fileIndex, chunkIndex) && (patchAction == PatchAction::Revert || fileNamesAreDifferent(fileIndex)); action->setEnabled(enabled); diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index b10758233a0..38bb004a2d6 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -995,14 +995,20 @@ void VcsBaseEditorWidget::contextMenuEvent(QContextMenuEvent *e) // the user has "Open With" and choose the right diff editor so that // fileNameFromDiffSpecification() works. QAction *applyAction = menu->addAction(Tr::tr("Apply Chunk...")); - connect(applyAction, &QAction::triggered, this, [this, chunk] { - slotApplyDiffChunk(chunk, PatchAction::Apply); - }); + connect( + applyAction, + &QAction::triggered, + this, + [this, chunk] { slotApplyDiffChunk(chunk, PatchAction::Apply); }, + Qt::QueuedConnection); // Revert a chunk from a VCS diff, which might be linked to reloading the diff. QAction *revertAction = menu->addAction(Tr::tr("Revert Chunk...")); - connect(revertAction, &QAction::triggered, this, [this, chunk] { - slotApplyDiffChunk(chunk, PatchAction::Revert); - }); + connect( + revertAction, + &QAction::triggered, + this, + [this, chunk] { slotApplyDiffChunk(chunk, PatchAction::Revert); }, + Qt::QueuedConnection); // Custom diff actions addDiffActions(menu, chunk); break;