From d9ffc1c31813f2f765a865869465092539286f6a Mon Sep 17 00:00:00 2001 From: Julian Bouzas Date: Mon, 18 May 2020 10:55:06 -0400 Subject: [PATCH] core: finish all pending tasks when core proxy is destroyed --- lib/wp/core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/wp/core.c b/lib/wp/core.c index e351623d..425e1ea4 100644 --- a/lib/wp/core.c +++ b/lib/wp/core.c @@ -183,10 +183,22 @@ static const struct pw_core_events core_events = { .error = core_error, }; +static gboolean +async_tasks_finish (gpointer key, gpointer value, gpointer user_data) +{ + GTask *task = G_TASK (value); + g_return_val_if_fail (task, FALSE); + + g_task_return_new_error (task, WP_DOMAIN_LIBRARY, + WP_LIBRARY_ERROR_INVARIANT, "core disconnected"); + return TRUE; +} + static void proxy_core_destroy (void *data) { WpCore *self = WP_CORE (data); + g_hash_table_foreach_remove (self->async_tasks, async_tasks_finish, NULL); self->pw_core = NULL; wp_debug_object (self, "emit disconnected"); g_signal_emit (self, signals[SIGNAL_DISCONNECTED], 0);