From c54ca6761df23867204795e80e7e82d7c3f1921f Mon Sep 17 00:00:00 2001 From: peterc-s Date: Tue, 22 Oct 2024 12:17:22 +0100 Subject: [PATCH] seems to fix segfault by not giving up control of the tty, shutting down when it's aready deferred could be the issue? --- src/animations/Doom.zig | 4 ++-- src/main.zig | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/animations/Doom.zig b/src/animations/Doom.zig index 0b8c824..9f8647e 100644 --- a/src/animations/Doom.zig +++ b/src/animations/Doom.zig @@ -97,9 +97,9 @@ pub fn draw(self: Doom) void { } fn initBuffer(buffer: []u8, width: usize) void { - const length = buffer.len - width; + const length = buffer.len; const slice_start = buffer[0..length]; - const slice_end = buffer[length..]; + const slice_end = buffer[length - width .. length]; @memset(slice_start, 0); @memset(slice_end, STEPS - 1); diff --git a/src/main.zig b/src/main.zig index bb52d16..cfc0050 100644 --- a/src/main.zig +++ b/src/main.zig @@ -317,9 +317,9 @@ pub fn main() !void { } } - var animation_timer = switch(config.animation) { + var animation_timer = switch (config.animation) { .none => undefined, - else => try std.time.Timer.start() + else => try std.time.Timer.start(), }; const animate = config.animation != .none; @@ -345,7 +345,6 @@ pub fn main() !void { try info_line.addMessage(lang.err_console_dev, config.error_bg, config.error_fg); }; - while (run) { // If there's no input or there's an animation, a resolution change needs to be checked if (!update or config.animation != .none) { @@ -706,7 +705,7 @@ pub fn main() !void { defer allocator.free(password_text); // Give up control on the TTY - _ = termbox.tb_shutdown(); + // _ = termbox.tb_shutdown(); session_pid = try std.posix.fork(); if (session_pid == 0) {