From 5beebd793895c40637da95f36c0808232f490d6f Mon Sep 17 00:00:00 2001 From: Jan Grulich Date: Tue, 1 Feb 2022 12:35:31 +0100 Subject: [PATCH] Update patch --- ...ent-remove-mwaitingforupdatedelivery.patch | 70 ++++++++++--------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/qtwayland-client-remove-mwaitingforupdatedelivery.patch b/qtwayland-client-remove-mwaitingforupdatedelivery.patch index e35af1e..b55b377 100644 --- a/qtwayland-client-remove-mwaitingforupdatedelivery.patch +++ b/qtwayland-client-remove-mwaitingforupdatedelivery.patch @@ -1,58 +1,60 @@ -From 92969a01c91e7d21332be55c005bf861c89252d2 Mon Sep 17 00:00:00 2001 +From 591d38d21cdd215677c6e9e8e6e0cfa9acd9c48c Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii -Date: Mon, 31 Jan 2022 16:31:56 +0200 -Subject: [PATCH] Client: Make sure mWaitingForUpdateDelivery updates are - thread-safe +Date: Tue, 01 Feb 2022 13:05:36 +0200 +Subject: [PATCH] Client: Remove mWaitingForUpdateDelivery -Change-Id: I7e22fe49f679fb87d56bae0bc3c1d2c261ffe144 +Currently, mWaitingForUpdateDelivery is shared between the main thread +(doHandleFrameCallback()) and the frame callback event thread +(handleFrameCallback()), however the access to it is not synchronized +between neither both threads. On the other hand, QWaylandWindow +already ensures not to create a frame callback if there's already one +pending. + +This change removes mWaitingForUpdateDelivery flag because it should be +already covered by mWaitingForFrameCallback and to remove unsynchronized +shared state between threads. + +Change-Id: I0e5a25d18d1e66c4d7683e7e972330c4d7cbbf38 --- - src/client/qwaylandwindow.cpp | 7 +++---- - src/client/qwaylandwindow_p.h | 2 +- - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp -index 7de19a74..b22864ab 100644 +index 812373a..29e6ef6 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp -@@ -638,22 +638,21 @@ void QWaylandWindow::handleFrameCallback() +@@ -715,12 +715,9 @@ mFrameCallbackElapsedTimer.invalidate(); // The rest can wait until we can run it on the correct thread - if (!mWaitingForUpdateDelivery) { -+ if (!mWaitingForUpdateDelivery.loadAcquire()) { - auto doHandleExpose = [this]() { -+ mWaitingForUpdateDelivery.storeRelease(false); - bool wasExposed = isExposed(); - mFrameCallbackTimedOut = false; - if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed? - sendExposeEvent(QRect(QPoint(), geometry().size())); - if (wasExposed && hasPendingUpdateRequest()) - deliverUpdateRequest(); -- -- mWaitingForUpdateDelivery = false; - }; - - // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync() - // in the single-threaded case. +- // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync() +- // in the single-threaded case. - mWaitingForUpdateDelivery = true; - QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection); -+ mWaitingForUpdateDelivery.storeRelease(true); - } +- QMetaObject::invokeMethod(this, &QWaylandWindow::doHandleFrameCallback, Qt::QueuedConnection); +- } ++ // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync() ++ // in the single-threaded case. ++ QMetaObject::invokeMethod(this, &QWaylandWindow::doHandleFrameCallback, Qt::QueuedConnection); mFrameSyncWait.notify_all(); + } +@@ -733,8 +730,6 @@ + sendExposeEvent(QRect(QPoint(), geometry().size())); + if (wasExposed && hasPendingUpdateRequest()) + deliverUpdateRequest(); +- +- mWaitingForUpdateDelivery = false; + } + + bool QWaylandWindow::waitForFrameSync(int timeout) diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h -index d45980a8..a8699827 100644 +index d64c80c..6eb8053 100644 --- a/src/client/qwaylandwindow_p.h +++ b/src/client/qwaylandwindow_p.h -@@ -228,7 +228,7 @@ protected: +@@ -280,7 +280,6 @@ WId mWindowId; bool mWaitingForFrameCallback = false; bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out - bool mWaitingForUpdateDelivery = false; -+ QAtomicInteger mWaitingForUpdateDelivery = false; int mFrameCallbackCheckIntervalTimerId = -1; QElapsedTimer mFrameCallbackElapsedTimer; struct ::wl_callback *mFrameCallback = nullptr; --- -2.35.1 -