Skip to content

Commit 2114910

Browse files
committed
Remove drop field from ValueRef
1 parent 74bebe6 commit 2114910

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

src/state/raw.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ impl RawLua {
489489
#[cfg(feature = "luau")]
490490
ffi::lua_resetthread(thread_state);
491491
extra.thread_pool.push(thread.0.index);
492-
thread.0.drop = false;
492+
thread.0.index = 0; // Prevent reference from being dropped
493493
return true;
494494
}
495495
false

src/types.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ pub(crate) struct DestructedUserdata;
115115
pub(crate) struct ValueRef {
116116
pub(crate) lua: WeakLua,
117117
pub(crate) index: c_int,
118-
pub(crate) drop: bool,
119118
}
120119

121120
impl ValueRef {
@@ -124,7 +123,6 @@ impl ValueRef {
124123
ValueRef {
125124
lua: lua.weak().clone(),
126125
index,
127-
drop: true,
128126
}
129127
}
130128

@@ -149,7 +147,7 @@ impl Clone for ValueRef {
149147

150148
impl Drop for ValueRef {
151149
fn drop(&mut self) {
152-
if self.drop {
150+
if self.index > 0 {
153151
if let Some(lua) = self.lua.try_lock() {
154152
unsafe { lua.drop_ref(self) };
155153
}

0 commit comments

Comments
 (0)