1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
From 38dbeb8f5aa346f490003c75d9fa6e4b817f5bc8 Mon Sep 17 00:00:00 2001
From: Ulf Hermann <ulf.hermann@qt.io>
Date: Tue, 11 Jan 2022 12:42:47 +0100
Subject: [PATCH] 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(+)
@@ -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);
@@ -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;
@@ -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)
+ }
}
|