From a8d35b3c18bdb05a0da3ed50a554a7b7bd4ebed3 Mon Sep 17 00:00:00 2001
From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Date: Mon, 30 Nov 2020 13:13:18 +0100
Subject: [PATCH 10/36] Fix leaked subsurface wayland items
Whenever a subsurface was added we would create a QWaylandQuickItem,
but this was never deleted. It is one-to-one with the surface, so it
should be deleted at the same time.
[ChangeLog][QtWaylandCompositor] Fixed a memory leak when creating
subsurfaces.
Task-number: QTBUG-88782
Change-Id: If4b3f15200ce3bd123ff73847d3593d174a39229
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
(cherry picked from commit 38fc568b30bf916165324c2cd2db127d2a9aa68c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
---
src/compositor/compositor_api/qwaylandquickitem.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp
index 15f0195c..2218f43a 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.cpp
+++ b/src/compositor/compositor_api/qwaylandquickitem.cpp
@@ -737,6 +737,7 @@ void QWaylandQuickItem::handleSubsurfaceAdded(QWaylandSurface *childSurface)
childItem->setVisible(true);
childItem->setParentItem(this);
connect(childSurface, &QWaylandSurface::subsurfacePositionChanged, childItem, &QWaylandQuickItem::handleSubsurfacePosition);
+ connect(childSurface, &QWaylandSurface::destroyed, childItem, &QObject::deleteLater);
} else {
bool success = QMetaObject::invokeMethod(d->subsurfaceHandler, "handleSubsurfaceAdded", Q_ARG(QWaylandSurface *, childSurface));
if (!success)
--
2.33.1