widget: unref callbacks on delete
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
20533e9443
commit
c2da16332e
16
widget.c
16
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.
|
||||
*/
|
||||
|
|
13
widget.h
13
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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue