drm-syncobj: fixup fd leak with timelines

This commit is contained in:
Vaxry 2024-08-07 16:08:50 +02:00
parent f36c625e37
commit 99e9cb5107
2 changed files with 6 additions and 0 deletions

View File

@ -114,6 +114,11 @@ CDRMSyncobjTimelineResource::CDRMSyncobjTimelineResource(SP<CWpLinuxDrmSyncobjTi
}
}
CDRMSyncobjTimelineResource::~CDRMSyncobjTimelineResource() {
if (fd >= 0)
close(fd);
}
SP<CDRMSyncobjTimelineResource> CDRMSyncobjTimelineResource::fromResource(wl_resource* res) {
auto data = (CDRMSyncobjTimelineResource*)(((CWpLinuxDrmSyncobjTimelineV1*)wl_resource_get_user_data(res))->data());
return data ? data->self.lock() : nullptr;

View File

@ -34,6 +34,7 @@ class CDRMSyncobjSurfaceResource {
class CDRMSyncobjTimelineResource {
public:
CDRMSyncobjTimelineResource(SP<CWpLinuxDrmSyncobjTimelineV1> resource_, int fd_);
~CDRMSyncobjTimelineResource();
static SP<CDRMSyncobjTimelineResource> fromResource(wl_resource*);
bool good();