mirror of
https://github.com/labwc/labwc.git
synced 2026-03-23 05:34:52 -04:00
tree-wide: use die_if_null() for wlr_scene alloc failures
Some checks failed
labwc.github.io / notify (push) Has been cancelled
Some checks failed
labwc.github.io / notify (push) Has been cancelled
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:
parent
c4effef0ec
commit
16c5373be5
27 changed files with 155 additions and 141 deletions
|
|
@ -12,6 +12,7 @@
|
|||
#include <wlr/types/wlr_virtual_keyboard_v1.h>
|
||||
#include <wlr/types/wlr_xdg_shell.h>
|
||||
#include "common/mem.h"
|
||||
#include "common/scene-helpers.h"
|
||||
#include "input/keyboard.h"
|
||||
#include "labwc.h"
|
||||
#include "node.h"
|
||||
|
|
@ -398,6 +399,8 @@ handle_input_method_new_popup_surface(struct wl_listener *listener, void *data)
|
|||
|
||||
popup->tree = wlr_scene_subsurface_tree_create(
|
||||
relay->popup_tree, popup->popup_surface->surface);
|
||||
die_if_null(popup->tree);
|
||||
|
||||
node_descriptor_create(&popup->tree->node, LAB_NODE_IME_POPUP,
|
||||
/*view*/ NULL, /*data*/ NULL);
|
||||
|
||||
|
|
@ -580,7 +583,7 @@ input_method_relay_create(struct seat *seat)
|
|||
relay->seat = seat;
|
||||
wl_list_init(&relay->text_inputs);
|
||||
wl_list_init(&relay->popups);
|
||||
relay->popup_tree = wlr_scene_tree_create(&seat->server->scene->tree);
|
||||
relay->popup_tree = lab_wlr_scene_tree_create(&seat->server->scene->tree);
|
||||
|
||||
relay->new_text_input.notify = handle_new_text_input;
|
||||
wl_signal_add(&seat->server->text_input_manager->events.text_input,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue