From ce4f08b91a798c3eee5a67a93e8b0b37a22cb47a Mon Sep 17 00:00:00 2001 From: Felix Kratz Date: Wed, 22 Dec 2021 19:45:15 +0100 Subject: [PATCH] correctly free popup items on destruction of parent --- src/bar_item.c | 1 + src/popup.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bar_item.c b/src/bar_item.c index c13c5da..ef39b20 100644 --- a/src/bar_item.c +++ b/src/bar_item.c @@ -389,6 +389,7 @@ void bar_item_destroy(struct bar_item* bar_item) { if (bar_item->group && bar_item->type == BAR_COMPONENT_GROUP) group_destroy(bar_item->group); else if (bar_item->group) group_remove_member(bar_item->group, bar_item); env_vars_destroy(&bar_item->signal_args.env_vars); + popup_destroy(&bar_item->popup); free(bar_item); } diff --git a/src/popup.c b/src/popup.c index 803c866..ebb8292 100644 --- a/src/popup.c +++ b/src/popup.c @@ -1,6 +1,7 @@ #include "popup.h" #include "background.h" #include "bar_item.h" +#include "bar_manager.h" #include "misc/helpers.h" #include @@ -145,10 +146,10 @@ void popup_draw(struct popup* popup) { void popup_destroy(struct popup* popup) { for (int i = 0; i < popup->num_items; i++) { - free(popup->items[i]); + bar_manager_remove_item(&g_bar_manager, popup->items[i]); } if (popup->items) free(popup->items); - if (popup->context) free(popup->context); + popup_close_window(popup); } static bool popup_parse_sub_domain(struct popup* popup, FILE* rsp, struct token property, char* message) {