summaryrefslogtreecommitdiffstats
path: root/tests/auto/qmainwindow/tst_qmainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qmainwindow/tst_qmainwindow.cpp')
-rw-r--r--tests/auto/qmainwindow/tst_qmainwindow.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qmainwindow/tst_qmainwindow.cpp b/tests/auto/qmainwindow/tst_qmainwindow.cpp
index b4d765c..4eb3c22 100644
--- a/tests/auto/qmainwindow/tst_qmainwindow.cpp
+++ b/tests/auto/qmainwindow/tst_qmainwindow.cpp
@@ -140,6 +140,7 @@ private slots:
void saveState();
void restoreState();
void restoreStateFromPreviousVersion();
+ void restoreStateDockWidgetBug();
void createPopupMenu();
void iconSizeChanged();
void toolButtonStyleChanged();
@@ -1285,6 +1286,46 @@ void tst_QMainWindow::restoreState()
QVERIFY(mw.restoreState(state, 1));
}
+/*
+ QWidget::setStylesheet() generates QEvent::StyleChange event, which will
+ cause the function QDockAreaLayout::fitLayout() to be called before the layout
+ of MainWindow is activated. This will force the size of dock widgets
+ and the central widget to be calculated using the wrong geometry, which will
+ break the state restored by QMainWindow::restoreState().
+*/
+void tst_QMainWindow::restoreStateDockWidgetBug()
+{
+ QByteArray state;
+
+ //save state
+ {
+ QMainWindow mw1;
+ QDockWidget *dw1 = new QDockWidget();
+ dw1->setObjectName("Left DockWidget");
+ mw1.addDockWidget(Qt::LeftDockWidgetArea, dw1);
+ mw1.setCentralWidget(new QTextEdit());
+ mw1.show();
+ QApplication::processEvents();
+ dw1->setFixedWidth(101);
+ QApplication::processEvents();
+
+ state = mw1.saveState();
+ }
+
+ //restore state
+ QMainWindow mw2;
+ QDockWidget *dw2 = new QDockWidget();
+ dw2->setObjectName("Left DockWidget");
+ mw2.addDockWidget(Qt::LeftDockWidgetArea, dw2);
+ mw2.setCentralWidget(new QTextEdit());
+ mw2.restoreState(state);
+ mw2.setStyleSheet("color:red");
+ mw2.show();
+ QApplication::processEvents();
+
+ QCOMPARE(dw2->width(), 101);
+}
+
//tests the restoration of the previous versions of window settings
void tst_QMainWindow::restoreStateFromPreviousVersion()
{