aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls/data/tst_abstractbutton.qml
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 /tests/auto/controls/data/tst_abstractbutton.qml
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 'tests/auto/controls/data/tst_abstractbutton.qml')
-rw-r--r--tests/auto/controls/data/tst_abstractbutton.qml16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_abstractbutton.qml b/tests/auto/controls/data/tst_abstractbutton.qml
index c65930be..9118c221 100644
--- a/tests/auto/controls/data/tst_abstractbutton.qml
+++ b/tests/auto/controls/data/tst_abstractbutton.qml
@@ -322,5 +322,21 @@ TestCase {
keyClick(Qt.Key_S, Qt.AltModifier)
compare(clickSpy.count, 3)
+
+ control.visible = false
+ control.text = "&Hidden"
+ keyClick(Qt.Key_H, Qt.AltModifier)
+ compare(clickSpy.count, 3)
+
+ control.visible = true
+ keyClick(Qt.Key_H, Qt.AltModifier)
+ compare(clickSpy.count, 4)
+
+ // ungrab on destruction (don't crash)
+ control.Component.onDestruction.connect(function() { control = null })
+ control.destroy()
+ wait(0)
+ verify(!control)
+ keyClick(Qt.Key_H, Qt.AltModifier)
}
}