5b4fd04c46062cf20434ac9fee1a937684180945
[AGL/meta-agl.git] / meta-agl-core / recipes-graphics / wayland / weston / 0001-libweston-add-weston_layer_fini.patch
1 From 8740037a93c7c4400cc381ecf3009d1e4014be07 Mon Sep 17 00:00:00 2001
2 From: Pekka Paalanen <pekka.paalanen@collabora.com>
3 Upstream-Status: Backport
4 Date: Fri, 14 May 2021 14:29:40 +0300
5 Subject: [PATCH] libweston: add weston_layer_fini()
6
7 Layers did not have a fini sequence before, which means the compositor
8 layer list might have stale pointers temporarily when shutting down. A
9 bigger problem might be having views linger after the destruction of the
10 layer.
11
12 These problems were not observed yet, but if they exist, this patch
13 should help to find them and then fix them.
14
15 The check in weston_compositor_shutdown() is not an assert yet, because
16 it will trigger until all components call weston_layer_fini() correctly.
17 Some components do not even have a tear-down function to call it from at
18 all, like fullscreen-shell.
19
20 The same with the check in weston_layer_fini().
21
22 Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
23 ---
24  include/libweston/libweston.h |  2 ++
25  libweston/compositor.c        | 21 +++++++++++++++++++++
26  2 files changed, 23 insertions(+)
27
28 diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h
29 index 7e8e7a625..d9907de0d 100644
30 --- a/include/libweston/libweston.h
31 +++ b/include/libweston/libweston.h
32 @@ -1637,6 +1637,8 @@ void
33  weston_layer_init(struct weston_layer *layer,
34                   struct weston_compositor *compositor);
35  void
36 +weston_layer_fini(struct weston_layer *layer);
37 +void
38  weston_layer_set_position(struct weston_layer *layer,
39                           enum weston_layer_position position);
40  void
41 diff --git a/libweston/compositor.c b/libweston/compositor.c
42 index dc6ecb2ce..c2da3a48c 100644
43 --- a/libweston/compositor.c
44 +++ b/libweston/compositor.c
45 @@ -3243,6 +3243,21 @@ weston_layer_init(struct weston_layer *layer,
46         weston_layer_set_mask_infinite(layer);
47  }
48  
49 +/** Finalize the weston_layer struct.
50 + *
51 + * \param layer The layer to finalize.
52 + */
53 +WL_EXPORT void
54 +weston_layer_fini(struct weston_layer *layer)
55 +{
56 +       wl_list_remove(&layer->link);
57 +
58 +       if (!wl_list_empty(&layer->view_list.link))
59 +               weston_log("BUG: finalizing a layer with views still on it.\n");
60 +
61 +       wl_list_remove(&layer->view_list.link);
62 +}
63 +
64  /** Sets the position of the layer in the layer list. The layer will be placed
65   * below any layer with the same position value, if any.
66   * This function is safe to call if the layer is already on the list, but the
67 @@ -7738,6 +7753,12 @@ weston_compositor_shutdown(struct weston_compositor *ec)
68         weston_binding_list_destroy_all(&ec->debug_binding_list);
69  
70         weston_plane_release(&ec->primary_plane);
71 +
72 +       weston_layer_fini(&ec->fade_layer);
73 +       weston_layer_fini(&ec->cursor_layer);
74 +
75 +       if (!wl_list_empty(&ec->layer_list))
76 +               weston_log("BUG: layer_list is not empty after shutdown. Calls to weston_layer_fini() are missing somwhere.\n");
77  }
78  
79  /** weston_compositor_exit_with_code
80 -- 
81 GitLab
82