From 8d1aeb7bf1122e83eb73569707a4c24fc1d51833 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 20 Apr 2021 18:29:09 +0300 Subject: [PATCH] Store QWaylandLayerShell using a QScopedPointer This is to ensure that the QWaylandLayerShell will be eventually destroyed. --- src/qwaylandlayershellintegration.cpp | 6 +++++- src/qwaylandlayershellintegration_p.h | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/qwaylandlayershellintegration.cpp b/src/qwaylandlayershellintegration.cpp index 1793286..230f3be 100644 --- a/src/qwaylandlayershellintegration.cpp +++ b/src/qwaylandlayershellintegration.cpp @@ -18,6 +18,10 @@ QWaylandLayerShellIntegration::QWaylandLayerShellIntegration() { } +QWaylandLayerShellIntegration::~QWaylandLayerShellIntegration() +{ +} + bool QWaylandLayerShellIntegration::initialize(QtWaylandClient::QWaylandDisplay *display) { QWaylandShellIntegration::initialize(display); @@ -35,7 +39,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(registry, id, std::min(version, 4u)); + shell->m_layerShell.reset(new QWaylandLayerShell(registry, id, std::min(version, 4u))); } } diff --git a/src/qwaylandlayershellintegration_p.h b/src/qwaylandlayershellintegration_p.h index 5150b22..2df4206 100644 --- a/src/qwaylandlayershellintegration_p.h +++ b/src/qwaylandlayershellintegration_p.h @@ -21,6 +21,7 @@ class LAYERSHELLQT_EXPORT QWaylandLayerShellIntegration : public QtWaylandClient { public: QWaylandLayerShellIntegration(); + ~QWaylandLayerShellIntegration() override; bool initialize(QtWaylandClient::QWaylandDisplay *display) override; QtWaylandClient::QWaylandShellSurface *createShellSurface(QtWaylandClient::QWaylandWindow *window) override; @@ -28,7 +29,7 @@ public: private: static void registryLayer(void *data, struct wl_registry *registry, uint32_t id, const QString &interface, uint32_t version); - QWaylandLayerShell *m_layerShell = nullptr; + QScopedPointer m_layerShell; }; }