mirror of
https://github.com/labwc/labwc.git
synced 2026-04-07 08:21:20 -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
|
|
@ -7,7 +7,7 @@
|
|||
#include <wlr/types/wlr_scene.h>
|
||||
#include "buffer.h"
|
||||
#include "common/mem.h"
|
||||
#include "common/string-helpers.h"
|
||||
#include "common/scene-helpers.h"
|
||||
#include "config/rcxml.h"
|
||||
#include "labwc.h"
|
||||
#include "node.h"
|
||||
|
|
@ -31,14 +31,14 @@ ssd_titlebar_create(struct ssd *ssd)
|
|||
int width = view->current.width;
|
||||
int corner_width = ssd_get_corner_width();
|
||||
|
||||
ssd->titlebar.tree = wlr_scene_tree_create(ssd->tree);
|
||||
ssd->titlebar.tree = lab_wlr_scene_tree_create(ssd->tree);
|
||||
node_descriptor_create(&ssd->titlebar.tree->node,
|
||||
LAB_NODE_TITLEBAR, view, /*data*/ NULL);
|
||||
|
||||
enum ssd_active_state active;
|
||||
FOR_EACH_ACTIVE_STATE(active) {
|
||||
struct ssd_titlebar_subtree *subtree = &ssd->titlebar.subtrees[active];
|
||||
subtree->tree = wlr_scene_tree_create(ssd->titlebar.tree);
|
||||
subtree->tree = lab_wlr_scene_tree_create(ssd->titlebar.tree);
|
||||
struct wlr_scene_tree *parent = subtree->tree;
|
||||
wlr_scene_node_set_enabled(&parent->node, active);
|
||||
wlr_scene_node_set_position(&parent->node, 0, -theme->titlebar_height);
|
||||
|
|
@ -51,7 +51,7 @@ ssd_titlebar_create(struct ssd *ssd)
|
|||
&theme->window[active].corner_top_right_normal->base;
|
||||
|
||||
/* Background */
|
||||
subtree->bar = wlr_scene_buffer_create(parent, titlebar_fill);
|
||||
subtree->bar = lab_wlr_scene_buffer_create(parent, titlebar_fill);
|
||||
/*
|
||||
* Work around the wlroots/pixman bug that widened 1px buffer
|
||||
* becomes translucent when bilinear filtering is used.
|
||||
|
|
@ -64,11 +64,11 @@ ssd_titlebar_create(struct ssd *ssd)
|
|||
}
|
||||
wlr_scene_node_set_position(&subtree->bar->node, corner_width, 0);
|
||||
|
||||
subtree->corner_left = wlr_scene_buffer_create(parent, corner_top_left);
|
||||
subtree->corner_left = lab_wlr_scene_buffer_create(parent, corner_top_left);
|
||||
wlr_scene_node_set_position(&subtree->corner_left->node,
|
||||
-rc.theme->border_width, -rc.theme->border_width);
|
||||
|
||||
subtree->corner_right = wlr_scene_buffer_create(parent, corner_top_right);
|
||||
subtree->corner_right = lab_wlr_scene_buffer_create(parent, corner_top_right);
|
||||
wlr_scene_node_set_position(&subtree->corner_right->node,
|
||||
width - corner_width, -rc.theme->border_width);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue