From 5d07a4d9448f60139c711e592cbf3ac47d4df3d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= <morten.sorvig@digia.com>
Date: Mon, 22 Apr 2013 13:11:29 +0200
Subject: [PATCH] Process initial expose events immediately.

Required to prevent qmlscene flicker on startup.

Also brings back that qWait() in tst_QGL::graphicsViewClipping()
that seems necessary after all.

Amended-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Change-Id: I14ba6e18ac98e5df1ce8ecbc263b30176b67d111
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
---
 src/plugins/platforms/cocoa/qcocoawindow.mm | 1 +
 tests/auto/opengl/qgl/tst_qgl.cpp           | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 83678ddf678..94904c12f63 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -320,6 +320,7 @@ void QCocoaWindow::setVisible(bool visible)
         // - QNSViews for child windows are initialy not hidden and won't get the
         //   viewDidUnhide message.
         exposeWindow();
+        QWindowSystemInterface::flushWindowSystemEvents();
 
         if (m_nsWindow) {
             // setWindowState might have been called while the window was hidden and
diff --git a/tests/auto/opengl/qgl/tst_qgl.cpp b/tests/auto/opengl/qgl/tst_qgl.cpp
index 00973cf533d..28ec699427c 100644
--- a/tests/auto/opengl/qgl/tst_qgl.cpp
+++ b/tests/auto/opengl/qgl/tst_qgl.cpp
@@ -875,6 +875,10 @@ void tst_QGL::graphicsViewClipping()
     scene.setSceneRect(view.viewport()->rect());
 
     QVERIFY(QTest::qWaitForWindowExposed(&view));
+    #ifdef Q_OS_MAC
+        // The black rectangle jumps from the center to the upper left for some reason.
+        QTest::qWait(100);
+    #endif
 
     QTRY_VERIFY(widget->painted);
 
-- 
GitLab