From bb31aa853eb704bc916004ea59ad57bc6baa1276 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= <morten.sorvig@digia.com>
Date: Thu, 30 Oct 2014 16:52:36 +0100
Subject: [PATCH] Cocoa: refactor commit 876a428f.

Conditions for when updateExposedGeometry() should
actually send the expose event goes into the function
itself.

The window()->isVisible() check could arguably be
moved to isWindowExposable(), but I'm keeping this
as a straight refactor without any behavior changes.
(isWindowExposable() is called from multiple locations)

Change-Id: I6d792286ccbc50065ebfc588daca2240761a1937
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
---
 src/plugins/platforms/cocoa/qcocoawindow.mm | 5 +++++
 src/plugins/platforms/cocoa/qnsview.mm      | 8 ++------
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index f536e20b39a..56c356711e5 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -1754,6 +1754,11 @@ void QCocoaWindow::updateExposedGeometry()
     if (!m_geometryUpdateExposeAllowed)
         return;
 
+    // Do not send incorrect exposes in case the window is not even visible yet.
+    // We might get here as a result of a resize() from QWidget's show(), for instance.
+    if (!window()->isVisible())
+        return;
+
     if (!isWindowExposable())
         return;
 
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 83e913ad58c..052a7cc98f1 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -361,12 +361,8 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
     // Send a geometry change event to Qt, if it's ready to handle events
     if (!m_platformWindow->m_inConstructor) {
         QWindowSystemInterface::handleGeometryChange(m_window, geometry);
-        // Do not send incorrect exposes in case the window is not even visible yet.
-        // We might get here as a result of a resize() from QWidget's show(), for instance.
-        if (m_platformWindow->window()->isVisible()) {
-            m_platformWindow->updateExposedGeometry();
-            QWindowSystemInterface::flushWindowSystemEvents();
-        }
+        m_platformWindow->updateExposedGeometry();
+        QWindowSystemInterface::flushWindowSystemEvents();
     }
 }
 
-- 
GitLab