mirror of
https://github.com/labwc/labwc.git
synced 2025-11-14 06:59:54 -05:00
img: remove "theme" member from lab_img
lab_img.theme member was referenced by "modifier" functions when drawing a hover effect on button buffers or rounding the button buffer for corner buttons, but this can be prone to use-after-free and was not very clean because theme and lab_img were referencing each other. Instead, let's just reference rc.theme in the modifier functions and remove theme from lab_img.
This commit is contained in:
parent
956b271f9b
commit
90a8c3e793
3 changed files with 15 additions and 20 deletions
|
|
@ -106,10 +106,8 @@ lab_img_copy(struct lab_img *img)
|
|||
}
|
||||
|
||||
void
|
||||
lab_img_add_modifier(struct lab_img *img, lab_img_modifier_func_t modifier,
|
||||
struct theme *theme)
|
||||
lab_img_add_modifier(struct lab_img *img, lab_img_modifier_func_t modifier)
|
||||
{
|
||||
img->theme = theme;
|
||||
lab_img_modifier_func_t *mod = wl_array_add(&img->modifiers, sizeof(*mod));
|
||||
*mod = modifier;
|
||||
}
|
||||
|
|
@ -185,7 +183,7 @@ lab_img_render(struct lab_img *img, int width, int height, int padding,
|
|||
lab_img_modifier_func_t *modifier;
|
||||
wl_array_for_each(modifier, &img->modifiers) {
|
||||
cairo_save(cairo);
|
||||
(*modifier)(img->theme, cairo, width, height);
|
||||
(*modifier)(cairo, width, height);
|
||||
cairo_restore(cairo);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue