diff options
| author | Federico Angelilli <code@fedang.net> | 2024-03-17 17:00:27 +0100 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2024-03-17 17:00:27 +0100 |
| commit | 635b960629ef17daed73d742fb6cb78ea6b1d4a7 (patch) | |
| tree | 2e2806b1ee2c61c65960d0aa048bfb7bc75bb4af /src/animate.c | |
| parent | 44a9ccb0ca18314016ef10b4b1b1c7c958d9eabc (diff) | |
Fix memory leaks and refactor menu button
Diffstat (limited to 'src/animate.c')
| -rw-r--r-- | src/animate.c | 14 |
1 files changed, 9 insertions, 5 deletions
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; |
