Skip to content

Commit 83f2e55

Browse files
authored
Merge pull request #1600 from sdroege/gdbus-register-object-with-closures-memleak
gio: Work around GLib memory leak in g_dbus_connection_register_objec…
2 parents 290a41e + 4194b22 commit 83f2e55

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

gio/src/dbus_connection.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,19 @@ impl<'a> RegistrationBuilder<'a> {
218218
let interface_name = args[3].get::<Option<&str>>().unwrap();
219219
let method_name = args[4].get::<&str>().unwrap();
220220
let parameters = args[5].get::<glib::Variant>().unwrap();
221-
let invocation = args[6].get::<DBusMethodInvocation>().unwrap();
221+
222+
// Work around GLib memory leak: Assume that the invocation is passed
223+
// as `transfer full` into the closure.
224+
//
225+
// This workaround is not going to break with future versions of
226+
// GLib as fixing the bug was considered a breaking API change.
227+
//
228+
// See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4427
229+
let invocation = from_glib_full(glib::gobject_ffi::g_value_get_object(
230+
args[6].as_ptr(),
231+
)
232+
as *mut ffi::GDBusMethodInvocation);
233+
222234
f(
223235
conn,
224236
sender,

0 commit comments

Comments
 (0)