qt5-qtquickcontrols2/0004-QQuickAbstractButton-fix-crash-on-destruction.patch

90 lines
3.0 KiB
Diff
Raw Normal View History

2022-10-31 13:21:18 +00:00
From 1bd1ceae8b8340f9d0e06b55a301c4642324d64a Mon Sep 17 00:00:00 2001
From: Ulf Hermann <ulf.hermann@qt.io>
Date: Tue, 11 Jan 2022 12:42:47 +0100
2022-10-31 13:21:18 +00:00
Subject: [PATCH 4/5] QQuickAbstractButton: fix crash on destruction
If we listen for size changes we also need to remove the object listened
to when it's deleted.
Pick-to: 5.15 6.2 6.3
Fixes: QTBUG-99644
Change-Id: I613855ebd986b1e67685088020b88d8b070659cf
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
(cherry picked from commit 720ffaeb60d43123522066e1de3a69ad551644aa in
qtdeclarative)
---
src/quicktemplates2/qquickabstractbutton.cpp | 11 +++++++++
.../qquickabstractbutton_p_p.h | 1 +
tests/auto/controls/data/tst_switch.qml | 23 +++++++++++++++++++
3 files changed, 35 insertions(+)
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp
index 950e4e099..1df0c706d 100644
--- a/src/quicktemplates2/qquickabstractbutton.cpp
+++ b/src/quicktemplates2/qquickabstractbutton.cpp
@@ -387,6 +387,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 9291c1a87..b729720f2 100644
--- a/src/quicktemplates2/qquickabstractbutton_p_p.h
+++ b/src/quicktemplates2/qquickabstractbutton_p_p.h
@@ -109,6 +109,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 b3fab41ca..10b6baa02 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)
+ }
}
--
2022-09-20 15:36:34 +00:00
2.37.3