Fixed: Crash in CLuaManager
This commit is contained in:
parent
c27e1062e4
commit
75a28a149b
3 changed files with 22 additions and 5 deletions
|
@ -31,8 +31,8 @@ namespace NLGUI
|
||||||
class CLuaManager
|
class CLuaManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~CLuaManager();
|
|
||||||
|
|
||||||
|
/// Get or create singleton
|
||||||
static CLuaManager& getInstance()
|
static CLuaManager& getInstance()
|
||||||
{
|
{
|
||||||
if( instance == NULL )
|
if( instance == NULL )
|
||||||
|
@ -42,6 +42,9 @@ namespace NLGUI
|
||||||
return *instance;
|
return *instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Release singleton
|
||||||
|
static void releaseInstance();
|
||||||
|
|
||||||
/// Enables attaching the Lua debugger in the CLuaState instance, only matters on startup.
|
/// Enables attaching the Lua debugger in the CLuaState instance, only matters on startup.
|
||||||
static void enableLuaDebugging(){ debugLua = true; }
|
static void enableLuaDebugging(){ debugLua = true; }
|
||||||
|
|
||||||
|
@ -65,6 +68,7 @@ namespace NLGUI
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CLuaManager();
|
CLuaManager();
|
||||||
|
~CLuaManager();
|
||||||
|
|
||||||
static CLuaManager *instance;
|
static CLuaManager *instance;
|
||||||
static bool debugLua;
|
static bool debugLua;
|
||||||
|
|
|
@ -32,10 +32,22 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
CLuaManager::~CLuaManager()
|
CLuaManager::~CLuaManager()
|
||||||
|
{
|
||||||
|
if (luaState)
|
||||||
{
|
{
|
||||||
delete luaState;
|
delete luaState;
|
||||||
luaState = NULL;
|
luaState = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLuaManager::releaseInstance()
|
||||||
|
{
|
||||||
|
if (instance)
|
||||||
|
{
|
||||||
|
delete instance;
|
||||||
|
instance = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool CLuaManager::executeLuaScript( const std::string &luaScript, bool smallScript )
|
bool CLuaManager::executeLuaScript( const std::string &luaScript, bool smallScript )
|
||||||
{
|
{
|
||||||
|
@ -60,7 +72,8 @@ namespace NLGUI
|
||||||
|
|
||||||
void CLuaManager::ResetLuaState()
|
void CLuaManager::ResetLuaState()
|
||||||
{
|
{
|
||||||
delete luaState;
|
if (luaState) delete luaState;
|
||||||
|
|
||||||
luaState = new CLuaState( debugLua );
|
luaState = new CLuaState( debugLua );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -659,7 +659,7 @@ void release()
|
||||||
CInterfaceExpr::release();
|
CInterfaceExpr::release();
|
||||||
CPdrTokenRegistry::releaseInstance();
|
CPdrTokenRegistry::releaseInstance();
|
||||||
NLNET::IModuleManager::releaseInstance();
|
NLNET::IModuleManager::releaseInstance();
|
||||||
delete &CLuaManager::getInstance();
|
CLuaManager::releaseInstance();
|
||||||
NLGUI::CDBManager::release();
|
NLGUI::CDBManager::release();
|
||||||
CWidgetManager::release();
|
CWidgetManager::release();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue