QMainWindow: fix potential crash when restoring tab bar state
Don't activate the mainwindow layout while it is being restored. Otherwise we might end up in recursive calls to setGeometry. Pick-to: 6.5 Fixes: QTBUG-111538 Change-Id: I4b6cba9e0abfbae479f71a65b1c4526d92dac081 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
5b8ffc6d2a
commit
fc9853dcbf
@ -46,6 +46,8 @@
|
||||
#include <private/qlayoutengine_p.h>
|
||||
#include <private/qwidgetresizehandler_p.h>
|
||||
|
||||
#include <QScopedValueRollback>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
@ -1813,7 +1815,7 @@ bool QMainWindowTabBar::event(QEvent *e)
|
||||
|
||||
QTabBar *QMainWindowLayout::getTabBar()
|
||||
{
|
||||
if (!usedTabBars.isEmpty()) {
|
||||
if (!usedTabBars.isEmpty() && !isInRestoreState) {
|
||||
/*
|
||||
If dock widgets have been removed and added while the main window was
|
||||
hidden, then the layout hasn't been activated yet, and tab bars from empty
|
||||
@ -2960,6 +2962,7 @@ void QMainWindowLayout::saveState(QDataStream &stream) const
|
||||
|
||||
bool QMainWindowLayout::restoreState(QDataStream &stream)
|
||||
{
|
||||
QScopedValueRollback<bool> guard(isInRestoreState, true);
|
||||
savedState = layoutState;
|
||||
layoutState.clear();
|
||||
layoutState.rect = savedState.rect;
|
||||
|
@ -586,6 +586,7 @@ private:
|
||||
#if QT_CONFIG(tabbar)
|
||||
void updateTabBarShapes();
|
||||
#endif
|
||||
bool isInRestoreState = false;
|
||||
};
|
||||
|
||||
#if QT_CONFIG(dockwidget) && !defined(QT_NO_DEBUG_STREAM)
|
||||
|
Loading…
Reference in New Issue
Block a user