diff options
author | aunsane <aunsane@gmail.com> | 2017-09-02 20:56:39 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2017-09-02 20:56:39 +0300 |
commit | bf3a7231bf7f977591c80a7dca44035dfbf9c376 (patch) | |
tree | 9f7c0748496bc995a73e4474a64d39b20d0c8b95 /plugins/MirLua/src/m_clist.cpp | |
parent | fbe8725b4f270dbd5981b0ed642fc52da4405cea (diff) |
MirLua: return nil if something went wroing in m_clist and m_genmenu
Diffstat (limited to 'plugins/MirLua/src/m_clist.cpp')
-rw-r--r-- | plugins/MirLua/src/m_clist.cpp | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/plugins/MirLua/src/m_clist.cpp b/plugins/MirLua/src/m_clist.cpp index 7620ef9e9e..d5d8d76a10 100644 --- a/plugins/MirLua/src/m_clist.cpp +++ b/plugins/MirLua/src/m_clist.cpp @@ -7,18 +7,26 @@ static int clist_AddMainMenuRoot(lua_State *L) HANDLE hIcon = (HANDLE)lua_touserdata(L, 3);
HGENMENU res = Menu_CreateRoot(MO_MAIN, ptrW(Utf8DecodeW(name)), position, hIcon);
- lua_pushlightuserdata(L, res);
+ if (res != nullptr)
+ lua_pushlightuserdata(L, res);
+ else
+ lua_pushnil(L);
return 1;
}
static int clist_AddMainMenuItem(lua_State *L)
{
+ luaL_checktype(L, 1, LUA_TTABLE);
+
CMenuItem mi;
MakeMenuItem(L, mi);
HGENMENU res = Menu_AddMainMenuItem(&mi);
- lua_pushlightuserdata(L, res);
+ if (res != nullptr)
+ lua_pushlightuserdata(L, res);
+ else
+ lua_pushnil(L);
return 1;
}
@@ -30,36 +38,43 @@ static int clist_AddContactMenuRoot(lua_State *L) HANDLE hIcon = (HANDLE)lua_touserdata(L, 3);
HGENMENU res = Menu_CreateRoot(MO_MAIN, ptrW(Utf8DecodeW(name)), position, hIcon);
- lua_pushlightuserdata(L, res);
+ if (res != nullptr)
+ lua_pushlightuserdata(L, res);
+ else
+ lua_pushnil(L);
return 1;
}
static int clist_AddContactMenuItem(lua_State *L)
{
+ luaL_checktype(L, 1, LUA_TTABLE);
+
CMenuItem mi;
MakeMenuItem(L, mi);
ptrA szProto(mir_utf8decodeA(lua_tostring(L, 2)));
HGENMENU res = Menu_AddContactMenuItem(&mi, szProto);
- lua_pushlightuserdata(L, res);
+ if (res != nullptr)
+ lua_pushlightuserdata(L, res);
+ else
+ lua_pushnil(L);
return 1;
}
static int clist_AddTrayMenuItem(lua_State *L)
{
- if (!lua_istable(L, 1))
- {
- lua_pushlightuserdata(L, 0);
- return 1;
- }
+ luaL_checktype(L, 1, LUA_TTABLE);
CMenuItem mi;
MakeMenuItem(L, mi);
HGENMENU res = Menu_AddTrayMenuItem(&mi);
- lua_pushlightuserdata(L, res);
+ if (res != nullptr)
+ lua_pushlightuserdata(L, res);
+ else
+ lua_pushnil(L);
return 1;
}
|