summaryrefslogtreecommitdiff
path: root/src/client/qwaylandwindow.cpp
diff options
context:
space:
mode:
authorGeorges Basile Stavracas Neto <gbsneto@gnome.org>2021-05-27 20:02:53 -0300
committerGeorges Basile Stavracas Neto <gbsneto@gnome.org>2021-09-27 02:38:50 -0300
commit42cdc61a93cf2acb09936aebb5e431fdbc0a26c6 (patch)
tree4bf0ec37037585dae6b13777793679391696452d /src/client/qwaylandwindow.cpp
parentcbc74ba6d7186457d8d07183272e952dee5f34f9 (diff)
downloadqtwayland-42cdc61a93cf2acb09936aebb5e431fdbc0a26c6.tar.gz
Client: Always destroy frame callback in the actual callback
It's good hygiene to destroy all frame callbacks. Destroy the frame callback and cleanup the mFrameCallback class member in the callback itself. The callback destruction happens before calling handleFrameCallback() to avoid the theoretical case where another frame callback is queued by handleFrameCallback(), and then immediately destroyed in the callback handler. Change-Id: Ide6dc95e3402932c58bfc088a9d471fda821e9a1 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/client/qwaylandwindow.cpp')
-rw-r--r--src/client/qwaylandwindow.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index d83d5169..5561f58f 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -659,9 +659,13 @@ void QWaylandWindow::commit()
const wl_callback_listener QWaylandWindow::callbackListener = {
[](void *data, wl_callback *callback, uint32_t time) {
- Q_UNUSED(callback);
Q_UNUSED(time);
auto *window = static_cast<QWaylandWindow*>(data);
+
+ Q_ASSERT(callback == window->mFrameCallback);
+ wl_callback_destroy(callback);
+ window->mFrameCallback = nullptr;
+
window->handleFrameCallback();
}
};
@@ -1366,14 +1370,6 @@ void QWaylandWindow::handleUpdate()
if (!mSurface)
return;
- if (mFrameCallback) {
- if (!isExposed())
- return;
-
- wl_callback_destroy(mFrameCallback);
- mFrameCallback = nullptr;
- }
-
QMutexLocker locker(mFrameQueue.mutex);
struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);