river: fix a few leaks

This commit is contained in:
Isaac Freund 2023-03-04 20:12:37 +01:00
parent 4d2f5bb32d
commit f5f9b526a0
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11
4 changed files with 8 additions and 0 deletions

View File

@ -89,6 +89,8 @@ fn handleDestroy(listener: *wl.Listener(*wlr.LayerSurfaceV1), _: *wlr.LayerSurfa
layer_surface.destroyPopups();
layer_surface.popup_tree.node.destroy();
util.gpa.destroy(layer_surface);
}

View File

@ -273,6 +273,7 @@ fn handleSurface(
assert(manager.lock != null);
LockSurface.create(wlr_lock_surface, manager.lock.?) catch {
log.err("out of memory", .{});
wlr_lock_surface.resource.postNoMemory();
};
}

View File

@ -37,6 +37,7 @@ surface_destroy: wl.Listener(void) = wl.Listener(void).init(handleDestroy),
pub fn create(wlr_lock_surface: *wlr.SessionLockSurfaceV1, lock: *wlr.SessionLockV1) error{OutOfMemory}!void {
const lock_surface = try util.gpa.create(LockSurface);
errdefer util.gpa.destroy(lock_surface);
lock_surface.* = .{
.wlr_lock_surface = wlr_lock_surface,
@ -46,6 +47,8 @@ pub fn create(wlr_lock_surface: *wlr.SessionLockSurfaceV1, lock: *wlr.SessionLoc
const output = lock_surface.getOutput();
const tree = try output.locked_content.createSceneSubsurfaceTree(wlr_lock_surface.surface);
errdefer tree.node.destroy();
try SceneNodeData.attach(&tree.node, .{ .lock_surface = lock_surface });
wlr_lock_surface.output.events.mode.add(&lock_surface.output_mode);

View File

@ -358,6 +358,8 @@ fn handleDestroy(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void {
output.mode.link.remove();
output.present.link.remove();
output.tree.node.destroy();
if (output.layout_namespace) |namespace| util.gpa.free(namespace);
output.wlr_output.data = 0;