From b2c9c386d9e1d87f52a361b87b28e0dbe2656d42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 9 Jan 2019 18:45:31 +0100 Subject: [PATCH] bar: make sure modules (and particles and fonts!) are destroyed before cleanup Before shutting down and destroying cairo and XCB, make sure the modules, particles and fonts have been destroyed. I.e. move module destruction from bar's destroy() to the end of bar's run() --- bar.c | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/bar.c b/bar.c index c90921f..d2963db 100644 --- a/bar.c +++ b/bar.c @@ -676,6 +676,31 @@ run(struct bar_run_context *run_ctx) LOG_DBG("modules joined"); + for (size_t i = 0; i < bar->left.count; i++) { + struct module *m = bar->left.mods[i]; + struct module_expose_context *e = &bar->left.exps[i]; + + if (e->exposable != NULL) + m->end_expose(m, e); + m->destroy(m); + } + for (size_t i = 0; i < bar->center.count; i++) { + struct module *m = bar->center.mods[i]; + struct module_expose_context *e = &bar->center.exps[i]; + + if (e->exposable != NULL) + m->end_expose(m, e); + m->destroy(m); + } + for (size_t i = 0; i < bar->right.count; i++) { + struct module *m = bar->right.mods[i]; + struct module_expose_context *e = &bar->right.exps[i]; + + if (e->exposable != NULL) + m->end_expose(m, e); + m->destroy(m); + } + cairo_destroy(bar->cairo); cairo_surface_destroy(bar->cairo_surface); cairo_debug_reset_static_data(); @@ -705,31 +730,6 @@ 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 module_expose_context *e = &b->left.exps[i]; - - if (e->exposable != NULL) - m->end_expose(m, e); - m->destroy(m); - } - for (size_t i = 0; i < b->center.count; i++) { - struct module *m = b->center.mods[i]; - struct module_expose_context *e = &b->center.exps[i]; - - if (e->exposable != NULL) - m->end_expose(m, e); - m->destroy(m); - } - for (size_t i = 0; i < b->right.count; i++) { - struct module *m = b->right.mods[i]; - struct module_expose_context *e = &b->right.exps[i]; - - if (e->exposable != NULL) - m->end_expose(m, e); - m->destroy(m); - } - free(b->left.mods); free(b->left.exps); free(b->center.mods);