From 9ae2df7bae2dc3d9dd2a145c2272e3282c0fdb6c Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 22 Nov 2022 08:45:09 -0800 Subject: [PATCH] Don't crash when fn key pressed on mac (workaround upstream issue) --- src/main.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main.zig b/src/main.zig index b67dd5d53..13fd654b1 100644 --- a/src/main.zig +++ b/src/main.zig @@ -194,6 +194,16 @@ pub fn log( fn glfwErrorCallback(code: glfw.Error, desc: [:0]const u8) void { std.log.warn("glfw error={} message={s}", .{ code, desc }); + + // Workaround for: https://github.com/ocornut/imgui/issues/5908 + // If we get an invalid value with "scancode" in the message we assume + // it is from the glfw key callback that imgui sets and we clear the + // error so that our future code doesn't crash. + if (code == glfw.Error.InvalidValue and + std.mem.indexOf(u8, desc, "scancode") != null) + { + glfw.errors.getError() catch {}; + } } test {