Actually unref scope created types from the registry AS WELL AS destructing them
This commit is contained in:
parent
84b009da03
commit
514abd5b82
|
@ -1080,6 +1080,8 @@ impl<'lua, 'scope> Scope<'lua, 'scope> {
|
|||
ffi::LUA_REGISTRYINDEX,
|
||||
registry_id as ffi::lua_Integer,
|
||||
);
|
||||
ffi::luaL_unref(state, ffi::LUA_REGISTRYINDEX, registry_id);
|
||||
|
||||
ffi::lua_getupvalue(state, -1, 1);
|
||||
let ud = take_userdata::<RefCell<Callback>>(state);
|
||||
|
||||
|
@ -1109,6 +1111,7 @@ impl<'lua, 'scope> Scope<'lua, 'scope> {
|
|||
ffi::LUA_REGISTRYINDEX,
|
||||
registry_id as ffi::lua_Integer,
|
||||
);
|
||||
ffi::luaL_unref(state, ffi::LUA_REGISTRYINDEX, registry_id);
|
||||
Box::new(take_userdata::<RefCell<T>>(state))
|
||||
}));
|
||||
Ok(u)
|
||||
|
|
|
@ -614,6 +614,7 @@ fn scope_func() {
|
|||
.unwrap();
|
||||
lua.globals().set("bad", f.clone()).unwrap();
|
||||
f.call::<_, ()>(()).unwrap();
|
||||
assert_eq!(Rc::strong_count(&rc), 2);
|
||||
});
|
||||
assert_eq!(rc.get(), 42);
|
||||
assert_eq!(Rc::strong_count(&rc), 1);
|
||||
|
|
Loading…
Reference in New Issue