From 93f3ed2c0764571b4c812c3afe3c4d372d4262e2 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 20 Apr 2021 18:20:33 +0300 Subject: [PATCH] Fix a memory leak The dynamically allocated QtWayland::zwlr_layer_shell_v1 object in QWaylandLayerShellIntegration::registryLayer() isn't deleted anywhere. --- src/qwaylandlayershell.cpp | 4 ++-- src/qwaylandlayershell_p.h | 2 +- src/qwaylandlayershellintegration.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qwaylandlayershell.cpp b/src/qwaylandlayershell.cpp index 526e7b2..9c54abb 100644 --- a/src/qwaylandlayershell.cpp +++ b/src/qwaylandlayershell.cpp @@ -10,8 +10,8 @@ namespace LayerShellQt { -QWaylandLayerShell::QWaylandLayerShell(QtWayland::zwlr_layer_shell_v1 *shell) - : QtWayland::zwlr_layer_shell_v1(shell->object()) +QWaylandLayerShell::QWaylandLayerShell(::wl_registry *registry, uint32_t id, uint32_t version) + : QtWayland::zwlr_layer_shell_v1(registry, id, version) { } diff --git a/src/qwaylandlayershell_p.h b/src/qwaylandlayershell_p.h index 4a5810f..cf8ee6c 100644 --- a/src/qwaylandlayershell_p.h +++ b/src/qwaylandlayershell_p.h @@ -20,7 +20,7 @@ namespace LayerShellQt class LAYERSHELLQT_EXPORT QWaylandLayerShell : public QtWayland::zwlr_layer_shell_v1 { public: - QWaylandLayerShell(QtWayland::zwlr_layer_shell_v1 *shell); + QWaylandLayerShell(::wl_registry *registry, uint32_t id, uint32_t version); virtual ~QWaylandLayerShell(); QWaylandLayerSurface *createLayerSurface(QtWaylandClient::QWaylandWindow *window); diff --git a/src/qwaylandlayershellintegration.cpp b/src/qwaylandlayershellintegration.cpp index bb738f2..1793286 100644 --- a/src/qwaylandlayershellintegration.cpp +++ b/src/qwaylandlayershellintegration.cpp @@ -35,7 +35,7 @@ void QWaylandLayerShellIntegration::registryLayer(void *data, struct wl_registry QWaylandLayerShellIntegration *shell = static_cast(data); if (interface == zwlr_layer_shell_v1_interface.name) - shell->m_layerShell = new QWaylandLayerShell(new QtWayland::zwlr_layer_shell_v1(registry, id, std::min(version, 4u))); + shell->m_layerShell = new QWaylandLayerShell(registry, id, std::min(version, 4u)); } }