Store QWaylandLayerShell using a QScopedPointer

This is to ensure that the QWaylandLayerShell will be eventually
destroyed.
This commit is contained in:
Vlad Zahorodnii 2021-04-20 18:29:09 +03:00 committed by Aleix Pol Gonzalez
parent 93f3ed2c07
commit 8d1aeb7bf1
2 changed files with 7 additions and 2 deletions

View file

@ -18,6 +18,10 @@ QWaylandLayerShellIntegration::QWaylandLayerShellIntegration()
{ {
} }
QWaylandLayerShellIntegration::~QWaylandLayerShellIntegration()
{
}
bool QWaylandLayerShellIntegration::initialize(QtWaylandClient::QWaylandDisplay *display) bool QWaylandLayerShellIntegration::initialize(QtWaylandClient::QWaylandDisplay *display)
{ {
QWaylandShellIntegration::initialize(display); QWaylandShellIntegration::initialize(display);
@ -35,7 +39,7 @@ void QWaylandLayerShellIntegration::registryLayer(void *data, struct wl_registry
QWaylandLayerShellIntegration *shell = static_cast<QWaylandLayerShellIntegration *>(data); QWaylandLayerShellIntegration *shell = static_cast<QWaylandLayerShellIntegration *>(data);
if (interface == zwlr_layer_shell_v1_interface.name) 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)));
} }
} }

View file

@ -21,6 +21,7 @@ class LAYERSHELLQT_EXPORT QWaylandLayerShellIntegration : public QtWaylandClient
{ {
public: public:
QWaylandLayerShellIntegration(); QWaylandLayerShellIntegration();
~QWaylandLayerShellIntegration() override;
bool initialize(QtWaylandClient::QWaylandDisplay *display) override; bool initialize(QtWaylandClient::QWaylandDisplay *display) override;
QtWaylandClient::QWaylandShellSurface *createShellSurface(QtWaylandClient::QWaylandWindow *window) override; QtWaylandClient::QWaylandShellSurface *createShellSurface(QtWaylandClient::QWaylandWindow *window) override;
@ -28,7 +29,7 @@ public:
private: private:
static void registryLayer(void *data, struct wl_registry *registry, uint32_t id, const QString &interface, uint32_t version); static void registryLayer(void *data, struct wl_registry *registry, uint32_t id, const QString &interface, uint32_t version);
QWaylandLayerShell *m_layerShell = nullptr; QScopedPointer<QWaylandLayerShell> m_layerShell;
}; };
} }