From b2daa2acb3dfcedb09b13ce3e158c405f680c71d Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 13 Jun 2008 23:59:51 +0200 Subject: [PATCH] mouse: garbage collector for mouse objects Signed-off-by: Julien Danjou --- mouse.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mouse.c b/mouse.c index b5efbe982..852e4fb0d 100644 --- a/mouse.c +++ b/mouse.c @@ -875,6 +875,17 @@ luaA_mouse_new(lua_State *L) return luaA_mouse_userdata_new(button); } +/** Handle mouse garbage collection. + */ +static int +luaA_mouse_gc(lua_State *L) +{ + button_t **b = luaA_checkudata(L, 1, "mouse"); + button_unref(b); + *b = NULL; + return 0; +} + const struct luaL_reg awesome_mouse_methods[] = { { "new", luaA_mouse_new }, @@ -884,6 +895,7 @@ const struct luaL_reg awesome_mouse_methods[] = }; const struct luaL_reg awesome_mouse_meta[] = { + { "__gc", luaA_mouse_gc }, { NULL, NULL } };