summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
}