aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-09-27 17:41:40 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-09-28 11:38:11 +0000
commit3f1229bb7bfd45fdc09ce8c2a16cc59e322d5d1c (patch)
treec0aef897714fd46de1023d94ec08f0bd8d7fa622 /tests/auto
parent576a97774e04858adee9f2080e485a715e985820 (diff)
QQuickButtonGroup: track the checked button with a QPointer
A destroyed button removes itself from a group, but because of the workaround added for QTBUG-52358, there's a moment after clear() when a button is removed from a group and before it is added back to the group. If the button gets destroyed during that period, the group ends up with a dangling pointer. Task-number: QTBUG-62946 Task-number: QTBUG-63470 Change-Id: If994f87b221a7e77f56458866c4d132365c45d6f Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/controls/data/tst_buttongroup.qml32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_buttongroup.qml b/tests/auto/controls/data/tst_buttongroup.qml
index bde655da..6baff494 100644
--- a/tests/auto/controls/data/tst_buttongroup.qml
+++ b/tests/auto/controls/data/tst_buttongroup.qml
@@ -346,4 +346,36 @@ TestCase {
verify(container.group.checkedButton)
compare(container.group.checkedButton.objectName, "0")
}
+
+ Component {
+ id: checkedButtonColumn
+ Column {
+ id: column
+ ButtonGroup { buttons: column.children }
+ Repeater {
+ id: repeater
+ delegate: Button {
+ checkable: true
+ text: modelData
+ onClicked: listModel.remove(index)
+ }
+ model: ListModel {
+ id: listModel
+ Component.onCompleted: {
+ for (var i = 0; i < 10; ++i)
+ append({text: i})
+ }
+ }
+ }
+ }
+ }
+
+ function test_checkedButtonDestroyed() {
+ var column = createTemporaryObject(checkedButtonColumn, testCase)
+ verify(column)
+
+ waitForRendering(column)
+ mouseClick(column.children[0])
+ wait(0) // don't crash (QTBUG-62946, QTBUG-63470)
+ }
}