From 661a7142cac56508b737437516337e2a960711bf Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Wed, 3 Jul 2024 06:58:44 -0500 Subject: [PATCH] libweston: Defer animation destruction to idle loop If the first tick of an animation finishes the animation, then the animation is destroyed before its creation function even returns. Let's just defer that destruction to the idle loop so that can't happen. Signed-off-by: Derek Foreman --- libweston/animation.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libweston/animation.c b/libweston/animation.c index 8271ab9b..3d8cc7a2 100644 --- a/libweston/animation.c +++ b/libweston/animation.c @@ -180,6 +180,9 @@ static void defer_animation_destroy(struct weston_view_animation *animation) struct weston_compositor *ec = animation->view->surface->compositor; struct wl_event_loop *loop = wl_display_get_event_loop(ec->wl_display); + if (animation->idle_destroy_source) + return; + animation->idle_destroy_source = wl_event_loop_add_idle(loop, idle_animation_destroy, animation); @@ -202,10 +205,7 @@ weston_view_animation_frame(struct weston_animation *base, weston_spring_update(&animation->spring, time); if (weston_spring_done(&animation->spring)) { - if (animation->idle_destroy_source) - wl_event_source_remove(animation->idle_destroy_source); - - weston_view_animation_destroy(animation); + defer_animation_destroy(animation); return; }