From 028f27781fdb60442d05941a72ed5acb4bdd9a7e Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 8 Jul 2024 14:06:07 +0200 Subject: [PATCH] Core: Fix saving document after showing editor context menu The editor context menu generated for the drag mark contains actions that also gets the same shortcut as the global save command, to make them visible in the menu. This leads to ambiguous shortcut events if these actions are still taken into account after closing the context menu. Avoid this by removing the actions from the context menu again when hiding it. This was previously done before the menu was shown again, so this just does it earlier. Fixes: QTCREATORBUG-31205 Change-Id: I49490c2d6cbd3b000c717f35373e7f9b6b5393e4 Reviewed-by: Christian Stenger --- src/plugins/coreplugin/editortoolbar.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/coreplugin/editortoolbar.cpp b/src/plugins/coreplugin/editortoolbar.cpp index 857a32b6372..5675cae0eb3 100644 --- a/src/plugins/coreplugin/editortoolbar.cpp +++ b/src/plugins/coreplugin/editortoolbar.cpp @@ -193,9 +193,13 @@ EditorToolBar::EditorToolBar(QWidget *parent) : menu.exec(d->m_editorList->mapToGlobal(p)); }); connect(d->m_dragHandleMenu, &QMenu::aboutToShow, this, [this] { - d->m_dragHandleMenu->clear(); fillListContextMenu(d->m_dragHandleMenu); }); + connect(d->m_dragHandleMenu, &QMenu::aboutToHide, this, [this] { + // Remove actions from context menu, to avoid any shortcuts set on them + // for the display in the menu interfering with global actions + d->m_dragHandleMenu->clear(); + }); connect(d->m_lockButton, &QAbstractButton::clicked, this, &EditorToolBar::makeEditorWritable); connect(d->m_closeEditorButton, &QAbstractButton::clicked, this, &EditorToolBar::closeEditor, Qt::QueuedConnection);