From 1a02247a7b6913b45bf81331c3e0ab9a374d04e8 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Thu, 23 Jun 2016 14:47:00 +0000 Subject: MirLua: fix previous commit git-svn-id: http://svn.miranda-ng.org/main/trunk@17024 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/m_core.cpp | 26 ++++---------------------- plugins/MirLua/src/mlua.cpp | 4 ++-- 2 files changed, 6 insertions(+), 24 deletions(-) (limited to 'plugins') diff --git a/plugins/MirLua/src/m_core.cpp b/plugins/MirLua/src/m_core.cpp index 8d388bf8c7..1b4bc8d390 100644 --- a/plugins/MirLua/src/m_core.cpp +++ b/plugins/MirLua/src/m_core.cpp @@ -18,7 +18,7 @@ static int core_CreateHookableEvent(lua_State *L) int HookEventObjParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param) { - lua_State *L = (lua_State*)obj; + lua_State *L = lua_newthread((lua_State*)obj); int ref = param; lua_rawgeti(L, LUA_REGISTRYINDEX, ref); @@ -46,9 +46,7 @@ static int core_HookEvent(lua_State *L) lua_pushvalue(L, 2); int ref = luaL_ref(L, LUA_REGISTRYINDEX); - lua_State *T = lua_newthread(L); - - HANDLE hEvent = HookEventObjParam(name, HookEventObjParam, T, ref); + HANDLE hEvent = HookEventObjParam(name, HookEventObjParam, g_mLua, ref); if (hEvent == NULL) { luaL_unref(L, LUA_REGISTRYINDEX, ref); @@ -57,9 +55,6 @@ static int core_HookEvent(lua_State *L) return 1; } - lua_rawsetp(L, LUA_REGISTRYINDEX, hEvent); - lua_pushlightuserdata(L, hEvent); - return 1; } @@ -69,11 +64,6 @@ static int core_UnhookEvent(lua_State *L) HANDLE hEvent = lua_touserdata(L, 1); int res = UnhookEvent(hEvent); - if (!res) - { - lua_pushnil(L); - lua_rawsetp(L, LUA_REGISTRYINDEX, hEvent); - } lua_pushboolean(L, !res); return 1; @@ -107,7 +97,7 @@ static int core_DestroyHookableEvent(lua_State *L) INT_PTR CreateServiceFunctionObjParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param) { - lua_State *L = (lua_State*)obj; + lua_State *L = lua_newthread((lua_State*)obj); int ref = param; lua_rawgeti(L, LUA_REGISTRYINDEX, ref); @@ -130,9 +120,7 @@ static int core_CreateServiceFunction(lua_State *L) lua_pushvalue(L, 2); int ref = luaL_ref(L, LUA_REGISTRYINDEX); - lua_State *T = lua_newthread(L); - - HANDLE hService = CreateServiceFunctionObjParam(name, CreateServiceFunctionObjParam, T, ref); + HANDLE hService = CreateServiceFunctionObjParam(name, CreateServiceFunctionObjParam, g_mLua, ref); if (!hService) { luaL_unref(L, LUA_REGISTRYINDEX, ref); @@ -140,9 +128,6 @@ static int core_CreateServiceFunction(lua_State *L) return 1; } - lua_rawsetp(L, LUA_REGISTRYINDEX, hService); - lua_pushlightuserdata(L, hService); - return 1; } @@ -175,9 +160,6 @@ static int core_DestroyServiceFunction(lua_State *L) DestroyServiceFunction(hService); - lua_pushnil(L); - lua_rawsetp(L, LUA_REGISTRYINDEX, hService); - return 0; } diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp index afe49d0f31..bea7645bbf 100644 --- a/plugins/MirLua/src/mlua.cpp +++ b/plugins/MirLua/src/mlua.cpp @@ -89,8 +89,8 @@ void CMLua::Unload() KillModuleMenus(hMLuaLangpack); KillModuleHotkeys(hMLuaLangpack); - KillObjectEventHooks(L); - KillObjectServices(L); + KillObjectEventHooks(this); + KillObjectServices(this); lua_close(L); } -- cgit v1.2.3