From cd19a4615b822ab85ebe1430ec956f6b22f3d008 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sat, 18 Apr 2020 12:21:43 +0200 Subject: Properly clean up resources on exit --- src/output.zig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/output.zig') diff --git a/src/output.zig b/src/output.zig index e951fe3..bb88156 100644 --- a/src/output.zig +++ b/src/output.zig @@ -101,6 +101,20 @@ pub const Output = struct { } } + pub fn deinit(self: *Self) void { + for (self.layers) |*layer| { + while (layer.pop()) |layer_surface_node| { + self.root.server.allocator.destroy(layer_surface_node); + } + } + + while (self.views.first) |node| { + node.view.deinit(); + self.views.remove(node); + self.root.server.allocator.destroy(node); + } + } + /// Add a new view to the output. arrangeViews() will be called by the view /// when it is mapped. pub fn addView(self: *Self, wlr_xdg_surface: *c.wlr_xdg_surface) void { -- cgit v1.2.3