output: destroy Layouts on Output removal

The Layout struct holds a pointer to the Output which becomes invalid
when the Output is destroyed so we must ensure all the layouts of an
Output are destroyed first.
This commit is contained in:
Isaac Freund
2021-06-09 20:03:19 +00:00
parent 2e7c1dbe6a
commit 88410cc2b8
3 changed files with 13 additions and 2 deletions

View File

@ -169,6 +169,10 @@ fn handleRequest(layout: *river.LayoutV2, request: river.LayoutV2.Request, self:
}
fn handleDestroy(layout: *river.LayoutV2, self: *Self) void {
self.destroy();
}
pub fn destroy(self: *Self) void {
log.debug(
"destroying layout '{s}' on output '{s}'",
.{ self.namespace, mem.sliceTo(&self.output.wlr_output.name, 0) },
@ -189,4 +193,6 @@ fn handleDestroy(layout: *river.LayoutV2, self: *Self) void {
util.gpa.free(self.namespace);
util.gpa.destroy(node);
self.layout.setHandler(?*c_void, handleRequestInert, null, null);
}