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

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