diff options
author | Ian Fan <[email protected]> | 2018-09-12 08:28:28 +0100 |
---|---|---|
committer | Ian Fan <[email protected]> | 2018-09-12 08:28:28 +0100 |
commit | 2eaef802061836dd83bbf753174fcb8488b2d8cd (patch) | |
tree | 33fcd285cc70a6cea257b1f3b6d24121d340a270 /swaybar/render.c | |
parent | af9e8f94cc0afb9f80e3902cbb83de78027cd737 (diff) |
i3bar: count references to blocks
This prevents blocks from being destroyed before their hotspots are destroyed,
in case it is used for a pending click event that fires between the bar
receiving a new status, which destroys the block, and the bar rendering the new
status, which destroys the hotspot; this problem can be easily produced by
scrolling on a block that immediately causes a new status to be sent, with
multiple outputs
Diffstat (limited to 'swaybar/render.c')
-rw-r--r-- | swaybar/render.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/swaybar/render.c b/swaybar/render.c index 7303e70f..2d848bfa 100644 --- a/swaybar/render.c +++ b/swaybar/render.c @@ -115,6 +115,10 @@ static enum hotspot_event_handling block_hotspot_callback(struct swaybar_output return i3bar_block_send_click(status, block, x, y, button); } +static void i3bar_block_unref_callback(void *data) { + i3bar_block_unref(data); +} + static uint32_t render_status_block(cairo_t *cairo, struct swaybar_config *config, struct swaybar_output *output, struct i3bar_block *block, double *x, @@ -179,8 +183,9 @@ static uint32_t render_status_block(cairo_t *cairo, hotspot->width = width; hotspot->height = height; hotspot->callback = block_hotspot_callback; - hotspot->destroy = NULL; + hotspot->destroy = i3bar_block_unref_callback; hotspot->data = block; + block->ref_count++; wl_list_insert(&output->hotspots, &hotspot->link); double pos = *x; |