fix: crash in home screen

Button click handlers may delete the button, so we should not touch self after
calling them.
This commit is contained in:
CJ van den Berg 2025-10-30 21:30:13 +01:00
parent a0fa079a13
commit 932c79fb13
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -133,9 +133,9 @@ fn State(ctx_type: type) type {
}
return true;
} else if (try m.match(.{ "B", input.event.release, tp.extract(&btn), tp.any, tp.extract(&x), tp.extract(&y), tp.any, tp.any })) {
self.call_click_handler(@enumFromInt(btn), self.to_rel_cursor(x, y));
self.drag_anchor = null;
self.drag_pos = null;
self.call_click_handler(@enumFromInt(btn), self.to_rel_cursor(x, y));
tui.need_render();
return true;
} else if (try m.match(.{ "D", input.event.press, tp.extract(&btn), tp.any, tp.extract(&x), tp.extract(&y), tp.any, tp.any })) {
@ -150,9 +150,9 @@ fn State(ctx_type: type) type {
self.active = false;
h.send(from, m) catch {};
}
self.call_click_handler(@enumFromInt(btn), self.to_rel_cursor(x, y));
self.drag_anchor = null;
self.drag_pos = null;
self.call_click_handler(@enumFromInt(btn), self.to_rel_cursor(x, y));
tui.need_render();
return true;
} else if (try m.match(.{ "H", tp.extract(&self.hover) })) {