summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPekka Paalanen <pekka.paalanen@collabora.co.uk>2017-08-11 16:05:41 +0300
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2017-10-04 16:18:06 +0300
commit1580be68fda378e640aa92f5072d6b4366c03454 (patch)
tree08a0ba18f6906b46e22502e71f8cba91e49d524f
parent26ac2e12189c93d7e01aace7c4a702b77e519a90 (diff)
compositor-wayland: move output init into common, fix error path
Move the weston_output_init() call into wayland_output_create_common(). This avoids passing the name twice to different functions, and follows the precedent set in "libweston: weston_output_init(..., +name)" for calling init before accessing fields. Since the error paths in wayland_output_create_for_parent_output() and wayland_output_create_fullscreen() are now guaranteed to have weston_output init'd, call weston_output_destroy() appropriately. There might be more to free than just the name. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ian Ray <ian.ray@ge.com> Acked-by Daniel Stone <daniels@collabora.com>
-rw-r--r--libweston/compositor-wayland.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index dee972c8..e8639a0e 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -1242,7 +1242,8 @@ err_output:
}
static struct wayland_output *
-wayland_output_create_common(const char *name)
+wayland_output_create_common(struct weston_compositor *compositor,
+ const char *name)
{
struct wayland_output *output;
char *title;
@@ -1262,6 +1263,8 @@ wayland_output_create_common(const char *name)
}
output->title = title;
+ weston_output_init(&output->base, compositor, name);
+
output->base.destroy = wayland_output_destroy;
output->base.disable = wayland_output_disable;
output->base.enable = wayland_output_enable;
@@ -1272,12 +1275,12 @@ wayland_output_create_common(const char *name)
static int
wayland_output_create(struct weston_compositor *compositor, const char *name)
{
- struct wayland_output *output = wayland_output_create_common(name);
+ struct wayland_output *output;
+ output = wayland_output_create_common(compositor, name);
if (!output)
return -1;
- weston_output_init(&output->base, compositor, name);
weston_compositor_add_pending_output(&output->base, compositor);
return 0;
@@ -1337,7 +1340,7 @@ wayland_output_create_for_parent_output(struct wayland_backend *b,
struct wayland_output *output;
struct weston_mode *mode;
- output = wayland_output_create_common("wlparent");
+ output = wayland_output_create_common(b->compositor, "wlparent");
if (!output)
return -1;
@@ -1353,8 +1356,6 @@ wayland_output_create_for_parent_output(struct wayland_backend *b,
goto out;
}
- weston_output_init(&output->base, b->compositor, "wlparent");
-
output->base.scale = 1;
output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL;
@@ -1375,7 +1376,7 @@ wayland_output_create_for_parent_output(struct wayland_backend *b,
return 0;
out:
- free(output->base.name);
+ weston_output_destroy(&output->base);
free(output->title);
free(output);
@@ -1388,12 +1389,10 @@ wayland_output_create_fullscreen(struct wayland_backend *b)
struct wayland_output *output;
int width = 0, height = 0;
- output = wayland_output_create_common("wayland-fullscreen");
+ output = wayland_output_create_common(b->compositor, "wayland-fullscreen");
if (!output)
return -1;
- weston_output_init(&output->base, b->compositor, "wayland-fullscreen");
-
output->base.scale = 1;
output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL;
@@ -1425,7 +1424,7 @@ wayland_output_create_fullscreen(struct wayland_backend *b)
err_set_size:
wayland_backend_destroy_output_surface(output);
err_surface:
- free(output->base.name);
+ weston_output_destroy(&output->base);
free(output->title);
free(output);