diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-06-18 09:13:44 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-06-18 09:13:44 -0400 |
commit | 6bbd39f54a71a1d223c6e74b47c6b0cf9f72eb7e (patch) | |
tree | fdb3df84b454dc4bced320249528154da953ae7d /indra/newview/llmanip.cpp | |
parent | aff78224a026bbf17e6ac4818228c0e1814c4226 (diff) |
lua_emplace<T>() should permit GC despite LL.atexit() safety net.
lua_emplace<T>() was passing LL.atexit() a closure binding the new userdata
with a cleanup function. The trouble with that was that a strong reference to
the new userdata would prevent it ever being garbage collected, even if that
was the only remaining reference.
Instead, create a new weak table referencing the userdata, and bind that into
the cleanup function's closure. Then if the only remaining reference to the
userdata is from the weak table, the userdata can be collected.
Make lua_emplace_call_gc<T>() check the bound weak table in case the userdata
has in fact been collected.
Also, in lua_toclass<T>(), use luaL_checkudata() to synopsize comparing the
putative userdata's metatable against the one synthesized by lua_emplace<T>().
This saves several explicit steps.
Diffstat (limited to 'indra/newview/llmanip.cpp')
0 files changed, 0 insertions, 0 deletions