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>
This commit is contained in:
@@ -1242,7 +1242,8 @@ err_output:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct wayland_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;
|
struct wayland_output *output;
|
||||||
char *title;
|
char *title;
|
||||||
@@ -1262,6 +1263,8 @@ wayland_output_create_common(const char *name)
|
|||||||
}
|
}
|
||||||
output->title = title;
|
output->title = title;
|
||||||
|
|
||||||
|
weston_output_init(&output->base, compositor, name);
|
||||||
|
|
||||||
output->base.destroy = wayland_output_destroy;
|
output->base.destroy = wayland_output_destroy;
|
||||||
output->base.disable = wayland_output_disable;
|
output->base.disable = wayland_output_disable;
|
||||||
output->base.enable = wayland_output_enable;
|
output->base.enable = wayland_output_enable;
|
||||||
@@ -1272,12 +1275,12 @@ wayland_output_create_common(const char *name)
|
|||||||
static int
|
static int
|
||||||
wayland_output_create(struct weston_compositor *compositor, const char *name)
|
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)
|
if (!output)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
weston_output_init(&output->base, compositor, name);
|
|
||||||
weston_compositor_add_pending_output(&output->base, compositor);
|
weston_compositor_add_pending_output(&output->base, compositor);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1337,7 +1340,7 @@ wayland_output_create_for_parent_output(struct wayland_backend *b,
|
|||||||
struct wayland_output *output;
|
struct wayland_output *output;
|
||||||
struct weston_mode *mode;
|
struct weston_mode *mode;
|
||||||
|
|
||||||
output = wayland_output_create_common("wlparent");
|
output = wayland_output_create_common(b->compositor, "wlparent");
|
||||||
if (!output)
|
if (!output)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@@ -1353,8 +1356,6 @@ wayland_output_create_for_parent_output(struct wayland_backend *b,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
weston_output_init(&output->base, b->compositor, "wlparent");
|
|
||||||
|
|
||||||
output->base.scale = 1;
|
output->base.scale = 1;
|
||||||
output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||||
|
|
||||||
@@ -1375,7 +1376,7 @@ wayland_output_create_for_parent_output(struct wayland_backend *b,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
free(output->base.name);
|
weston_output_destroy(&output->base);
|
||||||
free(output->title);
|
free(output->title);
|
||||||
free(output);
|
free(output);
|
||||||
|
|
||||||
@@ -1388,12 +1389,10 @@ wayland_output_create_fullscreen(struct wayland_backend *b)
|
|||||||
struct wayland_output *output;
|
struct wayland_output *output;
|
||||||
int width = 0, height = 0;
|
int width = 0, height = 0;
|
||||||
|
|
||||||
output = wayland_output_create_common("wayland-fullscreen");
|
output = wayland_output_create_common(b->compositor, "wayland-fullscreen");
|
||||||
if (!output)
|
if (!output)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
weston_output_init(&output->base, b->compositor, "wayland-fullscreen");
|
|
||||||
|
|
||||||
output->base.scale = 1;
|
output->base.scale = 1;
|
||||||
output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||||
|
|
||||||
@@ -1425,7 +1424,7 @@ wayland_output_create_fullscreen(struct wayland_backend *b)
|
|||||||
err_set_size:
|
err_set_size:
|
||||||
wayland_backend_destroy_output_surface(output);
|
wayland_backend_destroy_output_surface(output);
|
||||||
err_surface:
|
err_surface:
|
||||||
free(output->base.name);
|
weston_output_destroy(&output->base);
|
||||||
free(output->title);
|
free(output->title);
|
||||||
free(output);
|
free(output);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user