tree-wide: use die_if_null() for wlr_scene alloc failures

wlr_scene_*_create() functions all allocate memory via calloc() and
return NULL if the allocation fails. Previously, the failures were
handled in any of 3 different ways:

 - sending a wayland protocol error
 - exiting labwc with an error
 - segfault (no NULL check at all)

Since labwc does not attempt to survive heap exhaustion in other
allocation paths (such as `znew`), it seems more consistent to use the
same die_if_null() check used in those paths to exit with an error.

For the three most common create() functions (tree, rect, buffer),
add small lab_wlr_ wrappers to common/scene-helpers.
This commit is contained in:
John Lindgren 2026-02-23 16:34:36 -05:00
parent a3646721bc
commit caf815e608
27 changed files with 155 additions and 141 deletions

View file

@ -5,6 +5,7 @@
#include "config/rcxml.h"
#include "common/list.h"
#include "common/mem.h"
#include "common/scene-helpers.h"
#include "node.h"
#include "scaled-buffer/scaled-icon-buffer.h"
#include "scaled-buffer/scaled-img-buffer.h"
@ -19,7 +20,7 @@ attach_ssd_button(struct wl_list *button_parts, enum lab_node_type type,
struct lab_img *imgs[LAB_BS_ALL + 1],
int x, int y, struct view *view)
{
struct wlr_scene_tree *root = wlr_scene_tree_create(parent);
struct wlr_scene_tree *root = lab_wlr_scene_tree_create(parent);
wlr_scene_node_set_position(&root->node, x, y);
assert(node_type_contains(LAB_NODE_BUTTON, type));
@ -31,7 +32,7 @@ attach_ssd_button(struct wl_list *button_parts, enum lab_node_type type,
/* Hitbox */
float invisible[4] = { 0, 0, 0, 0 };
wlr_scene_rect_create(root, rc.theme->window_button_width,
lab_wlr_scene_rect_create(root, rc.theme->window_button_width,
rc.theme->window_button_height, invisible);
/* Icons */