0 may be a valid function, LUA_REFNIL is what we want.

Also don't forget to unref the function on deletion.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Pierre Habouzit 2008-06-26 13:06:55 +02:00 committed by Julien Danjou
parent 086bada825
commit d45590fbcc
2 changed files with 2 additions and 1 deletions

View File

@ -409,7 +409,7 @@ event_handle_keypress(void *data __attribute__ ((unused)),
else
{
keybinding_t *k = keybinding_find(&globalconf.keys, ev);
if (k && k->fct)
if (k && k->fct != LUA_REFNIL)
luaA_dofunction(globalconf.L, k->fct, 0);
}

View File

@ -41,6 +41,7 @@ void keybinding_idx_wipe(keybinding_idx_t *idx)
void keybinding_delete(keybinding_t **kbp)
{
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, (*kbp)->fct);
p_delete(kbp);
}