summaryrefslogtreecommitdiff
path: root/dev-qt/qtwayland/files/qtwayland-5.12.4-client-make-handleupdate-aware-of-exposure-changes.patch
blob: 6aacad2a942ee73fd17f08974166be5573611b49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
From b13b595dc4f4fe6bdca7b69a21fd934ee233e149 Mon Sep 17 00:00:00 2001
From: David Edmundson <davidedmundson@kde.org>
Date: Sun, 23 Jun 2019 14:48:30 +0200
Subject: [PATCH] Client: Make handleUpdate aware of exposure changes

The wl_surface can be destroyed whilst a render is happening. Calling
wl_surface::frame after the window is reset can crash as wl_surface is
null.

Change-Id: I139a9b234cb6acba81d6c1d5fa58629904a25053
---
 src/client/qwaylandwindow.cpp | 10 +++++++++-
 src/client/qwaylandwindow_p.h |  4 ++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index 5ea0dce1e..7e7a4929c 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -79,6 +79,8 @@ Q_LOGGING_CATEGORY(lcWaylandBackingstore, "qt.qpa.wayland.backingstore")
 
 QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
 
+QReadWriteLock mSurfaceLock;
+
 QWaylandWindow::QWaylandWindow(QWindow *window)
     : QPlatformWindow(window)
     , mDisplay(waylandScreen()->display())
@@ -210,6 +212,7 @@ void QWaylandWindow::initWindow()
 
 void QWaylandWindow::initializeWlSurface()
 {
+    QWriteLocker lock(&mSurfaceLock);
     init(mDisplay->createSurface(static_cast<QtWayland::wl_surface *>(this)));
 }
 
@@ -245,8 +248,10 @@ void QWaylandWindow::reset(bool sendDestroyEvent)
     mShellSurface = nullptr;
     delete mSubSurfaceWindow;
     mSubSurfaceWindow = nullptr;
-    if (isInitialized())
+    if (isInitialized()) {
+        QWriteLocker lock(&mSurfaceLock);
         destroy();
+    }
     mScreens.clear();
 
     if (mFrameCallback) {
@@ -1145,6 +1150,9 @@ void QWaylandWindow::requestUpdate()
 void QWaylandWindow::handleUpdate()
 {
     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+    QReadLocker lock(&mSurfaceLock);
+    if (!isInitialized())
+        return;
 
     if (mFrameCallback) {
         wl_callback_destroy(mFrameCallback);
diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
index e8c9d5684..d3706442f 100644
--- a/src/client/qwaylandwindow_p.h
+++ b/src/client/qwaylandwindow_p.h
@@ -53,6 +53,8 @@
 
 #include <QtCore/QWaitCondition>
 #include <QtCore/QMutex>
+#include <QtCore/QReadWriteLock>
+
 #include <QtGui/QIcon>
 #include <QtCore/QVariant>
 #include <QtCore/QLoggingCategory>
@@ -271,6 +273,8 @@ private:
     static QMutex mFrameSyncMutex;
     static QWaylandWindow *mMouseGrab;
 
+    QReadWriteLock mSurfaceLock;
+
     friend class QWaylandSubSurface;
 };
 
-- 
2.16.3