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 <christian.stenger@qt.io>
This commit is contained in:
Eike Ziller
2024-07-08 14:06:07 +02:00
parent 533f03f248
commit 028f27781f

View File

@@ -193,9 +193,13 @@ EditorToolBar::EditorToolBar(QWidget *parent) :
menu.exec(d->m_editorList->mapToGlobal(p)); menu.exec(d->m_editorList->mapToGlobal(p));
}); });
connect(d->m_dragHandleMenu, &QMenu::aboutToShow, this, [this] { connect(d->m_dragHandleMenu, &QMenu::aboutToShow, this, [this] {
d->m_dragHandleMenu->clear();
fillListContextMenu(d->m_dragHandleMenu); 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_lockButton, &QAbstractButton::clicked, this, &EditorToolBar::makeEditorWritable);
connect(d->m_closeEditorButton, &QAbstractButton::clicked, connect(d->m_closeEditorButton, &QAbstractButton::clicked,
this, &EditorToolBar::closeEditor, Qt::QueuedConnection); this, &EditorToolBar::closeEditor, Qt::QueuedConnection);