mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-27 19:30:54 +00:00
Fixed: Crash in CLuaManager
--HG-- branch : develop
This commit is contained in:
parent
a8d81c689b
commit
aa3d209d39
3 changed files with 22 additions and 5 deletions
|
@ -31,8 +31,8 @@ namespace NLGUI
|
|||
class CLuaManager
|
||||
{
|
||||
public:
|
||||
~CLuaManager();
|
||||
|
||||
/// Get or create singleton
|
||||
static CLuaManager& getInstance()
|
||||
{
|
||||
if( instance == NULL )
|
||||
|
@ -42,6 +42,9 @@ namespace NLGUI
|
|||
return *instance;
|
||||
}
|
||||
|
||||
/// Release singleton
|
||||
static void releaseInstance();
|
||||
|
||||
/// Enables attaching the Lua debugger in the CLuaState instance, only matters on startup.
|
||||
static void enableLuaDebugging(){ debugLua = true; }
|
||||
|
||||
|
@ -65,6 +68,7 @@ namespace NLGUI
|
|||
|
||||
private:
|
||||
CLuaManager();
|
||||
~CLuaManager();
|
||||
|
||||
static CLuaManager *instance;
|
||||
static bool debugLua;
|
||||
|
|
|
@ -33,8 +33,20 @@ namespace NLGUI
|
|||
|
||||
CLuaManager::~CLuaManager()
|
||||
{
|
||||
delete luaState;
|
||||
luaState = NULL;
|
||||
if (luaState)
|
||||
{
|
||||
delete luaState;
|
||||
luaState = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CLuaManager::releaseInstance()
|
||||
{
|
||||
if (instance)
|
||||
{
|
||||
delete instance;
|
||||
instance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool CLuaManager::executeLuaScript( const std::string &luaScript, bool smallScript )
|
||||
|
@ -60,7 +72,8 @@ namespace NLGUI
|
|||
|
||||
void CLuaManager::ResetLuaState()
|
||||
{
|
||||
delete luaState;
|
||||
if (luaState) delete luaState;
|
||||
|
||||
luaState = new CLuaState( debugLua );
|
||||
}
|
||||
|
||||
|
|
|
@ -659,7 +659,7 @@ void release()
|
|||
CInterfaceExpr::release();
|
||||
CPdrTokenRegistry::releaseInstance();
|
||||
NLNET::IModuleManager::releaseInstance();
|
||||
delete &CLuaManager::getInstance();
|
||||
CLuaManager::releaseInstance();
|
||||
NLGUI::CDBManager::release();
|
||||
CWidgetManager::release();
|
||||
|
||||
|
|
Loading…
Reference in a new issue