Skip to content

Commit

Permalink
gio: Work around GLib memory leak in g_dbus_connection_register_objec…
Browse files Browse the repository at this point in the history
…t_with_closures()

Assume that the invocation is passed as `transfer full` into the
closure.

This workaround is not going to break with future versions of
GLib as fixing the bug was considered a breaking API change.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4427
  • Loading branch information
sdroege committed Dec 16, 2024
1 parent a806de5 commit 99b1722
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion gio/src/dbus_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,19 @@ impl<'a> RegistrationBuilder<'a> {
let interface_name = args[3].get::<Option<&str>>().unwrap();
let method_name = args[4].get::<&str>().unwrap();
let parameters = args[5].get::<glib::Variant>().unwrap();
let invocation = args[6].get::<DBusMethodInvocation>().unwrap();

// Work around GLib memory leak: Assume that the invocation is passed
// as `transfer full` into the closure.
//
// This workaround is not going to break with future versions of
// GLib as fixing the bug was considered a breaking API change.
//
// See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4427
let invocation = from_glib_full(glib::gobject_ffi::g_value_get_object(
args[6].as_ptr(),
)
as *mut ffi::GDBusMethodInvocation);

f(
conn,
sender,
Expand Down

0 comments on commit 99b1722

Please sign in to comment.