From 75e7106403143944e9dc7e0efc7a53127d582574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20Krezovi=C4=87?= Date: Thu, 11 Aug 2016 15:49:58 +0200 Subject: [PATCH] libweston: fix animation crash when a view has no output assigned MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a crash in animation related code where weston would crash in weston_view_animation_create when the view had no output assigned. This makes sure that animation gets created and released immediately, so done and reset callbacks still get called properly. Signed-off-by: Armin Krezović [Pekka: put a '{' on the right line.] Reviewed-by: Pekka Paalanen --- libweston/animation.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/libweston/animation.c b/libweston/animation.c index 30b3e5de..24fc4adc 100644 --- a/libweston/animation.c +++ b/libweston/animation.c @@ -196,6 +196,14 @@ weston_view_animation_frame(struct weston_animation *base, weston_compositor_schedule_repaint(compositor); } +static void +idle_animation_destroy(void *data) +{ + struct weston_view_animation *animation = data; + + weston_view_animation_destroy(animation); +} + static struct weston_view_animation * weston_view_animation_create(struct weston_view *view, float start, float stop, @@ -206,6 +214,8 @@ weston_view_animation_create(struct weston_view *view, void *private) { struct weston_view_animation *animation; + struct weston_compositor *ec = view->surface->compositor; + struct wl_event_loop *loop; animation = malloc(sizeof *animation); if (!animation) @@ -229,8 +239,14 @@ weston_view_animation_create(struct weston_view *view, animation->listener.notify = handle_animation_view_destroy; wl_signal_add(&view->destroy_signal, &animation->listener); - wl_list_insert(&view->output->animation_list, - &animation->animation.link); + if (view->output) { + wl_list_insert(&view->output->animation_list, + &animation->animation.link); + } else { + wl_list_init(&animation->animation.link); + loop = wl_display_get_event_loop(ec->wl_display); + wl_event_loop_add_idle(loop, idle_animation_destroy, animation); + } return animation; }