MeasureScript: Fixed memory leak when DynamicVariables=1.

This commit is contained in:
spx
2011-01-30 15:39:14 +00:00
parent a69e2e91d2
commit e4944fa99f
4 changed files with 122 additions and 89 deletions

View File

@ -12,7 +12,7 @@
#include "lua_rainmeter_ext.h"
bool LuaManager::m_bInitialized = false;
int LuaManager::m_RefCount = 0;
lua_State* LuaManager::m_pState = 0;
void LuaManager::Init()
@ -35,11 +35,22 @@ void LuaManager::Init()
luaopen_rainmeter_ext(m_pState);
}
++m_RefCount;
}
void LuaManager::CleanUp()
{
lua_close(m_pState);
if (m_RefCount > 0)
{
--m_RefCount;
}
if (m_RefCount == 0 && m_pState != 0)
{
lua_close(m_pState);
m_pState = 0;
}
}
void LuaManager::ReportErrors(lua_State * L)

View File

@ -20,7 +20,7 @@ public:
protected:
static bool m_bInitialized;
static int m_RefCount;
static lua_State* m_pState;
};