From 7ec9523ea3c5e5a4f1e7a6e17a047dae0b663db7 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sun, 29 Aug 2021 16:58:12 -0500 Subject: [PATCH] scene: stricter assertions on reparent For consistency with the rest of the scene-graph API, prevent detaching a subtree by giving NULL for the new parent, and don't allow ROOT nodes to be grafted into another tree. --- types/wlr_scene.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/types/wlr_scene.c b/types/wlr_scene.c index 19132d9a..ee9215d2 100644 --- a/types/wlr_scene.c +++ b/types/wlr_scene.c @@ -135,6 +135,8 @@ void wlr_scene_node_place_below(struct wlr_scene_node *node, void wlr_scene_node_reparent(struct wlr_scene_node *node, struct wlr_scene_node *new_parent) { + assert(node->type != WLR_SCENE_NODE_ROOT && new_parent != NULL); + if (node->parent == new_parent) { return; } @@ -145,11 +147,8 @@ void wlr_scene_node_reparent(struct wlr_scene_node *node, } wl_list_remove(&node->state.link); - node->parent = new_parent; - if (new_parent != NULL) { - wl_list_insert(new_parent->state.children.prev, &node->state.link); - } + wl_list_insert(new_parent->state.children.prev, &node->state.link); } static void scene_node_for_each_surface(struct wlr_scene_node *node,