Update "AnyUserData::take" to work on ref thread without need to push into stack.

This commit is contained in:
Alex Orlenko
2025-05-28 12:13:34 +01:00
parent 76a8f8cc71
commit 2fefaafaa6
4 changed files with 31 additions and 40 deletions
+2 -2
View File
@@ -455,9 +455,9 @@ pub(crate) unsafe extern "C" fn collect_userdata<T>(
// It checks if the userdata is safe to destroy and sets the "destroyed" metatable
// to prevent further GC collection.
pub(super) unsafe extern "C-unwind" fn destroy_userdata_storage<T>(state: *mut ffi::lua_State) -> c_int {
let ud = get_userdata::<UserDataStorage<T>>(state, -1);
let ud = get_userdata::<UserDataStorage<T>>(state, 1);
if (*ud).is_safe_to_destroy() {
take_userdata::<UserDataStorage<T>>(state);
take_userdata::<UserDataStorage<T>>(state, 1);
ffi::lua_pushboolean(state, 1);
} else {
ffi::lua_pushboolean(state, 0);