diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-11-14 19:53:01 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-11-14 19:53:01 +0000 |
commit | bdece52341a54be99aa6ae2ede926ce72e663c31 (patch) | |
tree | 2546c31b914ac3b8dd12e12cc858ce9fe2daa3ed /plugins | |
parent | 63691b42d4b0e3b47869183470a2b752f3667f39 (diff) |
MirLua: fixed CreateServiceFunction in m_core
git-svn-id: http://svn.miranda-ng.org/main/trunk@15727 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/MirLua/src/m_core.cpp | 39 |
1 files 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;
}
@@ -133,17 +133,16 @@ 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;
}
|