lua: check for ref value before getting them
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
862fe193ee
commit
a5640330d9
6
mouse.c
6
mouse.c
|
@ -1186,10 +1186,16 @@ luaA_button_index(lua_State *L)
|
|||
switch(a_tokenize(attr, len))
|
||||
{
|
||||
case A_TK_PRESS:
|
||||
if((*button)->press != LUA_REFNIL)
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, (*button)->press);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
break;
|
||||
case A_TK_RELEASE:
|
||||
if((*button)->release != LUA_REFNIL)
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, (*button)->release);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
break;
|
||||
case A_TK_BUTTON:
|
||||
/* works fine, but not *really* neat */
|
||||
|
|
6
wibox.c
6
wibox.c
|
@ -712,9 +712,12 @@ static bool
|
|||
luaA_wibox_hasitem(lua_State *L, wibox_t *wibox, const void *item)
|
||||
{
|
||||
bool ret = false;
|
||||
if(wibox->widgets_table != LUA_REFNIL)
|
||||
{
|
||||
lua_rawgeti(globalconf.L, LUA_REGISTRYINDEX, wibox->widgets_table);
|
||||
if(lua_topointer(L, -1) == item || luaA_hasitem(L, item))
|
||||
ret = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -814,7 +817,10 @@ luaA_wibox_index(lua_State *L)
|
|||
lua_pushstring(L, orientation_tostr((*wibox)->sw.orientation));
|
||||
break;
|
||||
case A_TK_WIDGETS:
|
||||
if((*wibox)->widgets_table != LUA_REFNIL)
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, (*wibox)->widgets_table);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
|
6
widget.c
6
widget.c
|
@ -397,10 +397,16 @@ luaA_widget_index(lua_State *L)
|
|||
lua_pushstring(L, (*widget)->name);
|
||||
return 1;
|
||||
case A_TK_MOUSE_ENTER:
|
||||
if((*widget)->mouse_enter != LUA_REFNIL)
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, (*widget)->mouse_enter);
|
||||
else
|
||||
return 0;
|
||||
return 1;
|
||||
case A_TK_MOUSE_LEAVE:
|
||||
if((*widget)->mouse_leave != LUA_REFNIL)
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, (*widget)->mouse_leave);
|
||||
else
|
||||
return 0;
|
||||
return 1;
|
||||
default:
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue