[PATCH 06/10] compositor-wayland: Add error handling in wayland_compositor_create()
Martin Olsson
martin at minimum.se
Sat Jul 7 18:03:43 PDT 2012
---
src/compositor-wayland.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index ea09730..9df7228 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -847,16 +847,16 @@ wayland_compositor_create(struct wl_display *display,
if (weston_compositor_init(&c->base, display, argc, argv,
config_file) < 0)
- return NULL;
+ goto err_free;
if (wayland_input_create(c) < 0)
- return NULL;
+ goto err_compositor;
c->parent.wl_display = wl_display_connect(display_name);
if (c->parent.wl_display == NULL) {
weston_log("failed to create display: %m\n");
- return NULL;
+ goto err_compositor;
}
wl_list_init(&c->input_list);
@@ -867,16 +867,16 @@ wayland_compositor_create(struct wl_display *display,
c->base.wl_display = display;
if (wayland_compositor_init_egl(c) < 0)
- return NULL;
+ goto err_display;
c->base.destroy = wayland_destroy;
if (weston_compositor_init_gl(&c->base) < 0)
- return NULL;
+ goto err_display;
create_border(c);
if (wayland_compositor_create_output(c, width, height) < 0)
- return NULL;
+ goto err_display;
loop = wl_display_get_event_loop(c->base.wl_display);
@@ -885,9 +885,17 @@ wayland_compositor_create(struct wl_display *display,
wl_event_loop_add_fd(loop, fd, c->parent.event_mask,
wayland_compositor_handle_event, c);
if (c->parent.wl_source == NULL)
- return NULL;
+ goto err_display;
return &c->base;
+
+err_display:
+ wl_display_disconnect(c->parent.wl_display);
+err_compositor:
+ weston_compositor_shutdown(&c->base);
+err_free:
+ free(c);
+ return NULL;
}
WL_EXPORT struct weston_compositor *
--
1.7.9.5
More information about the wayland-devel
mailing list