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;