59 lines
2.4 KiB
Diff
59 lines
2.4 KiB
Diff
|
From 92969a01c91e7d21332be55c005bf861c89252d2 Mon Sep 17 00:00:00 2001
|
||
|
From: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
||
|
Date: Mon, 31 Jan 2022 16:31:56 +0200
|
||
|
Subject: [PATCH] Client: Make sure mWaitingForUpdateDelivery updates are
|
||
|
thread-safe
|
||
|
|
||
|
Change-Id: I7e22fe49f679fb87d56bae0bc3c1d2c261ffe144
|
||
|
---
|
||
|
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
|
||
|
--- a/src/client/qwaylandwindow.cpp
|
||
|
+++ b/src/client/qwaylandwindow.cpp
|
||
|
@@ -638,22 +638,21 @@ void QWaylandWindow::handleFrameCallback()
|
||
|
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.
|
||
|
- mWaitingForUpdateDelivery = true;
|
||
|
QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
|
||
|
+ mWaitingForUpdateDelivery.storeRelease(true);
|
||
|
}
|
||
|
|
||
|
mFrameSyncWait.notify_all();
|
||
|
diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
|
||
|
index d45980a8..a8699827 100644
|
||
|
--- a/src/client/qwaylandwindow_p.h
|
||
|
+++ b/src/client/qwaylandwindow_p.h
|
||
|
@@ -228,7 +228,7 @@ protected:
|
||
|
WId mWindowId;
|
||
|
bool mWaitingForFrameCallback = false;
|
||
|
bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
|
||
|
- bool mWaitingForUpdateDelivery = false;
|
||
|
+ QAtomicInteger<bool> mWaitingForUpdateDelivery = false;
|
||
|
int mFrameCallbackCheckIntervalTimerId = -1;
|
||
|
QElapsedTimer mFrameCallbackElapsedTimer;
|
||
|
struct ::wl_callback *mFrameCallback = nullptr;
|
||
|
--
|
||
|
2.35.1
|
||
|
|