From cb0bc20b38bed1531ba685960b1b4d5ded302cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 9 May 2019 19:14:29 +0200 Subject: [PATCH] bar: destroy modules in destroy(), not at the end of run() This ensures we properly destroy everything when a bar has been instantiated, but not run(). --- bar/bar.c | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/bar/bar.c b/bar/bar.c index f59ed7a..44d70fa 100644 --- a/bar/bar.c +++ b/bar/bar.c @@ -306,31 +306,6 @@ run(struct bar *_bar) LOG_DBG("modules joined"); - for (size_t i = 0; i < bar->left.count; i++) { - struct module *m = bar->left.mods[i]; - struct exposable *e = bar->left.exps[i]; - - if (e != NULL) - e->destroy(e); - m->destroy(m); - } - for (size_t i = 0; i < bar->center.count; i++) { - struct module *m = bar->center.mods[i]; - struct exposable *e = bar->center.exps[i]; - - if (e != NULL) - e->destroy(e); - m->destroy(m); - } - for (size_t i = 0; i < bar->right.count; i++) { - struct module *m = bar->right.mods[i]; - struct exposable *e = bar->right.exps[i]; - - if (e != NULL) - e->destroy(e); - m->destroy(m); - } - bar->backend.iface->cleanup(_bar); if (bar->cairo) @@ -340,7 +315,6 @@ run(struct bar *_bar) cairo_surface_finish(bar->cairo_surface); cairo_surface_destroy(bar->cairo_surface); } - cairo_debug_reset_static_data(); LOG_DBG("bar exiting"); return ret; @@ -351,6 +325,33 @@ destroy(struct bar *bar) { struct private *b = bar->private; + for (size_t i = 0; i < b->left.count; i++) { + struct module *m = b->left.mods[i]; + struct exposable *e = b->left.exps[i]; + + if (e != NULL) + e->destroy(e); + m->destroy(m); + } + for (size_t i = 0; i < b->center.count; i++) { + struct module *m = b->center.mods[i]; + struct exposable *e = b->center.exps[i]; + + if (e != NULL) + e->destroy(e); + m->destroy(m); + } + for (size_t i = 0; i < b->right.count; i++) { + struct module *m = b->right.mods[i]; + struct exposable *e = b->right.exps[i]; + + if (e != NULL) + e->destroy(e); + m->destroy(m); + } + + cairo_debug_reset_static_data(); + free(b->left.mods); free(b->left.exps); free(b->center.mods);