>From c36cdefac255e878231a941ef2e5283df9d9bc7e Mon Sep 17 00:00:00 2001 From: David Palacio Date: Wed, 19 Oct 2011 14:19:46 -0500 Subject: [PATCH] Let the Lua VM take care of cleaning the environment --- src/qtluastate.cc | 47 ----------------------------------------------- 1 files changed, 0 insertions(+), 47 deletions(-) diff --git a/src/qtluastate.cc b/src/qtluastate.cc index 8cd85c6..ccb8510 100644 --- a/src/qtluastate.cc +++ b/src/qtluastate.cc @@ -510,53 +510,6 @@ State::State() State::~State() { - // clear all global variables - while (1) - { - lua_pushnil(_st); - if (!lua_next(_st, LUA_GLOBALSINDEX)) - break; - lua_pop(_st, 1); - lua_pushnil(_st); - lua_rawset(_st, LUA_GLOBALSINDEX); - } - - gc_collect(); - - // wipe remaining QObjectWrapper objects - wrapper_hash_t::const_iterator i; - - while ((i = _whash.begin()) != _whash.end()) - i.value()->_drop(); - -#ifndef QTLUA_NO_DEBUG - // check for existing Value objects - lua_pushlightuserdata(_st, &_key_this); - lua_pushnil(_st); - lua_rawset(_st, LUA_REGISTRYINDEX); - - lua_pushlightuserdata(_st, &_key_item_metatable); - lua_pushnil(_st); - lua_rawset(_st, LUA_REGISTRYINDEX); - - bool bad = false; - - lua_pushnil(_st); - while (lua_next(_st, LUA_REGISTRYINDEX)) - { - if (lua_islightuserdata(_st, -2)) - { - qCritical("QtLua::Value<%s> at %p still refers to lua state being free'd.", - lua_typename(_st, -1), lua_touserdata(_st, -2)); - bad = true; - } - lua_pop(_st, 1); - } - - if (bad) - abort(); -#endif - lua_close(_st); } -- 1.7.7