aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-06-28 16:36:02 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-06-28 22:13:02 +0000
commit48d24fe2e4d6ce6d91805a3425be0954126acc84 (patch)
treeadb705b21fc931e32785469c1df11f19168f2098 /src
parentd0fdebbc378f2d5c1993eee56b63e27bcff04ca5 (diff)
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 <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quicktemplates2/qquickabstractbutton.cpp4
1 files changed, 3 insertions, 1 deletions
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