From bef0f305cf8fff67023c6ae93c6fd92a63ba301c Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Mon, 24 Aug 2020 17:48:58 +0100 Subject: [PATCH] Delete resources in XdgOutput teardown Generated code typically cleans up resource objects when the client calls the relevant destructor. In multi-cast mode our wrapper can be deleted at any time, whilst a client resource exists any existing resources that have a pending message will then crash the compositor. Deleting resources ahead of time also resolves this. calls to this resource will no-op. The zxdg_output_v1::destroy_func will then be called to delete the Resource object. --- src/wayland/xdgoutput_v1_interface.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/wayland/xdgoutput_v1_interface.cpp b/src/wayland/xdgoutput_v1_interface.cpp index 1e2f9ae69c..0eee238b92 100644 --- a/src/wayland/xdgoutput_v1_interface.cpp +++ b/src/wayland/xdgoutput_v1_interface.cpp @@ -107,7 +107,19 @@ XdgOutputV1Interface::XdgOutputV1Interface(QObject *parent) } XdgOutputV1Interface::~XdgOutputV1Interface() -{} +{ + // Generated code typically cleans up resource objects when the client calls the relevant destructor + // In multi-cast mode our wrapper can be deleted at any time whilst a client resource exists. + // any existing resources that have a pending message will then crash the compositor. + + // Deleting resources ahead of time also resolves this. calls to this resource will no-op + const QMultiMap resourceMap = d->resourceMap(); + for (auto resource : resourceMap) + { + wl_resource_destroy(resource->handle); + } + +} void XdgOutputV1Interface::setLogicalSize(const QSize &size) {