feat: items with arc instead of arena

This commit is contained in:
2025-05-25 10:31:58 +02:00
parent 4a9dc12b48
commit 5cfb556dff
4 changed files with 76 additions and 38 deletions

View File

@@ -124,8 +124,15 @@ const Model = struct {
defer vm.app_common_model.current_items.mutex.unlock();
break :blk2 if (vm.app_common_model.current_items.data) |items| blk: {
const children = try ctx.arena.alloc(*vxfw.Text, items.len);
for (0.., items[0..children.len]) |i, child| {
const children = try ctx.arena.create(std.ArrayList(*vxfw.Text));
children.* = std.ArrayList(*vxfw.Text).init(ctx.arena);
// const children = try ctx.arena.alloc(*vxfw.Text, items.len);
for (0.., items) |i, *weak_child| {
const arc_child = weak_child.upgrade() orelse continue;
defer if (arc_child.releaseUnwrap()) |item| item.deinit();
const child = arc_child.value.*;
const is_active = i == vm.current_items_view.cursor;
const fg, const bg = colors: {
@@ -162,14 +169,18 @@ const Model = struct {
},
};
children[i] = text_element;
// children[i] = text_element;
try children.append(text_element);
}
break :blk children;
} else &.{};
} else {
vm.current_items_view.children.slice = &.{};
return;
};
};
const widgets = try ctx.arena.alloc(vxfw.Widget, text_items.len);
for (text_items, 0..) |t, i| {
const widgets = try ctx.arena.alloc(vxfw.Widget, text_items.items.len);
for (text_items.items, 0..) |t, i| {
widgets[i] = t.widget();
}