fix: fully deinit keybind.Mode to avoid race when switching modes

This commit is contained in:
CJ van den Berg 2025-11-05 16:39:35 +01:00
parent 983e518f69
commit 8b50c7a3af
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 21 additions and 8 deletions

View file

@ -554,7 +554,7 @@ fn active_event_handler(self: *Self) ?EventHandler {
fn dispatch_flush_input_event(self: *Self) error{ Exit, NoSpaceLeft }!void {
var buf: [32]u8 = undefined;
const mode = self.input_mode_ orelse return;
try mode.input_handler.send(tp.self_pid(), try tp.message.fmtbuf(&buf, .{"F"}));
if (mode.input_handler) |ih| try ih.send(tp.self_pid(), try tp.message.fmtbuf(&buf, .{"F"}));
if (mode.event_handler) |eh| try eh.send(tp.self_pid(), try tp.message.fmtbuf(&buf, .{"F"}));
}
@ -577,8 +577,8 @@ fn dispatch_input(ctx: *anyopaque, cbor_msg: []const u8) void {
break :ret false;
})
return;
if (self.input_mode_) |mode|
mode.input_handler.send(from, m) catch |e| self.logger.err("input handler", e);
if (self.input_mode_) |mode| if (mode.input_handler) |ih|
ih.send(from, m) catch |e| self.logger.err("input handler", e);
}
fn dispatch_mouse(ctx: *anyopaque, y: c_int, x: c_int, cbor_msg: []const u8) void {