Skip to content

QQuickAction: don't grab the same shortcut multiple times

If the entry for the QQuickItem that the QQuickAction is set on has already grabbed the shortcut, then m_shortcutId is no longer 0 and we must not overwrite the value. Otherwise, the QQuickItem removing itself from the action might not remove the correct entry from Qt's shortcut map, leaving a dangling pointer behind.

Multiple calls to QQuickActionPrivate::ShortcutEntry::grab are possible, because we grab the shortcut whenever the shortcut changes, or when an item representing the action becomes visible.

The test case added reproduces this scenario by adding the action to a menu item and then making the menu explicitly visible, resulting in two calls to grab() which should be idempotent.

Fixes: QTBUG-96551 Fixes: QTBUG-96561 Pick-to: 6.2 Change-Id: I7d42a4f4c04f7d8759f2d0f24a133720f10e4c47 Reviewed-by: Mitch Curtis mitch.curtis@qt.io Reviewed-by: Jarkko Koivikko jarkko.koivikko@code-q.fi Reviewed-by: Volker Hilsheimer volker.hilsheimer@qt.io

Merge request reports

Loading