From ca640d51203a7b7f1237af79e6ba4e5608333356 Mon Sep 17 00:00:00 2001 From: Leandro Ribeiro Date: Mon, 27 Jan 2020 19:12:01 -0300 Subject: [PATCH] libweston: fold weston_compositor_tear_down() into weston_compositor_destroy() The only reason why we have both weston_compositor_tear_down() and weston_compositor_destroy() is that the only we had to destroy the log context was keeping weston_compositor alive and calling weston_log_ctx_compositor_destroy(). After commit "weston-log: replace weston_log_ctx_compositor_destroy() by weston_log_ctx_destroy()", it's not necessary to keep a zombie weston_compositor just to be able to call weston_log_ctx_compositor_destroy(). Fold weston_compositor_tear_down() into weston_compositor_destroy(), as this split is useless now. Signed-off-by: Leandro Ribeiro --- compositor/main.c | 4 +--- doc/sphinx/toc/libweston/compositor.rst | 4 ++-- include/libweston/libweston.h | 2 -- libweston/compositor.c | 28 ++++++------------------- 4 files changed, 9 insertions(+), 29 deletions(-) diff --git a/compositor/main.c b/compositor/main.c index 94f8e7d2..97c3c45c 100644 --- a/compositor/main.c +++ b/compositor/main.c @@ -3375,13 +3375,11 @@ out: if (protologger) wl_protocol_logger_destroy(protologger); + weston_compositor_destroy(wet.compositor); weston_log_scope_destroy(protocol_scope); protocol_scope = NULL; - weston_compositor_tear_down(wet.compositor); - weston_log_scope_destroy(log_scope); log_scope = NULL; - weston_compositor_destroy(wet.compositor); weston_log_ctx_destroy(log_ctx); weston_log_subscriber_destroy_log(logger); weston_log_subscriber_destroy_flight_rec(flight_rec); diff --git a/doc/sphinx/toc/libweston/compositor.rst b/doc/sphinx/toc/libweston/compositor.rst index 4fc1f57d..755d781f 100644 --- a/doc/sphinx/toc/libweston/compositor.rst +++ b/doc/sphinx/toc/libweston/compositor.rst @@ -4,8 +4,8 @@ Compositor :type:`weston_compositor` represents the core object of the library, which aggregates all the other objects and maintains their state. You can create it using :func:`weston_compositor_create`, while for releasing all the resources -associated with it, you should use :func:`weston_compositor_tear_down`, -followed by :func:`weston_compositor_destroy` to destroy it. +associated with it and then destroy it, you should use +:func:`weston_compositor_destroy`. Compositor API -------------- diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index 57fa183d..1439775e 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -1765,8 +1765,6 @@ weston_buffer_from_resource(struct wl_resource *resource); void weston_compositor_get_time(struct timespec *time); -void -weston_compositor_tear_down(struct weston_compositor *ec); void weston_compositor_destroy(struct weston_compositor *ec); diff --git a/libweston/compositor.c b/libweston/compositor.c index 2f8af3c2..f7e2afdd 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -6529,7 +6529,7 @@ weston_compositor_create_output_with_head(struct weston_compositor *compositor, * The heads attached to the given output are detached and become unused again. * * It is not necessary to explicitly destroy all outputs at compositor exit. - * weston_compositor_tear_down() will automatically destroy any remaining + * weston_compositor_destroy() will automatically destroy any remaining * outputs. * * \ingroup ouput @@ -7633,7 +7633,7 @@ weston_load_module(const char *name, const char *entrypoint) * the plugin destruction order is not guaranteed: plugins that depend on other * plugins must be able to be torn down in arbitrary order. * - * \sa weston_compositor_tear_down, weston_compositor_destroy + * \sa weston_compositor_destroy */ WL_EXPORT bool weston_compositor_add_destroy_listener_once(struct weston_compositor *compositor, @@ -7648,19 +7648,16 @@ weston_compositor_add_destroy_listener_once(struct weston_compositor *compositor return true; } -/** Tear down the compositor. +/** Destroys the compositor. * - * This function cleans up the compositor state. While the compositor state has - * been cleaned do note that **only** weston_compositor_destroy() can be called - * afterwards, in order to destroy the compositor instance. + * This function cleans up the compositor state and then destroys it. * - * @param compositor The compositor to be tear-down/cleaned. + * @param compositor The compositor to be destroyed. * * @ingroup compositor - * @sa weston_compositor_destroy */ WL_EXPORT void -weston_compositor_tear_down(struct weston_compositor *compositor) +weston_compositor_destroy(struct weston_compositor *compositor) { /* prevent further rendering while shutting down */ compositor->state = WESTON_COMPOSITOR_OFFSCREEN; @@ -7685,20 +7682,7 @@ weston_compositor_tear_down(struct weston_compositor *compositor) weston_log_scope_destroy(compositor->timeline); compositor->timeline = NULL; -} -/** Destroys the compositor. - * - * This function destroys the compositor. **Do not** call this before - * calling weston_compositor_tear_down() - * - * @param compositor The compositor to be destroyed. - * @ingroup compositor - * @sa weston_compositor_tear_down() - */ -WL_EXPORT void -weston_compositor_destroy(struct weston_compositor *compositor) -{ free(compositor); }