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
10
mouse.c
10
mouse.c
|
@ -1186,10 +1186,16 @@ luaA_button_index(lua_State *L)
|
||||||
switch(a_tokenize(attr, len))
|
switch(a_tokenize(attr, len))
|
||||||
{
|
{
|
||||||
case A_TK_PRESS:
|
case A_TK_PRESS:
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, (*button)->press);
|
if((*button)->press != LUA_REFNIL)
|
||||||
|
lua_rawgeti(L, LUA_REGISTRYINDEX, (*button)->press);
|
||||||
|
else
|
||||||
|
lua_pushnil(L);
|
||||||
break;
|
break;
|
||||||
case A_TK_RELEASE:
|
case A_TK_RELEASE:
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, (*button)->release);
|
if((*button)->release != LUA_REFNIL)
|
||||||
|
lua_rawgeti(L, LUA_REGISTRYINDEX, (*button)->release);
|
||||||
|
else
|
||||||
|
lua_pushnil(L);
|
||||||
break;
|
break;
|
||||||
case A_TK_BUTTON:
|
case A_TK_BUTTON:
|
||||||
/* works fine, but not *really* neat */
|
/* works fine, but not *really* neat */
|
||||||
|
|
16
wibox.c
16
wibox.c
|
@ -712,9 +712,12 @@ static bool
|
||||||
luaA_wibox_hasitem(lua_State *L, wibox_t *wibox, const void *item)
|
luaA_wibox_hasitem(lua_State *L, wibox_t *wibox, const void *item)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
lua_rawgeti(globalconf.L, LUA_REGISTRYINDEX, wibox->widgets_table);
|
if(wibox->widgets_table != LUA_REFNIL)
|
||||||
if(lua_topointer(L, -1) == item || luaA_hasitem(L, item))
|
{
|
||||||
ret = true;
|
lua_rawgeti(globalconf.L, LUA_REGISTRYINDEX, wibox->widgets_table);
|
||||||
|
if(lua_topointer(L, -1) == item || luaA_hasitem(L, item))
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -814,8 +817,11 @@ luaA_wibox_index(lua_State *L)
|
||||||
lua_pushstring(L, orientation_tostr((*wibox)->sw.orientation));
|
lua_pushstring(L, orientation_tostr((*wibox)->sw.orientation));
|
||||||
break;
|
break;
|
||||||
case A_TK_WIDGETS:
|
case A_TK_WIDGETS:
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, (*wibox)->widgets_table);
|
if((*wibox)->widgets_table != LUA_REFNIL)
|
||||||
break;
|
lua_rawgeti(L, LUA_REGISTRYINDEX, (*wibox)->widgets_table);
|
||||||
|
else
|
||||||
|
lua_pushnil(L);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
10
widget.c
10
widget.c
|
@ -397,10 +397,16 @@ luaA_widget_index(lua_State *L)
|
||||||
lua_pushstring(L, (*widget)->name);
|
lua_pushstring(L, (*widget)->name);
|
||||||
return 1;
|
return 1;
|
||||||
case A_TK_MOUSE_ENTER:
|
case A_TK_MOUSE_ENTER:
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, (*widget)->mouse_enter);
|
if((*widget)->mouse_enter != LUA_REFNIL)
|
||||||
|
lua_rawgeti(L, LUA_REGISTRYINDEX, (*widget)->mouse_enter);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
case A_TK_MOUSE_LEAVE:
|
case A_TK_MOUSE_LEAVE:
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, (*widget)->mouse_leave);
|
if((*widget)->mouse_leave != LUA_REFNIL)
|
||||||
|
lua_rawgeti(L, LUA_REGISTRYINDEX, (*widget)->mouse_leave);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue