fix: prevent Widget.msg and EventHandler.msg from being corrupted by thespian.message.send

This commit is contained in:
CJ van den Berg 2025-10-28 21:58:33 +01:00
parent 3e4a604739
commit d6e9cec04d
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 6 additions and 3 deletions

View file

@ -108,7 +108,8 @@ pub fn dynamic_cast(self: Self, comptime T: type) ?*T {
}
pub fn msg(self: Self, m: anytype) tp.result {
return self.vtable.send(self.ptr, tp.self_pid(), tp.message.fmt(m));
var buf: [tp.max_message_size]u8 = undefined;
return self.vtable.send(self.ptr, tp.self_pid(), tp.message.fmtbuf(&buf, m) catch |e| std.debug.panic("EventHandler.msg: {any}", .{e}));
}
pub fn send(self: Self, from_: tp.pid_ref, m: tp.message) tp.result {
@ -172,7 +173,8 @@ pub const List = struct {
}
pub fn msg(self: *const List, m: anytype) tp.result {
return self.send(tp.self_pid(), tp.message.fmt(m));
var buf: [tp.max_message_size]u8 = undefined;
return self.send(tp.self_pid(), tp.message.fmtbuf(&buf, m) catch |e| std.debug.panic("EventHandler.List.msg: {any}", .{e}));
}
pub fn send(self: *const List, from: tp.pid_ref, m: tp.message) tp.result {

View file

@ -178,7 +178,8 @@ pub fn deinit(self: Self, allocator: Allocator) void {
}
pub fn msg(self: *const Self, m: anytype) error{Exit}!bool {
return self.vtable.send(self.ptr, tp.self_pid(), tp.message.fmt(m));
var buf: [tp.max_message_size]u8 = undefined;
return self.vtable.send(self.ptr, tp.self_pid(), tp.message.fmtbuf(&buf, m) catch |e| std.debug.panic("Widget.msg: {any}", .{e}));
}
pub fn send(self: *const Self, from_: tp.pid_ref, m: tp.message) error{Exit}!bool {