From 48d24fe2e4d6ce6d91805a3425be0954126acc84 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 28 Jun 2017 16:36:02 +0200 Subject: QQuickAbstractButton: fix shortcut handling QQuickAbstractButton::itemChange() already grabs and ungrabs the shortcut when the button's visibility changes, but setShortcut() was grabbing the shortcut without checking the button's visibility, so a hidden button ended up grabbing a shortcut. Furthermore, make sure to ungrab the shortcut on destruction to avoid leaving a dangling pointer to the application shortcut map. Change-Id: Ie93c2d073d7072abad271ba59a45428e3300cc28 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickabstractbutton.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp index e66a33e5..79d62f55 100644 --- a/src/quicktemplates2/qquickabstractbutton.cpp +++ b/src/quicktemplates2/qquickabstractbutton.cpp @@ -430,6 +430,7 @@ QQuickAbstractButton::~QQuickAbstractButton() Q_D(QQuickAbstractButton); if (d->group) d->group->removeButton(this); + d->ungrabShortcut(); } /*! @@ -824,7 +825,8 @@ void QQuickAbstractButton::setShortcut(const QKeySequence &shortcut) d->ungrabShortcut(); d->shortcut = shortcut; - d->grabShortcut(); + if (isVisible()) + d->grabShortcut(); } #endif -- cgit v1.2.3