Blame SOURCES/0024-Client-Disconnect-registry-listener-on-destruction.patch

6f97c1
From 1b5e43a593e917610e6245f7a272ac081c508ba4 Mon Sep 17 00:00:00 2001
6f97c1
From: David Edmundson <davidedmundson@kde.org>
6f97c1
Date: Fri, 14 May 2021 13:23:24 +0100
147f94
Subject: [PATCH 24/36] Client: Disconnect registry listener on destruction
6f97c1
6f97c1
If a display outlives a QWaylandClientExtension and a new global is
6f97c1
announced we end up delivering an event to a now deleted extension which
6f97c1
will crash.
6f97c1
6f97c1
Change-Id: Idc0de40be61a2f7627ab4963e1fe29b22fbf3f04
6f97c1
(cherry picked from commit c4ba37cd2f8cb81b9438b56ac604fc2f3e45083c)
6f97c1
---
6f97c1
 src/client/global/qwaylandclientextension.cpp | 7 +++++++
6f97c1
 src/client/global/qwaylandclientextension.h   | 1 +
6f97c1
 2 files changed, 8 insertions(+)
6f97c1
6f97c1
diff --git a/src/client/global/qwaylandclientextension.cpp b/src/client/global/qwaylandclientextension.cpp
6f97c1
index 125b1e19..797b06fe 100644
6f97c1
--- a/src/client/global/qwaylandclientextension.cpp
6f97c1
+++ b/src/client/global/qwaylandclientextension.cpp
6f97c1
@@ -88,6 +88,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
6f97c1
     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
6f97c1
 }
6f97c1
 
6f97c1
+QWaylandClientExtension::~QWaylandClientExtension()
6f97c1
+{
6f97c1
+    Q_D(QWaylandClientExtension);
6f97c1
+    if (d->registered && !QCoreApplication::closingDown())
6f97c1
+        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
6f97c1
+}
6f97c1
+
6f97c1
 QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
6f97c1
 {
6f97c1
     Q_D(const QWaylandClientExtension);
6f97c1
diff --git a/src/client/global/qwaylandclientextension.h b/src/client/global/qwaylandclientextension.h
6f97c1
index 98272e57..5bd28398 100644
6f97c1
--- a/src/client/global/qwaylandclientextension.h
6f97c1
+++ b/src/client/global/qwaylandclientextension.h
6f97c1
@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
6f97c1
     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
6f97c1
 public:
6f97c1
     QWaylandClientExtension(const int version);
6f97c1
+    ~QWaylandClientExtension();
6f97c1
 
6f97c1
     QtWaylandClient::QWaylandIntegration *integration() const;
6f97c1
     int version() const;
6f97c1
-- 
147f94
2.33.1
6f97c1