diff options
author | Jens Georg <mail@jensge.org> | 2022-01-16 13:55:19 +0100 |
---|---|---|
committer | Jens Georg <mail@jensge.org> | 2022-01-20 14:36:07 +0100 |
commit | 9af0d8e1993bf20f18314170005c648699fd29d2 (patch) | |
tree | 8ddab22a860f40c42eb47f9b1d6057f79e016f77 | |
parent | ba2ff1365f822ab9727d7a91ad115fefd8c00dec (diff) | |
download | gupnp-9af0d8e1993bf20f18314170005c648699fd29d2.tar.gz |
ServiceProxyAction: Remove proxy
The task keeps a reference to the proxy, we do not need to
keep a proxy reference ourselves
-rw-r--r-- | libgupnp/gupnp-service-proxy-action-private.h | 1 | ||||
-rw-r--r-- | libgupnp/gupnp-service-proxy-action.c | 5 | ||||
-rw-r--r-- | libgupnp/gupnp-service-proxy.c | 29 |
3 files changed, 7 insertions, 28 deletions
diff --git a/libgupnp/gupnp-service-proxy-action-private.h b/libgupnp/gupnp-service-proxy-action-private.h index 27dc85e..ebe488e 100644 --- a/libgupnp/gupnp-service-proxy-action-private.h +++ b/libgupnp/gupnp-service-proxy-action-private.h @@ -132,7 +132,6 @@ G_BEGIN_DECLS } G_STMT_END struct _GUPnPServiceProxyAction { - GUPnPServiceProxy *proxy; char *name; gint header_pos; diff --git a/libgupnp/gupnp-service-proxy-action.c b/libgupnp/gupnp-service-proxy-action.c index cd9daf1..4aff616 100644 --- a/libgupnp/gupnp-service-proxy-action.c +++ b/libgupnp/gupnp-service-proxy-action.c @@ -234,11 +234,6 @@ gupnp_service_proxy_action_ref (GUPnPServiceProxyAction *action) static void action_dispose (GUPnPServiceProxyAction *action) { - if (action->proxy != NULL) { - g_object_remove_weak_pointer (G_OBJECT (action->proxy), - (gpointer *)&(action->proxy)); - gupnp_service_proxy_remove_action (action->proxy, action); - } if (action->cancellable != NULL && action->cancellable_connection_id != 0) { g_cancellable_disconnect (action->cancellable, diff --git a/libgupnp/gupnp-service-proxy.c b/libgupnp/gupnp-service-proxy.c index 310da07..0c52c17 100644 --- a/libgupnp/gupnp-service-proxy.c +++ b/libgupnp/gupnp-service-proxy.c @@ -96,18 +96,6 @@ subscribe (GUPnPServiceProxy *proxy); static void unsubscribe (GUPnPServiceProxy *proxy); -void -gupnp_service_proxy_remove_action (GUPnPServiceProxy *proxy, - GUPnPServiceProxyAction *action) -{ - GUPnPServiceProxyPrivate *priv; - - priv = gupnp_service_proxy_get_instance_private (proxy); - - priv->pending_actions = g_list_remove (priv->pending_actions, - action); -} - static void callback_data_free (CallbackData *data) { @@ -480,7 +468,7 @@ prepare_action_msg (GUPnPServiceProxy *proxy, } static void -gupnp_service_proxy_action_queue_task (GTask *task); +gupnp_service_proxy_action_queue_task (GUPnPServiceProxy *proxy, GTask *task); static void action_task_got_response (GObject *source, @@ -490,6 +478,7 @@ action_task_got_response (GObject *source, GTask *task = G_TASK (user_data); GError *error = NULL; GUPnPServiceProxyAction *action = (GUPnPServiceProxyAction *) g_task_get_task_data (task); + GUPnPServiceProxy *proxy = GUPNP_SERVICE_PROXY(g_task_get_source_object (task)); action->response = soup_session_send_and_read_finish (SOUP_SESSION (source), @@ -518,7 +507,7 @@ action_task_got_response (GObject *source, g_debug ("POST returned with METHOD_NOT_ALLOWED, " "trying with M-POST"); g_bytes_unref (action->response); - if (!prepare_action_msg (action->proxy, + if (!prepare_action_msg (proxy, action, "M-POST", &error)) { @@ -532,7 +521,7 @@ action_task_got_response (GObject *source, g_object_unref (task); } else { - gupnp_service_proxy_action_queue_task (task); + gupnp_service_proxy_action_queue_task (proxy, task); } } else { @@ -568,7 +557,7 @@ action_task_got_response (GObject *source, } static void -gupnp_service_proxy_action_queue_task (GTask *task) +gupnp_service_proxy_action_queue_task (GUPnPServiceProxy *proxy, GTask *task) { GUPnPContext *context; SoupSession *session; @@ -576,7 +565,7 @@ gupnp_service_proxy_action_queue_task (GTask *task) /* Send the message */ context = gupnp_service_info_get_context - (GUPNP_SERVICE_INFO (action->proxy)); + (GUPNP_SERVICE_INFO (proxy)); session = gupnp_context_get_session (context); soup_session_send_and_read_async ( @@ -1642,8 +1631,6 @@ gupnp_service_proxy_call_action_async (GUPnPServiceProxy *proxy, g_task_return_error (task, error); g_object_unref (task); } else { - action->proxy = proxy; - g_object_add_weak_pointer (G_OBJECT (proxy), (gpointer *)&(action->proxy)); priv->pending_actions = g_list_prepend (priv->pending_actions, action); @@ -1657,7 +1644,7 @@ gupnp_service_proxy_call_action_async (GUPnPServiceProxy *proxy, action, NULL); - gupnp_service_proxy_action_queue_task (task); + gupnp_service_proxy_action_queue_task (proxy, task); } } @@ -1681,8 +1668,6 @@ gupnp_service_proxy_call_action_finish (GUPnPServiceProxy *proxy, g_return_val_if_fail (g_task_is_valid (G_TASK (result), proxy), NULL); GUPnPServiceProxyAction *action = g_task_get_task_data (G_TASK (result)); - gupnp_service_proxy_remove_action (action->proxy, action); - g_clear_weak_pointer (&action->proxy); action->pending = FALSE; return g_task_propagate_pointer (G_TASK (result), error); |