[lua] Correctly call PropertiesIterator destructor using its __gc

This was detected by MSVC with its _ITERATOR_DEBUG_LEVEL=2 where
orphan iterators are detected when the map/container is destroyed.
This commit is contained in:
David Capello 2023-01-02 17:05:08 -03:00
parent 9f0491ddb6
commit 11dbb22efa

View File

@ -150,6 +150,12 @@ int Properties_pairs(lua_State* L)
return 2;
}
int PropertiesIterator_gc(lua_State* L)
{
get_obj<PropertiesIterator>(L, 1)->~PropertiesIterator();
return 0;
}
const luaL_Reg Properties_methods[] = {
{ "__len", Properties_len },
{ "__index", Properties_index },
@ -159,6 +165,7 @@ const luaL_Reg Properties_methods[] = {
};
const luaL_Reg PropertiesIterator_methods[] = {
{ "__gc", PropertiesIterator_gc },
{ nullptr, nullptr }
};