libweston: fix animation crash when a view has no output assigned

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ć <krezovic.armin@gmail.com>
[Pekka: put a '{' on the right line.]
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
dev
Armin Krezović 8 years ago committed by Pekka Paalanen
parent 96c205a509
commit 75e7106403
  1. 20
      libweston/animation.c

@ -196,6 +196,14 @@ weston_view_animation_frame(struct weston_animation *base,
weston_compositor_schedule_repaint(compositor); 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 * static struct weston_view_animation *
weston_view_animation_create(struct weston_view *view, weston_view_animation_create(struct weston_view *view,
float start, float stop, float start, float stop,
@ -206,6 +214,8 @@ weston_view_animation_create(struct weston_view *view,
void *private) void *private)
{ {
struct weston_view_animation *animation; struct weston_view_animation *animation;
struct weston_compositor *ec = view->surface->compositor;
struct wl_event_loop *loop;
animation = malloc(sizeof *animation); animation = malloc(sizeof *animation);
if (!animation) if (!animation)
@ -229,8 +239,14 @@ weston_view_animation_create(struct weston_view *view,
animation->listener.notify = handle_animation_view_destroy; animation->listener.notify = handle_animation_view_destroy;
wl_signal_add(&view->destroy_signal, &animation->listener); wl_signal_add(&view->destroy_signal, &animation->listener);
wl_list_insert(&view->output->animation_list, if (view->output) {
&animation->animation.link); 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; return animation;
} }

Loading…
Cancel
Save