From 441856a0e6a91a8a0b54b5a0f839b23aaff773b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 18 Jun 2015 03:16:29 +0200 Subject: [PATCH] [server] Destroy created Surface/Region when ClientConnection goes away Resources might not be properly destroyed if an application crashes and doesn't call destroy. --- src/wayland/compositor_interface.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/wayland/compositor_interface.cpp b/src/wayland/compositor_interface.cpp index 59fa274191..3035a65f5f 100644 --- a/src/wayland/compositor_interface.cpp +++ b/src/wayland/compositor_interface.cpp @@ -102,6 +102,14 @@ void CompositorInterface::Private::createSurface(wl_client *client, wl_resource delete surface; return; } + QObject::connect(surface->client(), &ClientConnection::disconnected, surface, + [surface] (ClientConnection *c) { + if (surface->resource()) { + wl_resource_destroy(surface->resource()); + delete surface; + } + } + ); emit q->surfaceCreated(surface); } @@ -119,6 +127,14 @@ void CompositorInterface::Private::createRegion(wl_client *client, wl_resource * delete region; return; } + QObject::connect(region->client(), &ClientConnection::disconnected, region, + [region] (ClientConnection *c) { + if (region->resource()) { + wl_resource_destroy(region->resource()); + delete region; + } + } + ); emit q->regionCreated(region); }