renderer/termio attach thread local state for crash capture

This commit is contained in:
Mitchell Hashimoto
2024-09-01 10:59:19 -07:00
parent f0916d58e8
commit 8f477b00da
3 changed files with 19 additions and 10 deletions

View File

@@ -5,6 +5,7 @@ pub const Thread = @This();
const std = @import("std");
const builtin = @import("builtin");
const xev = @import("xev");
const crash = @import("../crash/main.zig");
const renderer = @import("../renderer.zig");
const apprt = @import("../apprt.zig");
const configpkg = @import("../config.zig");
@@ -191,6 +192,12 @@ pub fn threadMain(self: *Thread) void {
fn threadMain_(self: *Thread) !void {
defer log.debug("renderer thread exited", .{});
// Setup our crash metadata
crash.sentry.thread_state = .{
.surface = self.renderer.surface_mailbox.surface,
};
defer crash.sentry.thread_state = null;
// Run our loop start/end callbacks if the renderer cares.
const has_loop = @hasDecl(renderer.Renderer, "loopEnter");
if (has_loop) try self.renderer.loopEnter(self);