Skip to content

Commit

Permalink
Merge pull request #1600 from sdroege/gdbus-register-object-with-clos…
Browse files Browse the repository at this point in the history
…ures-memleak

gio: Work around GLib memory leak in g_dbus_connection_register_objec…
  • Loading branch information
sdroege authored Dec 13, 2024
2 parents 290a41e + 4194b22 commit 83f2e55
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 83f2e55

Please sign in to comment.