From d45590fbcc83c2cfd933990c59bde9164dc5200e Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Thu, 26 Jun 2008 13:06:55 +0200 Subject: [PATCH] 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 Signed-off-by: Julien Danjou --- event.c | 2 +- keybinding.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/event.c b/event.c index 676c96ba5..27cb8f234 100644 --- a/event.c +++ b/event.c @@ -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); } diff --git a/keybinding.c b/keybinding.c index 7a16121df..c34065ef5 100644 --- a/keybinding.c +++ b/keybinding.c @@ -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); }