From ee37779cc2bdb12315b962af3df2501fdcc68089 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Fri, 24 Jun 2016 17:43:57 +0000 Subject: temporary revert git-svn-id: http://svn.miranda-ng.org/main/trunk@17032 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/mlua.cpp | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'plugins/MirLua/src/mlua.cpp') diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp index bea7645bbf..2c67f32f3e 100644 --- a/plugins/MirLua/src/mlua.cpp +++ b/plugins/MirLua/src/mlua.cpp @@ -2,6 +2,9 @@ int hMLuaLangpack; +LIST CMLua::HookRefs(1, HandleKeySortT); +LIST CMLua::ServiceRefs(1, HandleKeySortT); + static int CompareScripts(const CMLuaScript* p1, const CMLuaScript* p2) { return mir_strcmpi(p1->GetModuleName(), p2->GetModuleName()); @@ -80,7 +83,7 @@ void CMLua::Unload() { CMLuaScript *script = g_mLua->Scripts[last - 1]; Scripts.remove(script); - script->Unload(L); + script->Unload(); delete script; } @@ -89,8 +92,33 @@ void CMLua::Unload() KillModuleMenus(hMLuaLangpack); KillModuleHotkeys(hMLuaLangpack); - KillObjectEventHooks(this); - KillObjectServices(this); + KillObjectEventHooks(L); + KillObjectServices(L); lua_close(L); } + +void CMLua::KillLuaRefs() +{ + while (HookRefs.getCount()) + { + HandleRefParam *param = (HandleRefParam*)HookRefs[0]; + if (param != NULL) + { + luaL_unref(param->L, LUA_REGISTRYINDEX, param->ref); + HookRefs.remove(0); + delete param; + } + } + + while (ServiceRefs.getCount()) + { + HandleRefParam *param = (HandleRefParam*)ServiceRefs[0]; + if (param != NULL) + { + luaL_unref(param->L, LUA_REGISTRYINDEX, param->ref); + ServiceRefs.remove(0); + delete param; + } + } +} -- cgit v1.2.3