summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2022-06-16 13:16:58 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-06-17 18:59:36 +0000
commit1ed89b70122f7a9ba9f315bbebe3c57773bc9705 (patch)
tree41266d3426a1ab3c2e3d83edea0888fe24d58818 /tests
parent8562f3aee618f2da1377be005cd539cec1b4ca9e (diff)
QMainWindow: fix restoreState() for toolbars
Restoring the toolbar state of a QMainWindow could not update QWidgetPrivate::widgetItem for the QToolBar, because at that point it was still holding the pointer to the widgetItem of the previous state. Later on, when the new state was successfully applied, the previous state was deleted, and the corresponding widgetItem was reset to nullptr. This patch explicitly resets the QToolBar's widgetItem while updating the state, so that it is later correctly updated while creating a new QWidgetItemV2. Fixes: QTBUG-102395 Change-Id: I17613d62423edcc0faf85ecb0a714865a50d87e8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 2ed54dedf3783471716b21509db1f8279d5b5af8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
index 1c7ceec0ec..6996591946 100644
--- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
+++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
@@ -1340,14 +1340,19 @@ void tst_QMainWindow::restoreState()
dw.setObjectName(QLatin1String("dock"));
mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);
+ QWidgetPrivate *tbp = QWidgetPrivate::get(&tb);
+ QVERIFY(tbp->widgetItem);
+
QByteArray state;
state = mw.saveState();
QVERIFY(mw.restoreState(state));
+ QVERIFY(tbp->widgetItem);
state = mw.saveState(1);
QVERIFY(!mw.restoreState(state));
QVERIFY(mw.restoreState(state, 1));
+ QVERIFY(tbp->widgetItem);
}
//tests the restoration of the previous versions of window settings