From 635b960629ef17daed73d742fb6cb78ea6b1d4a7 Mon Sep 17 00:00:00 2001 From: Federico Angelilli Date: Sun, 17 Mar 2024 17:00:27 +0100 Subject: Fix memory leaks and refactor menu button --- src/animate.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/animate.c') diff --git a/src/animate.c b/src/animate.c index 387c9b8..2f4be8d 100644 --- a/src/animate.c +++ b/src/animate.c @@ -145,7 +145,7 @@ static bool shrink_func(Animation *shrink, Layout *layout) // This part is quite rough around the edges... if (group->children->next) { g_list_free(g_list_remove_link(group->children, group->children)); - g_list_free(g_list_remove_link(layout->children, layout->children)); + g_list_free_full(g_list_remove_link(layout->children, layout->children), (GDestroyNotify)layout_destroy); layout->width = CAST(layout->children->data, Layout)->width; return true; } @@ -162,8 +162,10 @@ static bool shrink_func(Animation *shrink, Layout *layout) for (GList *it = layout->children, *next = it->next; it; it = next, next = it ? it->next : NULL) { Layout *child = it->data; - if (child->x + child->width > layout->x + width) - layout->children = g_list_delete_link(layout->children, it); + if (child->x + child->width <= layout->x + width) continue; + + layout_destroy(it->data); + layout->children = g_list_delete_link(layout->children, it); } return true; @@ -197,8 +199,10 @@ static bool grow_func(Animation *grow, Layout *layout) for (GList *it = layout->children, *next = it->next; it; it = next, next = it ? it->next : NULL) { Layout *child = it->data; - if (child->x + child->width > layout->x + width) - layout->children = g_list_delete_link(layout->children, it); + if (child->x + child->width <= layout->x + width) continue; + + layout_destroy(it->data); + layout->children = g_list_delete_link(layout->children, it); } return true; -- cgit v1.2.3