diff options
-rw-r--r-- | src/quicktemplates2/qquickabstractbutton.cpp | 11 | ||||
-rw-r--r-- | src/quicktemplates2/qquickabstractbutton_p_p.h | 1 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_switch.qml | 23 |
3 files changed, 35 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp index e2b312b2..64428bda 100644 --- a/src/quicktemplates2/qquickabstractbutton.cpp +++ b/src/quicktemplates2/qquickabstractbutton.cpp @@ -399,6 +399,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item) emit q->implicitIndicatorHeightChanged(); } +void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item) +{ + Q_Q(QQuickAbstractButton); + QQuickControlPrivate::itemDestroyed(item); + if (item == indicator) { + indicator = nullptr; + emit q->implicitIndicatorWidthChanged(); + emit q->implicitIndicatorHeightChanged(); + } +} + QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const { Q_Q(const QQuickAbstractButton); diff --git a/src/quicktemplates2/qquickabstractbutton_p_p.h b/src/quicktemplates2/qquickabstractbutton_p_p.h index 6a9124da..5d9f9324 100644 --- a/src/quicktemplates2/qquickabstractbutton_p_p.h +++ b/src/quicktemplates2/qquickabstractbutton_p_p.h @@ -110,6 +110,7 @@ public: void itemImplicitWidthChanged(QQuickItem *item) override; void itemImplicitHeightChanged(QQuickItem *item) override; + void itemDestroyed(QQuickItem *item) override; // copied from qabstractbutton.cpp static const int AUTO_REPEAT_DELAY = 300; diff --git a/tests/auto/controls/data/tst_switch.qml b/tests/auto/controls/data/tst_switch.qml index b3fab41c..10b6baa0 100644 --- a/tests/auto/controls/data/tst_switch.qml +++ b/tests/auto/controls/data/tst_switch.qml @@ -608,4 +608,27 @@ TestCase { mouseClick(control.indicator) verify(control.activeFocus) } + + Component { + id: deletionOrder1 + Item { + Image { id: innerImage } + Switch { indicator: innerImage } + } + } + + Component { + id: deletionOrder2 + Item { + Switch { indicator: innerImage } + Image { id: innerImage } + } + } + + function test_deletionOrder() { + var control1 = createTemporaryObject(deletionOrder1, testCase) + verify(control1) + var control2 = createTemporaryObject(deletionOrder2, testCase) + verify(control2) + } } |