From 8b2d067196073dcfb674b8d337db84ebb44676ea Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Tue, 2 Jul 2024 23:45:45 +0100 Subject: [PATCH] Fix `Lua::set_vector_metatable` --- src/lua.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lua.rs b/src/lua.rs index b3e4113..8baefea 100644 --- a/src/lua.rs +++ b/src/lua.rs @@ -1739,8 +1739,9 @@ impl Lua { #[cfg(any(all(feature = "luau", feature = "unstable"), doc))] #[cfg_attr(docsrs, doc(cfg(all(feature = "luau", feature = "unstable"))))] pub fn set_vector_metatable(&self, metatable: Option) { + let lua = self.lock(); unsafe { - let state = self.state(); + let state = lua.state(); let _sg = StackGuard::new(state); assert_stack(state, 2); @@ -1749,7 +1750,7 @@ impl Lua { #[cfg(feature = "luau-vector4")] ffi::lua_pushvector(state, 0., 0., 0., 0.); match metatable { - Some(metatable) => self.push_ref(&metatable.0), + Some(metatable) => lua.push_ref(&metatable.0), None => ffi::lua_pushnil(state), }; ffi::lua_setmetatable(state, -2);