From 1ddbd9a855926d17e7de86c993a5f7d9e57c3401 Mon Sep 17 00:00:00 2001 From: Carlos Manuel Duclos Vergara Date: Fri, 23 Jul 2010 17:03:42 +0200 Subject: Drawer widget in a MainWindow disappears after returning from full screen mode. The problem was in the toggleDrawer function. We were not checking the status of the last transition before setting the new transition, so all the transition were treated as non-intentional. Task-number: QTBUG-11373 Reviewed-by: Prasanth (cherry picked from commit 725d8e061ededee9a5ddf0914aabd0f6aa2ee741) --- src/gui/kernel/qwidget_mac.mm | 4 +++- tests/auto/qwidget/tst_qwidget.cpp | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index e57ec77..c2af6af 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -1599,12 +1599,14 @@ void QWidgetPrivate::toggleDrawers(bool visible) continue; QWidget *widget = static_cast(object); if(qt_mac_is_macdrawer(widget)) { + bool oldState = widget->testAttribute(Qt::WA_WState_ExplicitShowHide); if(visible) { if (!widget->testAttribute(Qt::WA_WState_ExplicitShowHide)) widget->show(); } else { widget->hide(); - widget->setAttribute(Qt::WA_WState_ExplicitShowHide, false); + if(!oldState) + widget->setAttribute(Qt::WA_WState_ExplicitShowHide, false); } } } diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index fee7ef0..f722f89 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -397,6 +397,9 @@ private slots: void childAt(); #ifdef Q_WS_MAC void childAt_unifiedToolBar(); +#ifdef QT_MAC_USE_COCOA + void taskQTBUG_11373(); +#endif // QT_MAC_USE_COCOA #endif private: @@ -10433,6 +10436,26 @@ void tst_QWidget::childAt_unifiedToolBar() QCOMPARE(mainWindow.childAt(toolBarTopLeft), static_cast(toolBar)); QCOMPARE(mainWindow.childAt(labelTopLeft), static_cast(label)); } + +#ifdef QT_MAC_USE_COCOA +void tst_QWidget::taskQTBUG_11373() +{ + QMainWindow * myWindow = new QMainWindow(); + QWidget * center = new QWidget(); + myWindow -> setCentralWidget(center); + QWidget * drawer = new QWidget(myWindow, Qt::Drawer); + drawer -> hide(); + QCOMPARE(drawer->isVisible(), false); + myWindow -> show(); + myWindow -> raise(); + // The drawer shouldn't be visible now. + QCOMPARE(drawer->isVisible(), false); + myWindow -> setWindowState(Qt::WindowFullScreen); + myWindow -> setWindowState(Qt::WindowNoState); + // The drawer should still not be visible, since we haven't shown it. + QCOMPARE(drawer->isVisible(), false); +} +#endif // QT_MAC_USE_COCOA #endif QTEST_MAIN(tst_QWidget) -- cgit v0.12