parent
c4ae23938d
commit
78951ce42e
|
@ -52,14 +52,9 @@ fn Prototype(comptime Self: type) type {
|
|||
return self;
|
||||
}
|
||||
|
||||
/// Free the widget's resources. Will call an implementation's deinit
|
||||
/// and deinit on all children.
|
||||
/// Free the widget's resources. Will call an implementation's deinit function.
|
||||
/// A widget must ensure to call deinit on all its children!
|
||||
pub fn deinit(self: *Self) void {
|
||||
for (self.children()) |child| {
|
||||
// TODO: call child.deinit() here
|
||||
// see: https://github.com/ziglang/zig/issues/17872
|
||||
deinit(child);
|
||||
}
|
||||
_ = statspatch.implcallOptional(self, .ptr, "deinit", void, .{self});
|
||||
if (self.data.attreebutes) |*map| map.deinit(self.data.allocator);
|
||||
self.data.allocator.destroy(self);
|
||||
|
|
|
@ -50,6 +50,9 @@ pub fn init(alloc: std.mem.Allocator, direction: Direction) !*Widget {
|
|||
}
|
||||
|
||||
pub fn deinit(self: *Box, selfw: *Widget) void {
|
||||
for (self.children.items(.widget)) |child| {
|
||||
child.deinit();
|
||||
}
|
||||
self.children.deinit(selfw.data.allocator);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue