Blame SOURCES/0035-Client-Remove-mWaitingForUpdateDelivery.patch

165ad0
From a97759d032a40045551546ca17300891d4067ee4 Mon Sep 17 00:00:00 2001
165ad0
From: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
165ad0
Date: Tue, 1 Feb 2022 13:05:36 +0200
165ad0
Subject: [PATCH 35/40] Client: Remove mWaitingForUpdateDelivery
165ad0
165ad0
Currently, mWaitingForUpdateDelivery is shared between the main thread
165ad0
(doHandleFrameCallback()) and the frame callback event thread
165ad0
(handleFrameCallback()), however the access to it is not synchronized
165ad0
between both threads. On the other hand, QWaylandWindow
165ad0
already ensures not to create a frame callback if there's already one
165ad0
pending.
165ad0
165ad0
This change removes mWaitingForUpdateDelivery flag because it should be
165ad0
already covered by mWaitingForFrameCallback and to remove unsynchronized
165ad0
shared state between threads.
165ad0
165ad0
Change-Id: I0e5a25d18d1e66c4d7683e7e972330c4d7cbbf38
165ad0
Reviewed-by: David Edmundson <davidedmundson@kde.org>
165ad0
(cherry picked from commit feb1a5c207c13d0bf87c0d8ad039279dbf8cee9e)
165ad0
---
165ad0
 src/client/qwaylandwindow.cpp | 29 ++++++++++++-----------------
165ad0
 src/client/qwaylandwindow_p.h |  1 -
165ad0
 2 files changed, 12 insertions(+), 18 deletions(-)
165ad0
165ad0
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
165ad0
index 4c5711a0..949374b1 100644
165ad0
--- a/src/client/qwaylandwindow.cpp
165ad0
+++ b/src/client/qwaylandwindow.cpp
165ad0
@@ -648,23 +648,18 @@ void QWaylandWindow::handleFrameCallback()
165ad0
     mFrameCallbackElapsedTimer.invalidate();
165ad0
 
165ad0
     // The rest can wait until we can run it on the correct thread
165ad0
-    if (!mWaitingForUpdateDelivery) {
165ad0
-        auto doHandleExpose = [this]() {
165ad0
-            bool wasExposed = isExposed();
165ad0
-            mFrameCallbackTimedOut = false;
165ad0
-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
165ad0
-                sendExposeEvent(QRect(QPoint(), geometry().size()));
165ad0
-            if (wasExposed && hasPendingUpdateRequest())
165ad0
-                deliverUpdateRequest();
165ad0
-
165ad0
-            mWaitingForUpdateDelivery = false;
165ad0
-        };
165ad0
-
165ad0
-        // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
165ad0
-        // in the single-threaded case.
165ad0
-        mWaitingForUpdateDelivery = true;
165ad0
-        QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
165ad0
-    }
165ad0
+    auto doHandleExpose = [this]() {
165ad0
+        bool wasExposed = isExposed();
165ad0
+        mFrameCallbackTimedOut = false;
165ad0
+        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
165ad0
+            sendExposeEvent(QRect(QPoint(), geometry().size()));
165ad0
+        if (wasExposed && hasPendingUpdateRequest())
165ad0
+            deliverUpdateRequest();
165ad0
+    };
165ad0
+
165ad0
+    // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
165ad0
+    // in the single-threaded case.
165ad0
+    QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
165ad0
 
165ad0
     mFrameSyncWait.notify_all();
165ad0
 }
165ad0
diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
165ad0
index d45980a8..3ff68ccb 100644
165ad0
--- a/src/client/qwaylandwindow_p.h
165ad0
+++ b/src/client/qwaylandwindow_p.h
165ad0
@@ -228,7 +228,6 @@ protected:
165ad0
     WId mWindowId;
165ad0
     bool mWaitingForFrameCallback = false;
165ad0
     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
165ad0
-    bool mWaitingForUpdateDelivery = false;
165ad0
     int mFrameCallbackCheckIntervalTimerId = -1;
165ad0
     QElapsedTimer mFrameCallbackElapsedTimer;
165ad0
     struct ::wl_callback *mFrameCallback = nullptr;
165ad0
-- 
165ad0
2.35.1
165ad0