Update patch
This commit is contained in:
parent
d87aaf116e
commit
5beebd7938
@ -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 <vlad.zahorodnii@kde.org>
|
From: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
||||||
Date: Mon, 31 Jan 2022 16:31:56 +0200
|
Date: Tue, 01 Feb 2022 13:05:36 +0200
|
||||||
Subject: [PATCH] Client: Make sure mWaitingForUpdateDelivery updates are
|
Subject: [PATCH] Client: Remove mWaitingForUpdateDelivery
|
||||||
thread-safe
|
|
||||||
|
|
||||||
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
|
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
|
--- a/src/client/qwaylandwindow.cpp
|
||||||
+++ b/src/client/qwaylandwindow.cpp
|
+++ b/src/client/qwaylandwindow.cpp
|
||||||
@@ -638,22 +638,21 @@ void QWaylandWindow::handleFrameCallback()
|
@@ -715,12 +715,9 @@
|
||||||
mFrameCallbackElapsedTimer.invalidate();
|
mFrameCallbackElapsedTimer.invalidate();
|
||||||
|
|
||||||
// The rest can wait until we can run it on the correct thread
|
// The rest can wait until we can run it on the correct thread
|
||||||
- if (!mWaitingForUpdateDelivery) {
|
- if (!mWaitingForUpdateDelivery) {
|
||||||
+ if (!mWaitingForUpdateDelivery.loadAcquire()) {
|
- // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
|
||||||
auto doHandleExpose = [this]() {
|
- // in the single-threaded case.
|
||||||
+ mWaitingForUpdateDelivery.storeRelease(false);
|
- mWaitingForUpdateDelivery = true;
|
||||||
bool wasExposed = isExposed();
|
- QMetaObject::invokeMethod(this, &QWaylandWindow::doHandleFrameCallback, Qt::QueuedConnection);
|
||||||
mFrameCallbackTimedOut = false;
|
- }
|
||||||
if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
|
+ // 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()));
|
sendExposeEvent(QRect(QPoint(), geometry().size()));
|
||||||
if (wasExposed && hasPendingUpdateRequest())
|
if (wasExposed && hasPendingUpdateRequest())
|
||||||
deliverUpdateRequest();
|
deliverUpdateRequest();
|
||||||
-
|
-
|
||||||
- mWaitingForUpdateDelivery = false;
|
- mWaitingForUpdateDelivery = false;
|
||||||
};
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mFrameSyncWait.notify_all();
|
bool QWaylandWindow::waitForFrameSync(int timeout)
|
||||||
diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
|
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
|
--- a/src/client/qwaylandwindow_p.h
|
||||||
+++ b/src/client/qwaylandwindow_p.h
|
+++ b/src/client/qwaylandwindow_p.h
|
||||||
@@ -228,7 +228,7 @@ protected:
|
@@ -280,7 +280,6 @@
|
||||||
WId mWindowId;
|
WId mWindowId;
|
||||||
bool mWaitingForFrameCallback = false;
|
bool mWaitingForFrameCallback = false;
|
||||||
bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
|
bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
|
||||||
- bool mWaitingForUpdateDelivery = false;
|
- bool mWaitingForUpdateDelivery = false;
|
||||||
+ QAtomicInteger<bool> mWaitingForUpdateDelivery = false;
|
|
||||||
int mFrameCallbackCheckIntervalTimerId = -1;
|
int mFrameCallbackCheckIntervalTimerId = -1;
|
||||||
QElapsedTimer mFrameCallbackElapsedTimer;
|
QElapsedTimer mFrameCallbackElapsedTimer;
|
||||||
struct ::wl_callback *mFrameCallback = nullptr;
|
struct ::wl_callback *mFrameCallback = nullptr;
|
||||||
--
|
|
||||||
2.35.1
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user