compositor: Destroy the compositor before the log scope

Destroying the compositor after destroying the log scope will not print
out the messages in the tear down/clean-up phase of the compositor, so
add a new tear_down function which allows keeping a valid reference to
the compositor. This way we can destroy the compositor before destroying
the scope and keep the debug messages.

While at it remove the log context destroy part from the clean-up
of the compositor and make it stand on its own.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
dev
Marius Vlad 5 years ago
parent f387f8409a
commit 284d5345ad
  1. 3
      compositor/main.c
  2. 5
      doc/sphinx/toc/libweston/compositor.rst
  3. 3
      include/libweston/libweston.h
  4. 27
      libweston/compositor.c

@ -3215,8 +3215,11 @@ out:
weston_compositor_log_scope_destroy(protocol_scope);
protocol_scope = NULL;
weston_compositor_tear_down(wet.compositor);
weston_compositor_log_scope_destroy(log_scope);
log_scope = NULL;
weston_log_ctx_compositor_destroy(wet.compositor);
weston_compositor_destroy(wet.compositor);
weston_log_subscriber_destroy_log(logger);

@ -3,8 +3,9 @@ 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 destroying it and releasing all
the resources associated with it, you should use :func:`weston_compositor_destroy`.
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.
Compositor API
--------------

@ -1760,8 +1760,11 @@ 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);
struct weston_compositor *
weston_compositor_create(struct wl_display *display,
struct weston_log_context *log_ctx, void *user_data);

@ -7569,16 +7569,19 @@ weston_load_module(const char *name, const char *entrypoint)
}
/** Destroys the compositor.
/** Tear down the compositor.
*
* This function cleans up the compositor state and destroys it.
* 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.
*
* \param compositor The compositor to be destroyed.
* @param compositor The compositor to be tear-down/cleaned.
*
* \ingroup compositor
* @ingroup compositor
* @sa weston_compositor_destroy
*/
WL_EXPORT void
weston_compositor_destroy(struct weston_compositor *compositor)
weston_compositor_tear_down(struct weston_compositor *compositor)
{
/* prevent further rendering while shutting down */
compositor->state = WESTON_COMPOSITOR_OFFSCREEN;
@ -7600,8 +7603,20 @@ weston_compositor_destroy(struct weston_compositor *compositor)
weston_compositor_log_scope_destroy(compositor->debug_scene);
compositor->debug_scene = NULL;
weston_log_ctx_compositor_destroy(compositor);
}
/** 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);
}

Loading…
Cancel
Save