Merge branch '3559-revert-dbus-method-invocation-refcounting' into 'main'

Revert "gdbus: Fix leak of method invocation when registering an object with closures"

Closes #3559

See merge request GNOME/glib!4427
This commit is contained in:
Philip Withnall
2024-12-11 12:41:16 +00:00
2 changed files with 12 additions and 19 deletions

View File

@@ -5951,7 +5951,12 @@ register_with_closures_on_method_call (GDBusConnection *connection,
g_value_set_variant (&params[5], parameters);
g_value_init (&params[6], G_TYPE_DBUS_METHOD_INVOCATION);
g_value_take_object (&params[6], g_steal_pointer (&invocation));
/* NOTE: This is deliberately *not* g_value_take_object(). A reference to
* `invocation` is transferred in to this function, and it needs to be
* transferred onwards to the `g_dbus_method_invocation_return_*()` method
* call which must eventually happen (either in the closure function, or in
* a delayed consequence from it). Changing this will break API. */
g_value_set_object (&params[6], invocation);
g_closure_invoke (data->method_call_closure, NULL, G_N_ELEMENTS (params), params, NULL);
@@ -6085,6 +6090,11 @@ register_with_closures_on_set_property (GDBusConnection *connection,
* Version of g_dbus_connection_register_object() using closures instead of a
* #GDBusInterfaceVTable for easier binding in other languages.
*
* Note that the reference counting semantics of the function wrapped by
* @method_call_closure are the same as those of
* [callback@Gio.DBusInterfaceMethodCallFunc]: ownership of a reference to the
* [class@Gio.DBusMethodInvocation] is transferred to the function.
*
* Returns: 0 if @error is set, otherwise a registration ID (never 0)
* that can be used with g_dbus_connection_unregister_object() .
*