mirror of
https://codeberg.org/fairyglade/ly.git
synced 2026-08-20 20:44:19 +02:00
i spent hours debugging a arraylist shenanigan
This commit is contained in:
parent
54cc513fa1
commit
e82972f3db
1 changed files with 5 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue