Added Lua index registry clear routine to `destroy` method of classes that use it.
If this is left to GC, the abandoned userdata would stay in memory for one full extra cycle.

Prettified the code slightly. Clarified some comments. Refactored `Fixture` class `udata` name.
Removed Reference class include from `Shape` (it doesn't use it).
This commit is contained in:
raidho36
2017-04-14 05:53:36 +03:00
parent bc8783869e
commit 6b7172bd40
9 changed files with 71 additions and 22 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ Reference::~Reference()
void Reference::ref(lua_State *L)
{
unref(); // Just to be safe.
unref(); // Previously created reference needs to be cleared
pinnedL = luax_getpinnedthread(L);
luax_insist(L, LUA_REGISTRYINDEX, REFERENCE_TABLE_NAME);
lua_insert(L, -2); // Move reference table behind value.