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

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