widget: unref callbacks on delete

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-10-26 14:26:44 +01:00
parent 20533e9443
commit c2da16332e
2 changed files with 16 additions and 13 deletions

View File

@ -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.
*/

View File

@ -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)