weston-log: Add 'destroy_subscription' callback for the subscription
authorMarius Vlad <marius.vlad@collabora.com>
Mon, 29 Jul 2019 09:02:47 +0000 (12:02 +0300)
committerMarius Vlad <marius.vlad@collabora.com>
Thu, 17 Oct 2019 16:42:55 +0000 (19:42 +0300)
As 'new_subscription' can create additional objects, 'destroy_subscription'
will be needed when cleaning up.

As this requires a libweston_major bump (noticed by @pq), bump it up to
8.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
compositor/main.c
include/libweston/weston-log.h
libweston/backend-drm/drm.c
libweston/compositor.c
libweston/content-protection.c
libweston/weston-log.c
meson.build
pipewire/pipewire-plugin.c
xwayland/launcher.c

index 28f13e0ba5416eef59c086a7d8f15b1ea50ed01c..b3f6ba25f52802ba9f031347884c5853743220da 100644 (file)
@@ -3187,7 +3187,7 @@ int main(int argc, char *argv[])
        }
 
        log_scope = weston_compositor_add_log_scope(log_ctx, "log",
-                       "Weston and Wayland log\n", NULL, NULL);
+                       "Weston and Wayland log\n", NULL, NULL, NULL);
 
        weston_log_file_open(log);
        weston_log_set_handler(vlog, vlog_continue);
@@ -3274,7 +3274,7 @@ int main(int argc, char *argv[])
                weston_compositor_add_log_scope(log_ctx,
                                                "proto",
                                                "Wayland protocol dump for all clients.\n",
-                                                NULL, NULL);
+                                                NULL, NULL, NULL);
 
        if (debug_protocol) {
                protologger = wl_display_add_protocol_logger(display,
index d12f2578bacf87628cef6077c06c47a4137c0cfb..bda0b7d29cb2c0eecbd9dae116baf3a270719033 100644 (file)
@@ -67,6 +67,7 @@ weston_compositor_add_log_scope(struct weston_log_context *compositor,
                                  const char *name,
                                  const char *description,
                                  weston_log_scope_cb new_subscription,
+                                 weston_log_scope_cb destroy_subscription,
                                  void *user_data);
 
 void
index b21a5ed7cf8e6e56fba947ee0da0057687833c05..de2d1f84217e76faab11ce365b6028766ff85236 100644 (file)
@@ -3408,7 +3408,7 @@ drm_backend_create(struct weston_compositor *compositor,
        b->debug = weston_compositor_add_log_scope(compositor->weston_log_ctx,
                                                   "drm-backend",
                                                   "Debug messages from DRM/KMS backend\n",
-                                                   NULL, NULL);
+                                                   NULL, NULL, NULL);
 
        compositor->backend = &b->base;
 
index d20dfe7ee785ee66725ebe9b7c75ed28b2eb43ed..d06eccba50dbc8bb7c71706ff046630cfd8a1269 100644 (file)
@@ -7309,7 +7309,7 @@ weston_compositor_create(struct wl_display *display,
        ec->debug_scene =
                weston_compositor_add_log_scope(ec->weston_log_ctx, "scene-graph",
                                                "Scene graph details\n",
-                                               debug_scene_graph_cb,
+                                               debug_scene_graph_cb, NULL,
                                                ec);
 
        return ec;
index 63aa7337cd8c503b1339e19bbe508eadb8d34a6f..e958f8959f133b18ba898a933405c750fb382f78 100644 (file)
@@ -343,6 +343,6 @@ weston_compositor_enable_content_protection(struct weston_compositor *compositor
        cp->debug = weston_compositor_add_log_scope(compositor->weston_log_ctx,
                                                    "content-protection-debug",
                                                    "debug-logs for content-protection",
-                                                   NULL, NULL);
+                                                   NULL, NULL, NULL);
        return 0;
 }
index 877620ddd78b41242c8b42de1308960235e686f8..1021ebb2998dd94caec04bd963f24fd06e6ed06b 100644 (file)
@@ -82,6 +82,7 @@ struct weston_log_scope {
        char *name;
        char *desc;
        weston_log_scope_cb new_subscription;
+       weston_log_scope_cb destroy_subscription;
        void *user_data;
        struct wl_list compositor_link;
        struct wl_list subscription_list;  /**< weston_log_subscription::source_link */
@@ -260,6 +261,10 @@ void
 weston_log_subscription_destroy(struct weston_log_subscription *sub)
 {
        assert(sub);
+
+       if (sub->source->destroy_subscription)
+               sub->source->destroy_subscription(sub, sub->source->user_data);
+
        if (sub->owner)
                wl_list_remove(&sub->owner_link);
 
@@ -518,6 +523,8 @@ weston_compositor_is_debug_protocol_enabled(struct weston_compositor *wc)
  * @param description The log scope description for humans; must not be NULL.
  * @param new_subscription Optional callback when a client subscribes to this
  * scope.
+ * @param destroy_subscription Optional callback when a client destroys the
+ * subscription.
  * @param user_data Optional user data pointer for the callback.
  * @returns A valid pointer on success, NULL on failure.
  *
@@ -561,6 +568,7 @@ weston_compositor_add_log_scope(struct weston_log_context *log_ctx,
                                const char *name,
                                const char *description,
                                weston_log_scope_cb new_subscription,
+                               weston_log_scope_cb destroy_subscription,
                                void *user_data)
 {
        struct weston_log_scope *scope;
@@ -593,6 +601,7 @@ weston_compositor_add_log_scope(struct weston_log_context *log_ctx,
        scope->name = strdup(name);
        scope->desc = strdup(description);
        scope->new_subscription = new_subscription;
+       scope->destroy_subscription = destroy_subscription;
        scope->user_data = user_data;
        wl_list_init(&scope->subscription_list);
 
index 6db63f6404cd7da01afb2be62b4a5d4687d13aba..3d5aa5fbeb7d29a03b22d3f957eefb7432383a63 100644 (file)
@@ -10,7 +10,7 @@ project('weston',
        license: 'MIT/Expat',
 )
 
-libweston_major = 7
+libweston_major = 8
 
 # libweston_revision is manufactured to follow the autotools build's
 # library file naming, thanks to libtool
index bd873caadb74bf0b417b65bfd5757efae5dd6dfe..1eb5de573d6d49f0e1144abadda9b2c779fd8c63 100644 (file)
@@ -819,7 +819,7 @@ weston_module_init(struct weston_compositor *compositor)
                        compositor->weston_log_ctx,
                        "pipewire",
                        "Debug messages from pipewire plugin\n",
-                       NULL, NULL);
+                       NULL, NULL, NULL);
 
        pipewire->destroy_listener.notify = weston_pipewire_destroy;
        wl_signal_add(&compositor->destroy_signal, &pipewire->destroy_listener);
index 28383384780a0afac9e4fdeb0408543e77f4733e..1d51ee8fc1c5c5752237f647066bdb26fb5f7f4c 100644 (file)
@@ -398,7 +398,7 @@ weston_module_init(struct weston_compositor *compositor)
                weston_compositor_add_log_scope(wxs->compositor->weston_log_ctx,
                                                "xwm-wm-x11",
                                                "XWM's window management X11 events\n",
-                                               NULL, NULL);
+                                               NULL, NULL, NULL);
 
        return 0;
 }