diff options
| author | Federico Angelilli <code@fedang.net> | 2024-03-17 18:42:17 +0100 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2024-03-17 18:42:17 +0100 |
| commit | ba0b6f462ad3024848c63efd6896104472ed4422 (patch) | |
| tree | bf46ee84224c809efadd961d59938a57a2e3d097 /src/comet.c | |
| parent | e0c591cd6a3ac5af82c41460149f1ae6be8e3819 (diff) | |
Always clear previous menu animation
Diffstat (limited to 'src/comet.c')
| -rw-r--r-- | src/comet.c | 14 |
1 files changed, 6 insertions, 8 deletions
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; |
