diff options
author | Axel Spoerl <[email protected]> | 2025-07-03 07:35:37 +0200 |
---|---|---|
committer | Axel Spoerl <[email protected]> | 2025-07-03 13:49:18 +0200 |
commit | 2c8692adaed1c3374ca01842e166af79ed3861cc (patch) | |
tree | 6d722e4c2cc99de4bbe983a5436017a25b4a80a9 | |
parent | 9671b49182f37f575eea5f0a38b67a2ba85bdd74 (diff) |
QMainWindowLayout::animationFinished(): don't show deleted tab bars
QMainWindowLayout::animationFinished(): looped over a copy of the
usedTabBars member and showed all tab bars in the container.
Showing a tab bar, can cause another in the container to become unused.
Unused tab bars were kept in a separate container and re-used, before
a3f0ce4c0d0627ef979052b34b21e6fd2bdc3acf changed this logic and deleted
unused tab bars.
This caused a regression: show() was called on a deleted tab bar,
causing a crash.
Only show tab bars from the copied container, if usedTabBars still
contains them.
Fixes: QTBUG-138201
Pick-to: 6.10 6.9
Change-Id: I33de57ab3276d1f786d27f63aebfe8ba8ddc2832
Reviewed-by: Samuel Gaist <[email protected]>
Reviewed-by: Marc Mutz <[email protected]>
-rw-r--r-- | src/widgets/widgets/qmainwindowlayout.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 87c33932a8d..a1a4cfc2ce0 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -2673,8 +2673,10 @@ void QMainWindowLayout::animationFinished(QWidget *widget) parentWidget()->update(layoutState.dockAreaLayout.separatorRegion()); #if QT_CONFIG(tabbar) const auto usedTabBarsCopy = usedTabBars; // list potentially modified by animations - for (QTabBar *tab_bar : usedTabBarsCopy) - tab_bar->show(); + for (QTabBar *tab_bar : usedTabBarsCopy) { + if (usedTabBars.contains(tab_bar)) // Showing a tab bar can cause another to be deleted. + tab_bar->show(); + } #endif // QT_CONFIG(tabbar) #endif // QT_CONFIG(dockwidget) } |