i spent hours debugging a arraylist shenanigan

This commit is contained in:
RadsammyT 2026-03-25 19:04:22 -04:00
commit e82972f3db
No known key found for this signature in database

View file

@ -1082,10 +1082,14 @@ pub fn main() !void {
defer state.custom_info.deinit(state.allocator);
var lblIter = custom.labels.iterator();
// NOTE: Because widgets have a pointer to the underlying Label, we have to ensure
// that the ArrayList doesn't allocate more memory than what we ensured. Otherwise
// the pointer to the Label becomes invalid.
try state.custom_info.ensureTotalCapacity(state.allocator, @intCast(custom.labels.count()));
while (lblIter.next()) |i| {
try state.custom_info.append(state.allocator, .{
.info = i.value_ptr.*,
.lbl = .init("", null, state.buffer.fg, state.buffer.bg, &updateCustomInfo, null),
.lbl = .init("", null, state.buffer.fg, state.buffer.bg, updateCustomInfo, null),
});
var latest = &state.custom_info.items[state.custom_info.items.len - 1];
latest.info.id = latest.lbl.widget().id;