[PATCH 1/2] libweston: Prevent a crash when a view has no output assigned
Armin Krezović
krezovic.armin at gmail.com
Thu Aug 11 13:49:58 UTC 2016
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 at gmail.com>
---
libweston/animation.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/libweston/animation.c b/libweston/animation.c
index 30b3e5d..1dcd6fa 100644
--- a/libweston/animation.c
+++ b/libweston/animation.c
@@ -196,6 +196,13 @@ 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 +213,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 +238,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;
}
--
2.9.2
More information about the wayland-devel
mailing list