Amends 32edae5e268b968aff82f0713612eff2feffb4e1, 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.5 Change-Id: I8f7e886f3c4ac38e25f9b8bc194eea0833e5974f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit 9ea9e2476d72ae67178d55df99419f202b36131f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit cc5e154914c2a1e128bb9a61e47dd2544fd03925)
Description
Languages
C++
84.3%
HTML
4.9%
C
3.9%
CMake
3.6%
Objective-C++
2%
Other
0.8%