libweston: Add paint node destruction into weston_layer_entry_remove()

This prevents a potential crash where users of
weston_layer_entry_insert/layer_entry_remove() would see when moving
views into a NULL layer (effectively unmapping the surface/view).

Users that have migrated to the weston_view_move_to_layer() are immune
to this issue because that takes care of paint node destruction.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
Marius Vlad 2024-04-09 18:34:22 +03:00
parent 527bc8aeb3
commit 2d3cca3d3e

View File

@ -3980,17 +3980,10 @@ weston_view_move_to_layer(struct weston_view *view,
struct weston_layer_entry *layer)
{
bool was_mapped = view->is_mapped;
struct weston_paint_node *pnode, *pntmp;
if (layer == &view->layer_link)
return;
/* Remove all paint nodes because we have no idea what a layer change
* does to view visibility on any output.
*/
wl_list_for_each_safe(pnode, pntmp, &view->paint_node_list, view_link)
weston_paint_node_destroy(pnode);
view->surface->compositor->view_list_needs_rebuild = true;
/* Damage the view's old region, and remove it from the layer. */
@ -4020,6 +4013,18 @@ weston_view_move_to_layer(struct weston_view *view,
WL_EXPORT void
weston_layer_entry_remove(struct weston_layer_entry *entry)
{
struct weston_paint_node *pnode, *pntmp;
struct weston_view *view;
/* Remove all paint nodes because we have no idea what a layer change
* does to view visibility on any output.
*/
view = container_of(entry, struct weston_view, layer_link);
view->surface->compositor->view_list_needs_rebuild = true;
wl_list_for_each_safe(pnode, pntmp, &view->paint_node_list, view_link)
weston_paint_node_destroy(pnode);
wl_list_remove(&entry->link);
wl_list_init(&entry->link);
entry->layer = NULL;