I use the LuaScriptModule of CEGUI in my code:
Code: Select all
CEGUI::LuaScriptModule& scriptmod(CEGUI::LuaScriptModule::create());
m_pLuaState = scriptmod.getLuaState();
m_pGUISystem->setScriptingModule(&scriptmod);
and I also have a LuaScriptManager which I use it for get the global datas from lua and explosing C++ class to lua.
I also want the CEGUI lua feature which is easy to code GUI Event in lua script.
so I pass the lua_state from CEGUI to LuaScriptManager, like this:
Code: Select all
IMPLEMENT_SINGLETON(LuaScriptManager)
//--------------------------------------------------------------------------------------------------------
LuaScriptManager::LuaScriptManager()
{
m_pLuaState = UISystem::GetSingleton().GetLuaState();
luaL_openlibs(m_pLuaState);
}
//--------------------------------------------------------------------------------------------------------
LuaScriptManager::~LuaScriptManager()
{
lua_close(m_pLuaState);
}
The problem is : when I call the LuaScriptManager:DestructSingleton() which calls the ~LuaScriptManager() the program crash and a "debug assertion failed" dialog appeared. So I was wondering if something going wrong in the lua_state* pointer. Does CEGUI destroy the lua_state automatically so I just can't use it after it's done?
If I don't LuaScriptManager's destructor it works fine, and the CEGUI log says:
Code: Select all
---- Destroying Lua bindings ----
Does it mean lua_state* is closed?
Appreciate any advice!