gdbusinterfaceskeleton: Remove an unnecessary helper struct member

The `GDBusInterfaceSkeleton` is already stored as the source object of
the `GTask` here, with a strong reference.

Storing it again in the task’s data struct is redundant, and makes it
look like the `GDBusInterfaceSkeleton` is being used without holding a
strong reference. (There’s not actually a bug there though: the strong
reference from the `GTask` outlives the data struct, so is sufficient.)

Remove the unnecessary helper struct member to clarify the code a bit.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2924
This commit is contained in:
Philip Withnall 2023-02-22 12:40:49 +00:00
parent 290c4b7709
commit d90fbc3636

View File

@ -461,7 +461,6 @@ dbus_interface_interface_init (GDBusInterfaceIface *iface)
typedef struct typedef struct
{ {
gint ref_count; /* (atomic) */ gint ref_count; /* (atomic) */
GDBusInterfaceSkeleton *interface;
GDBusInterfaceMethodCallFunc method_call_func; GDBusInterfaceMethodCallFunc method_call_func;
GDBusMethodInvocation *invocation; GDBusMethodInvocation *invocation;
} DispatchData; } DispatchData;
@ -502,16 +501,17 @@ dispatch_in_thread_func (GTask *task,
GCancellable *cancellable) GCancellable *cancellable)
{ {
DispatchData *data = task_data; DispatchData *data = task_data;
GDBusInterfaceSkeleton *interface = g_task_get_source_object (task);
GDBusInterfaceSkeletonFlags flags; GDBusInterfaceSkeletonFlags flags;
GDBusObject *object; GDBusObject *object;
gboolean authorized; gboolean authorized;
g_mutex_lock (&data->interface->priv->lock); g_mutex_lock (&interface->priv->lock);
flags = data->interface->priv->flags; flags = interface->priv->flags;
object = data->interface->priv->object; object = interface->priv->object;
if (object != NULL) if (object != NULL)
g_object_ref (object); g_object_ref (object);
g_mutex_unlock (&data->interface->priv->lock); g_mutex_unlock (&interface->priv->lock);
/* first check on the enclosing object (if any), then the interface */ /* first check on the enclosing object (if any), then the interface */
authorized = TRUE; authorized = TRUE;
@ -519,13 +519,13 @@ dispatch_in_thread_func (GTask *task,
{ {
g_signal_emit_by_name (object, g_signal_emit_by_name (object,
"authorize-method", "authorize-method",
data->interface, interface,
data->invocation, data->invocation,
&authorized); &authorized);
} }
if (authorized) if (authorized)
{ {
g_signal_emit (data->interface, g_signal_emit (interface,
signals[G_AUTHORIZE_METHOD_SIGNAL], signals[G_AUTHORIZE_METHOD_SIGNAL],
0, 0,
data->invocation, data->invocation,
@ -627,7 +627,6 @@ g_dbus_interface_method_dispatch_helper (GDBusInterfaceSkeleton *interface
DispatchData *data; DispatchData *data;
data = g_slice_new0 (DispatchData); data = g_slice_new0 (DispatchData);
data->interface = interface;
data->method_call_func = method_call_func; data->method_call_func = method_call_func;
data->invocation = invocation; data->invocation = invocation;
data->ref_count = 1; data->ref_count = 1;