From bdece52341a54be99aa6ae2ede926ce72e663c31 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sat, 14 Nov 2015 19:53:01 +0000 Subject: MirLua: fixed CreateServiceFunction in m_core git-svn-id: http://svn.miranda-ng.org/main/trunk@15727 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/m_core.cpp | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/plugins/MirLua/src/m_core.cpp b/plugins/MirLua/src/m_core.cpp index cc26e6bab2..d0986da3c6 100644 --- a/plugins/MirLua/src/m_core.cpp +++ b/plugins/MirLua/src/m_core.cpp @@ -5,13 +5,14 @@ static int lua_CreateHookableEvent(lua_State *L) const char *name = luaL_checkstring(L, 1); HANDLE res = ::CreateHookableEvent(name); - if (res) + if (!res) { - lua_pushlightuserdata(L, res); - CMLua::Events.insert(res); - } - else lua_pushnil(L); + return 1; + } + + lua_pushlightuserdata(L, res); + CMLua::Events.insert(res); return 1; } @@ -66,19 +67,18 @@ static int lua_HookEvent(lua_State *L) int ref = luaL_ref(L, LUA_REGISTRYINDEX); HANDLE res = ::HookEventObjParam(name, HookEventObjParam, L, ref); - if (res) - { - CMLua::Hooks.insert(res); - CMLua::HookRefs.insert(new HandleRefParam(L, res, ref)); - - lua_pushlightuserdata(L, res); - } - else + if (!res) { luaL_unref(L, LUA_REGISTRYINDEX, ref); lua_pushnil(L); + return 1; } + CMLua::Hooks.insert(res); + CMLua::HookRefs.insert(new HandleRefParam(L, res, ref)); + + lua_pushlightuserdata(L, res); + return 1; } @@ -132,18 +132,17 @@ static int lua_CreateServiceFunction(lua_State *L) HANDLE res = ::CreateServiceFunctionObjParam(name, CreateServiceFunctionObjParam, L, ref); if (!res) - { - CMLua::Services.insert(res); - CMLua::ServiceRefs.insert(new HandleRefParam(L, res, ref)); - - lua_pushlightuserdata(L, res); - } - else { luaL_unref(L, LUA_REGISTRYINDEX, ref); lua_pushnil(L); + return 1; } + CMLua::Services.insert(res); + CMLua::ServiceRefs.insert(new HandleRefParam(L, res, ref)); + + lua_pushlightuserdata(L, res); + return 1; } -- cgit v1.2.3