From decc287134139c61da5610afc060a6ca8d09f368 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 4 Aug 2009 15:59:25 +0200 Subject: Cocoa: Menus show old selected values. We never told Cocoa that it needed to redraw the window view when a window was shown. This is implicit if the window is shown for the first time, but needs to be done explicit if you hide and show it again. Task-number: 254672 Reviewed-by: bnilsen --- src/gui/kernel/qwidget_mac.mm | 6 ++++++ tests/auto/qwidget_window/tst_qwidget_window.cpp | 24 +++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 8913c89..057df81 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3249,6 +3249,12 @@ void QWidgetPrivate::show_sys() #ifndef QT_MAC_USE_COCOA SizeWindow(window, q->width(), q->height(), true); #endif + +#ifdef QT_MAC_USE_COCOA + // Make sure that we end up sending a repaint event to + // the widget if the window has been visible one before: + [qt_mac_get_contentview_for(window) setNeedsDisplay:YES]; +#endif if(qt_mac_is_macsheet(q)) { qt_event_request_showsheet(q); } else if(qt_mac_is_macdrawer(q)) { diff --git a/tests/auto/qwidget_window/tst_qwidget_window.cpp b/tests/auto/qwidget_window/tst_qwidget_window.cpp index f059abe..6dddfe8 100644 --- a/tests/auto/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/qwidget_window/tst_qwidget_window.cpp @@ -78,6 +78,7 @@ private slots: void tst_windowFilePath(); void tst_showWithoutActivating(); + void tst_paintEventOnSecondShow(); }; void tst_QWidget_window::initTestCase() @@ -150,7 +151,9 @@ class TestWidget : public QWidget { public: int m_first, m_next; - void reset(){ m_first = m_next = 0; } + bool paintEventReceived; + + void reset(){ m_first = m_next = 0; paintEventReceived = false; } bool event(QEvent *event) { switch (event->type()) { @@ -162,6 +165,10 @@ public: m_next = event->type(); else m_first = event->type(); + break; + case QEvent::Paint: + paintEventReceived = true; + break; default: break; } @@ -300,5 +307,20 @@ void tst_QWidget_window::tst_showWithoutActivating() #endif // Q_WS_X11 } +void tst_QWidget_window::tst_paintEventOnSecondShow() +{ + TestWidget w; + w.show(); + w.hide(); + + w.reset(); + w.show(); +#ifdef Q_WS_X11 + QTest::qWait(500); +#endif + QApplication::processEvents(); + QVERIFY(w.paintEventReceived); +} + QTEST_MAIN(tst_QWidget_window) #include "tst_qwidget_window.moc" -- cgit v0.12