From c2da16332e8d2c5514a459039f1c8045b73ba52f Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sun, 26 Oct 2008 14:26:44 +0100 Subject: [PATCH] widget: unref callbacks on delete Signed-off-by: Julien Danjou --- widget.c | 16 +++++++++++++++- widget.h | 13 +------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/widget.c b/widget.c index 24177f58..c77a8176 100644 --- a/widget.c +++ b/widget.c @@ -37,6 +37,21 @@ DO_LUA_EQ(widget_t, widget, "widget") #include "widgetgen.h" +/** Delete a widget structure. + * \param widget The widget to destroy. + */ +void +widget_delete(widget_t **widget) +{ + if((*widget)->destructor) + (*widget)->destructor(*widget); + button_array_wipe(&(*widget)->buttons); + luaL_unref(globalconf.L, LUA_REGISTRYINDEX, (*widget)->mouse_enter); + luaL_unref(globalconf.L, LUA_REGISTRYINDEX, (*widget)->mouse_leave); + p_delete(&(*widget)->name); + p_delete(widget); +} + /** Compute offset for drawing the first pixel of a widget. * \param barwidth The wibox width. * \param widgetwidth The widget width. @@ -274,7 +289,6 @@ widget_render(widget_node_array_t *widgets, draw_context_t *ctx, xcb_gcontext_t } } - /** Common function for creating a widget. * \param widget The allocated widget. */ diff --git a/widget.h b/widget.h index 746b7587..ef834a07 100644 --- a/widget.h +++ b/widget.h @@ -34,18 +34,7 @@ struct widget_node_t area_t geometry; }; -/** Delete a widget structure. - * \param widget The widget to destroy. - */ -static inline void -widget_delete(widget_t **widget) -{ - if((*widget)->destructor) - (*widget)->destructor(*widget); - button_array_wipe(&(*widget)->buttons); - p_delete(&(*widget)->name); - p_delete(widget); -} +void widget_delete(widget_t **); DO_RCNT(widget_t, widget, widget_delete)