1From 4744081f6a23e934097a8ce3a19dc80bc909a76e Mon Sep 17 00:00:00 2001
2From: Jeffy Chen <jeffy.chen@rock-chips.com>
3Date: Fri, 9 Oct 2020 18:00:11 +0800
4Subject: [PATCH 29/79] libweston: animation: Fix double-destroy
5
6Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
7---
8 libweston/animation.c | 9 ++++++++-
9 1 file changed, 8 insertions(+), 1 deletion(-)
10
11diff --git a/libweston/animation.c b/libweston/animation.c
12index f11754c..b228558 100644
13--- a/libweston/animation.c
14+++ b/libweston/animation.c
15@@ -136,6 +136,7 @@ struct weston_view_animation {
16 	weston_view_animation_frame_func_t frame;
17 	weston_view_animation_frame_func_t reset;
18 	weston_view_animation_done_func_t done;
19+	struct wl_event_source *idle_destroy_source;
20 	void *data;
21 	void *private;
22 };
23@@ -143,6 +144,9 @@ struct weston_view_animation {
24 WL_EXPORT void
25 weston_view_animation_destroy(struct weston_view_animation *animation)
26 {
27+	if (animation->idle_destroy_source)
28+		wl_event_source_remove(animation->idle_destroy_source);
29+
30 	wl_list_remove(&animation->animation.link);
31 	wl_list_remove(&animation->listener.link);
32 	wl_list_remove(&animation->transform.link);
33@@ -248,10 +252,13 @@ weston_view_animation_create(struct weston_view *view,
34 	if (view->output) {
35 		wl_list_insert(&view->output->animation_list,
36 			       &animation->animation.link);
37+		animation->idle_destroy_source = NULL;
38 	} else {
39 		wl_list_init(&animation->animation.link);
40 		loop = wl_display_get_event_loop(ec->wl_display);
41-		wl_event_loop_add_idle(loop, idle_animation_destroy, animation);
42+		animation->idle_destroy_source =
43+			wl_event_loop_add_idle(loop, idle_animation_destroy,
44+					       animation);
45 	}
46
47 	return animation;
48--
492.20.1
50
51