Sophie

Sophie

distrib > Mageia > 9 > armv7hl > media > core-release-src > by-pkgid > 9d2048ba1b2c43fc57624ee9e5871089 > files > 3

qtquickcontrols25-5.15.7-1.mga9.src.rpm

From aeadc693cf323d61beb6e1d56121e6aabd013902 Mon Sep 17 00:00:00 2001
From: Oliver Eftevaag <oliver.eftevaag@qt.io>
Date: Wed, 19 Jan 2022 22:09:56 +0100
Subject: [PATCH 3/5] 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>

(cherry picked from commit 45af5ef2f63704adc515e29260ad8c6aaf51f08e in
qtdeclarative)
---
 src/quicktemplates2/qquickaction.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/quicktemplates2/qquickaction.cpp b/src/quicktemplates2/qquickaction.cpp
index 2041e7741..8610cdfae 100644
--- a/src/quicktemplates2/qquickaction.cpp
+++ b/src/quicktemplates2/qquickaction.cpp
@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
 
 void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
 {
-    if (shortcut.isEmpty())
+    if (shortcut.isEmpty() || m_shortcutId)
         return;
 
     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
-- 
2.37.3