libweston: move weston_compositor_shutdown call out of backends

If we want to support multiple backends, the compositor must take care
to call this once, at the appropriate moment, so stop letting the
backends handle compositor shutdown themselves.

Move the weston_compositor_shutdown() calls from the backend::destroy
callbacks into weston_compositor_destroy() and the calls in the backend
creation error paths into weston_compositor_load_backend().

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
This commit is contained in:
Philipp Zabel 2023-06-21 10:49:20 +02:00 committed by Daniel Stone
parent fcde7fae66
commit 90c11cf40e
9 changed files with 4 additions and 27 deletions

View File

@ -3260,8 +3260,6 @@ drm_destroy(struct weston_backend *backend)
struct drm_crtc *crtc, *crtc_tmp;
struct drm_writeback *writeback, *writeback_tmp;
weston_compositor_shutdown(ec);
wl_list_for_each_safe(crtc, crtc_tmp, &b->drm->crtc_list, link)
drm_crtc_destroy(crtc);
@ -4021,7 +4019,6 @@ err_udev:
err_launcher:
weston_launcher_destroy(compositor->launcher);
err_compositor:
weston_compositor_shutdown(compositor);
#ifdef BUILD_DRM_GBM
if (b->gbm)
gbm_device_destroy(b->gbm);

View File

@ -506,8 +506,6 @@ headless_destroy(struct weston_backend *backend)
struct weston_compositor *ec = b->compositor;
struct weston_head *base, *next;
weston_compositor_shutdown(ec);
wl_list_for_each_safe(base, next, &ec->head_list, compositor_link) {
if (to_headless_head(base))
headless_head_destroy(base);
@ -625,8 +623,6 @@ headless_backend_create(struct weston_compositor *compositor,
err_input:
if (b->theme)
theme_destroy(b->theme);
weston_compositor_shutdown(compositor);
err_free:
free(b);
return NULL;

View File

@ -645,8 +645,6 @@ pipewire_destroy(struct weston_backend *base)
weston_log_scope_destroy(b->debug);
b->debug = NULL;
weston_compositor_shutdown(ec);
pw_loop_leave(b->loop);
pw_loop_destroy(b->loop);
wl_event_source_remove(b->loop_source);
@ -1098,8 +1096,6 @@ pipewire_backend_create(struct weston_compositor *compositor,
return backend;
err_compositor:
weston_compositor_shutdown(compositor);
free(backend);
return NULL;
}

View File

@ -740,8 +740,6 @@ rdp_destroy(struct weston_backend *backend)
b->verbose = NULL;
}
weston_compositor_shutdown(ec);
wl_list_for_each_safe(base, next, &ec->head_list, compositor_link) {
if (to_rdp_head(base))
rdp_head_destroy(base);
@ -2035,8 +2033,6 @@ err_compositor:
if (to_rdp_head(base))
rdp_head_destroy(base);
}
weston_compositor_shutdown(compositor);
err_free_strings:
if (b->clipboard_debug)
weston_log_scope_destroy(b->clipboard_debug);

View File

@ -884,8 +884,6 @@ vnc_destroy(struct weston_backend *base)
struct weston_compositor *ec = backend->compositor;
struct weston_head *head, *next;
weston_compositor_shutdown(ec);
wl_event_source_remove(backend->aml_event);
aml_unref(backend->aml);
@ -1344,7 +1342,6 @@ err_output:
wl_list_for_each_safe(base, next, &compositor->head_list, compositor_link)
vnc_head_destroy(base);
err_compositor:
weston_compositor_shutdown(compositor);
free(backend);
return NULL;
}

View File

@ -2756,8 +2756,6 @@ wayland_destroy(struct weston_backend *backend)
struct wayland_parent_output *output, *next_output;
struct wayland_input *input, *next_input;
weston_compositor_shutdown(ec);
wl_list_for_each_safe(base, next, &ec->head_list, compositor_link) {
if (to_wayland_head(base))
wayland_head_destroy(base);
@ -2961,7 +2959,6 @@ err_renderer:
err_display:
wl_display_disconnect(b->parent.wl_display);
err_compositor:
weston_compositor_shutdown(compositor);
free(b->formats);
free(b);
return NULL;
@ -2978,7 +2975,6 @@ wayland_backend_destroy(struct wayland_backend *b)
cairo_device_destroy(b->frame_device);
wl_cursor_theme_destroy(b->cursor_theme);
weston_compositor_shutdown(b->compositor);
cleanup_after_cairo();
free(b->formats);
free(b);

View File

@ -1844,8 +1844,6 @@ x11_destroy(struct weston_backend *base)
struct weston_compositor *ec = backend->compositor;
struct weston_head *head, *next;
weston_compositor_shutdown(ec); /* destroys outputs, too */
wl_list_for_each_safe(head, next, &ec->head_list, compositor_link) {
if (to_x11_head(head))
x11_head_destroy(head);

View File

@ -8714,7 +8714,7 @@ fail:
/** weston_compositor_shutdown
* \ingroup compositor
*/
WL_EXPORT void
static void
weston_compositor_shutdown(struct weston_compositor *ec)
{
struct weston_output *output, *next;
@ -9091,6 +9091,8 @@ weston_compositor_destroy(struct weston_compositor *compositor)
if (compositor->backend && compositor->backend->shutdown)
compositor->backend->shutdown(compositor->backend);
weston_compositor_shutdown(compositor);
if (compositor->backend)
compositor->backend->destroy(compositor->backend);
@ -9196,6 +9198,7 @@ weston_compositor_load_backend(struct weston_compositor *compositor,
if (backend_init(compositor, config_base) < 0) {
compositor->backend = NULL;
weston_compositor_shutdown(compositor);
return -1;
}

View File

@ -243,8 +243,6 @@ weston_compositor_set_presentation_clock(struct weston_compositor *compositor,
int
weston_compositor_set_presentation_clock_software(
struct weston_compositor *compositor);
void
weston_compositor_shutdown(struct weston_compositor *ec);
void
weston_compositor_xkb_destroy(struct weston_compositor *ec);