diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index a1b1b20869..6fb263f87d 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -46,6 +46,8 @@ #include #include +#include + 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 guard(isInRestoreState, true); savedState = layoutState; layoutState.clear(); layoutState.rect = savedState.rect; diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index 394a052a09..0f784b56d0 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -586,6 +586,7 @@ private: #if QT_CONFIG(tabbar) void updateTabBarShapes(); #endif + bool isInRestoreState = false; }; #if QT_CONFIG(dockwidget) && !defined(QT_NO_DEBUG_STREAM)