summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Vlad <marius.vlad@collabora.com>2019-06-24 12:00:47 +0300
committerMarius Vlad <marius.vlad@collabora.com>2019-07-18 13:34:04 +0300
commit284d5345ad38dfd0e4ee08d3da75ace0a512a2c4 (patch)
treec7aeade362ffb28fff191976614e4049f51fdefb
parentf387f8409aa5fcc1ba7881143bfe15b912f9323f (diff)
downloadweston-284d5345ad38dfd0e4ee08d3da75ace0a512a2c4.tar.gz
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>
-rw-r--r--compositor/main.c3
-rw-r--r--doc/sphinx/toc/libweston/compositor.rst5
-rw-r--r--include/libweston/libweston.h3
-rw-r--r--libweston/compositor.c27
4 files changed, 30 insertions, 8 deletions
diff --git a/compositor/main.c b/compositor/main.c
index 538fb73a..068d0bf7 100644
--- a/compositor/main.c
+++ b/compositor/main.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);
diff --git a/doc/sphinx/toc/libweston/compositor.rst b/doc/sphinx/toc/libweston/compositor.rst
index 826b5620..4fc1f57d 100644
--- a/doc/sphinx/toc/libweston/compositor.rst
+++ b/doc/sphinx/toc/libweston/compositor.rst
@@ -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
--------------
diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h
index c24e94cf..2af7e32a 100644
--- a/include/libweston/libweston.h
+++ b/include/libweston/libweston.h
@@ -1761,7 +1761,10 @@ 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);
diff --git a/libweston/compositor.c b/libweston/compositor.c
index f2ef3f5b..be719ae6 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -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);
}