Don't crash when fn key pressed on mac (workaround upstream issue)

This commit is contained in:
Mitchell Hashimoto
2022-11-22 08:45:09 -08:00
parent acdbdfbe3f
commit 9ae2df7bae

View File

@ -194,6 +194,16 @@ pub fn log(
fn glfwErrorCallback(code: glfw.Error, desc: [:0]const u8) void { fn glfwErrorCallback(code: glfw.Error, desc: [:0]const u8) void {
std.log.warn("glfw error={} message={s}", .{ code, desc }); 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 { test {