diff options
-rw-r--r-- | src/quicktemplates2/qquickbuttongroup.cpp | 4 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_buttongroup.qml | 32 |
2 files changed, 33 insertions, 3 deletions
diff --git a/src/quicktemplates2/qquickbuttongroup.cpp b/src/quicktemplates2/qquickbuttongroup.cpp index f0813a17..355fcf6a 100644 --- a/src/quicktemplates2/qquickbuttongroup.cpp +++ b/src/quicktemplates2/qquickbuttongroup.cpp @@ -154,8 +154,6 @@ class QQuickButtonGroupPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QQuickButtonGroup) public: - QQuickButtonGroupPrivate() : checkedButton(nullptr) { } - void clear(); void buttonClicked(); void _q_updateCurrent(); @@ -165,7 +163,7 @@ public: static QQuickAbstractButton *buttons_at(QQmlListProperty<QQuickAbstractButton> *prop, int index); static void buttons_clear(QQmlListProperty<QQuickAbstractButton> *prop); - QQuickAbstractButton *checkedButton; + QPointer<QQuickAbstractButton> checkedButton; QVector<QQuickAbstractButton*> buttons; }; 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) + } } |