mirror of
https://github.com/swaywm/sway.git
synced 2026-02-04 04:06:18 -05:00
Use goto-based error handling in view_init()
This is less surprising than checking for the failed flag in the happy path.
This commit is contained in:
parent
723b1ea3b7
commit
c09d0f1d4a
1 changed files with 10 additions and 9 deletions
|
|
@ -43,20 +43,17 @@ bool view_init(struct sway_view *view, enum sway_view_type type,
|
|||
bool failed = false;
|
||||
view->scene_tree = alloc_scene_tree(root->staging, &failed);
|
||||
view->content_tree = alloc_scene_tree(view->scene_tree, &failed);
|
||||
if (failed) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!failed && !scene_descriptor_assign(&view->scene_tree->node,
|
||||
SWAY_SCENE_DESC_VIEW, view)) {
|
||||
failed = true;
|
||||
if (!scene_descriptor_assign(&view->scene_tree->node, SWAY_SCENE_DESC_VIEW, view)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
view->image_capture_scene = wlr_scene_create();
|
||||
if (view->image_capture_scene == NULL) {
|
||||
failed = true;
|
||||
}
|
||||
|
||||
if (failed) {
|
||||
wlr_scene_node_destroy(&view->scene_tree->node);
|
||||
return false;
|
||||
goto err;
|
||||
}
|
||||
|
||||
view->type = type;
|
||||
|
|
@ -67,6 +64,10 @@ bool view_init(struct sway_view *view, enum sway_view_type type,
|
|||
view->tearing_mode = TEARING_WINDOW_HINT;
|
||||
wl_signal_init(&view->events.unmap);
|
||||
return true;
|
||||
|
||||
err:
|
||||
wlr_scene_node_destroy(&view->scene_tree->node);
|
||||
return false;
|
||||
}
|
||||
|
||||
void view_destroy(struct sway_view *view) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue