1 From cfde02d47a503cbfd0629bbfe0cb776686af8a91 Mon Sep 17 00:00:00 2001
2 From: Marius Vlad <marius.vlad@collabora.com>
3 Date: Tue, 9 Apr 2024 18:34:22 +0300
4 Subject: [PATCH] libweston: Add paint node destruction into
5 weston_layer_entry_remove()
7 This prevents a potential crash where users of
8 weston_layer_entry_insert/layer_entry_remove() would see when moving
9 views into a NULL layer (effectively unmapping the surface/view).
11 Users that have migrated to the weston_view_move_to_layer() are immune
12 to this issue because that takes care paint node destruction.
14 Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
16 libweston/compositor.c | 17 ++++++++++-------
17 1 file changed, 10 insertions(+), 7 deletions(-)
19 diff --git a/libweston/compositor.c b/libweston/compositor.c
20 index bb29b83b5..ea257bb90 100644
21 --- a/libweston/compositor.c
22 +++ b/libweston/compositor.c
23 @@ -3980,17 +3980,10 @@ weston_view_move_to_layer(struct weston_view *view,
24 struct weston_layer_entry *layer)
26 bool was_mapped = view->is_mapped;
27 - struct weston_paint_node *pnode, *pntmp;
29 if (layer == &view->layer_link)
32 - /* Remove all paint nodes because we have no idea what a layer change
33 - * does to view visibility on any output.
35 - wl_list_for_each_safe(pnode, pntmp, &view->paint_node_list, view_link)
36 - weston_paint_node_destroy(pnode);
38 view->surface->compositor->view_list_needs_rebuild = true;
40 /* Damage the view's old region, and remove it from the layer. */
41 @@ -4020,6 +4013,16 @@ weston_view_move_to_layer(struct weston_view *view,
43 weston_layer_entry_remove(struct weston_layer_entry *entry)
45 + struct weston_paint_node *pnode, *pntmp;
46 + struct weston_view *view;
48 + /* Remove all paint nodes because we have no idea what a layer change
49 + * does to view visibility on any output.
51 + view = container_of(entry, struct weston_view, layer_link);
52 + wl_list_for_each_safe(pnode, pntmp, &view->paint_node_list, view_link)
53 + weston_paint_node_destroy(pnode);
55 wl_list_remove(&entry->link);
56 wl_list_init(&entry->link);