From ba0b6f462ad3024848c63efd6896104472ed4422 Mon Sep 17 00:00:00 2001 From: Federico Angelilli Date: Sun, 17 Mar 2024 18:42:17 +0100 Subject: Always clear previous menu animation --- src/comet.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/comet.c b/src/comet.c index a32382f..7adebaf 100644 --- a/src/comet.c +++ b/src/comet.c @@ -198,10 +198,10 @@ static void menu_action(Button *btn) bool closed; } *menu_ctx = CAST(btn, ButtonSimple)->data; - if (menu_ctx->closed) { - g_list_free(menu_ctx->group->children); - menu_ctx->group->children = g_list_copy(menu_ctx->toggled); - } + // NOTE: Clear the previous animation, if any + g_list_free(menu_ctx->group->children); + g_clear_pointer(&menu_ctx->group->btn.anim, animation_destroy); + menu_ctx->group->children = g_list_copy(menu_ctx->toggled); char *text = g_strdup(menu_ctx->strings[menu_ctx->closed]); button_simple_set_text(btn, text, CAST(btn, ButtonSimple)->text_color); @@ -210,10 +210,8 @@ static void menu_action(Button *btn) ? animation_group_grow_create(MILLIS(600)) : animation_group_shrink_create(MILLIS(600)); - if (button_set_animation((gpointer)menu_ctx->group, anim)) - state_request_animation(menu_ctx->state); - else - animation_destroy(anim); + g_assert(button_set_animation((gpointer)menu_ctx->group, anim)); + state_request_animation(menu_ctx->state); log_debug("%s menu", menu_ctx->closed ? "Opened" : "Closed"); menu_ctx->closed = !menu_ctx->closed; -- cgit v1.2.3