diff options
author | Axel Spoerl <axel.spoerl@qt.io> | 2024-04-09 19:23:33 +0200 |
---|---|---|
committer | Axel Spoerl <axel.spoerl@qt.io> | 2024-04-10 19:01:06 +0000 |
commit | ef8e548cf1adf8032c030df04e69988f238c77fb (patch) | |
tree | d094a367af78bb17ca3e259e233c42770ff241d2 /tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp | |
parent | ca851b33171e652b740efbc47d41b8cf906ecd3d (diff) |
QLayout: Consume ChildRemoved event, when layout is disabled
QLayout::widgetEvent() returned early, when the layout was disabled.
That suppressed ChildRemoved events and lead to a crash, when the
layout was enabled again.
Don't return early on ChildRemoved events.
Add an autotest in tst_layout::removeWidget().
Fixes: QTBUG-124151
Pick-to: 6.7 6.5 6.2
Change-Id: Ib0a0bb73978d9fc2c9777d300cf38a8c4496b702
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Chris René Lerner <chris.lerner@qt.io>
Diffstat (limited to 'tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp')
-rw-r--r-- | tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp index 3c3010c3ec..bd170ca8ab 100644 --- a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp +++ b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp @@ -378,10 +378,10 @@ void tst_QLayout::removeWidget() { QHBoxLayout layout; QCOMPARE(layout.count(), 0); - QWidget w; - layout.addWidget(&w); + std::unique_ptr<QWidget> w(new QWidget); + layout.addWidget(w.get()); QCOMPARE(layout.count(), 1); - layout.removeWidget(&w); + layout.removeWidget(w.get()); QCOMPARE(layout.count(), 0); QPointer<QLayout> childLayout(new QHBoxLayout); @@ -395,6 +395,12 @@ void tst_QLayout::removeWidget() QCOMPARE(layout.count(), 0); QVERIFY(!childLayout.isNull()); + + // Test inactive layout consumes ChildRemoved event (QTBUG-124151) + layout.addWidget(w.get()); + layout.setEnabled(false); + w.reset(); + layout.setEnabled(true); } QTEST_MAIN(tst_QLayout) |