[server] Destroy created Surface/Region when ClientConnection goes away

Resources might not be properly destroyed if an application crashes and
doesn't call destroy.
This commit is contained in:
Martin Gräßlin 2015-06-18 03:16:29 +02:00
parent c0d78d5aa1
commit 441856a0e6

View file

@ -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);
}