qt6-bb10/tests/auto/widgets
Volker Hilsheimer 9ea9e2476d QMainWindow: don't crash when restored state is modified before applied
Amends 32edae5e26, after which we keep a
copy of the restored state if the state couldn't be applied yet. Since
making a copy of the entire state results in multiple copies of layout
item pointers, we might end up with dangling pointers if the layout
structure is modified while we keep the copy. This can happen if methods
such as tabifyDockWidgets or splitDockWidget get called; e.g. tabifying
dock widgets will destroy the layout items that were added for them.

Unfortunately, the layout items do not have a pointer back to the layout
they live in, and the items in the stored state might not yet live in a
layout anyway. So we cannot remove the items from their layout in a
QDockWidgetItem destructor implementation.

Instead, we have to forget the stored state. Add a helper function that
writes the stored state back to the actual state, and deletes the stored
state afterwards. Call this function when the layout might get modified
programmatically.

Add a test case that reproduces the crash without the fix, and passes
with the patch.

Fixes: QTBUG-120025
Pick-to: 6.7 6.6 6.5
Change-Id: I8f7e886f3c4ac38e25f9b8bc194eea0833e5974f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-12-13 15:15:24 +01:00
..
dialogs Purge empty BLACKLIST files from tests 2023-11-24 18:09:16 +01:00
effects Stabilize tst_QGraphicsEffect::draw() 2023-08-25 09:04:37 +02:00
graphicsview Android: Skip focusProxy_QTBUG_51856() test case temporarily 2023-12-07 10:56:43 +02:00
itemviews Tests: remove blacklisted CIs no longer available 2023-12-06 22:07:44 +01:00
kernel Android: Skip showAndMoveChild() test case temporarily 2023-12-07 10:56:43 +02:00
styles Reset palette resolve mask in windows vista style 2023-09-05 10:59:00 +02:00
util Tests: remove blacklisted CIs no longer available 2023-12-06 22:07:44 +01:00
widgets QMainWindow: don't crash when restored state is modified before applied 2023-12-13 15:15:24 +01:00
CMakeLists.txt tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00