Blame SOURCES/0033-Client-Always-destroy-frame-callback-in-the-actual-c.patch

147f94
From efe6edcaf8eba601dff99ec6ad4457c8a4442f86 Mon Sep 17 00:00:00 2001
147f94
From: Georges Basile Stavracas Neto <gbsneto@gnome.org>
147f94
Date: Thu, 27 May 2021 20:02:53 -0300
147f94
Subject: [PATCH 33/36] Client: Always destroy frame callback in the actual
147f94
 callback
147f94
147f94
It's good hygiene to destroy all frame callbacks. Destroy the
147f94
frame callback and cleanup the mFrameCallback class member in
147f94
the callback itself. The callback destruction happens before
147f94
calling handleFrameCallback() to avoid the theoretical case
147f94
where another frame callback is queued by handleFrameCallback(),
147f94
and then immediately destroyed in the callback handler.
147f94
147f94
* asturmlechner 2021-09-27:
147f94
  Conflict resolved from non-backported commit in dev branch:
147f94
  93058de8d7e7c2f320c22b3bd898aa06cf5babcd
147f94
147f94
Change-Id: Ide6dc95e3402932c58bfc088a9d471fda821e9a1
147f94
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
147f94
(cherry picked from commit 42cdc61a93cf2acb09936aebb5e431fdbc0a26c6)
147f94
---
147f94
 src/client/qwaylandwindow.cpp | 11 +++++------
147f94
 1 file changed, 5 insertions(+), 6 deletions(-)
147f94
147f94
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
147f94
index 85307875..c020a58f 100644
147f94
--- a/src/client/qwaylandwindow.cpp
147f94
+++ b/src/client/qwaylandwindow.cpp
147f94
@@ -622,9 +622,13 @@ void QWaylandWindow::commit()
147f94
 
147f94
 const wl_callback_listener QWaylandWindow::callbackListener = {
147f94
     [](void *data, wl_callback *callback, uint32_t time) {
147f94
-        Q_UNUSED(callback);
147f94
         Q_UNUSED(time);
147f94
         auto *window = static_cast<QWaylandWindow*>(data);
147f94
+
147f94
+        Q_ASSERT(callback == window->mFrameCallback);
147f94
+        wl_callback_destroy(callback);
147f94
+        window->mFrameCallback = nullptr;
147f94
+
147f94
         window->handleFrameCallback();
147f94
     }
147f94
 };
147f94
@@ -1179,11 +1183,6 @@ void QWaylandWindow::handleUpdate()
147f94
     if (!mSurface)
147f94
         return;
147f94
 
147f94
-    if (mFrameCallback) {
147f94
-        wl_callback_destroy(mFrameCallback);
147f94
-        mFrameCallback = nullptr;
147f94
-    }
147f94
-
147f94
     QMutexLocker locker(mFrameQueue.mutex);
147f94
     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
147f94
     wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
147f94
-- 
147f94
2.33.1
147f94