mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 15:03:39 +02:00
GDBusConnection: Document memory management semantics for get_property()
Turns out we are leaking non-floating GVariant instances returned by get_property() functions. Also avoid imprecise language such as "newly-allocated GVariant" as this doesn't specify whether the variant can be floating or not. Also see https://bugzilla.gnome.org/show_bug.cgi?id=627974 as it is very related to this change. Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
@@ -3635,7 +3635,8 @@ invoke_get_property_in_idle_cb (gpointer _data)
|
||||
{
|
||||
g_assert_no_error (error);
|
||||
|
||||
g_variant_ref_sink (value);
|
||||
if (g_variant_is_floating (value))
|
||||
g_variant_ref_sink (value);
|
||||
reply = g_dbus_message_new_method_reply (data->message);
|
||||
g_dbus_message_set_body (reply, g_variant_new ("(v)", value));
|
||||
g_dbus_connection_send_message (data->connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
|
||||
@@ -3966,10 +3967,13 @@ invoke_get_all_properties_in_idle_cb (gpointer _data)
|
||||
if (value == NULL)
|
||||
continue;
|
||||
|
||||
if (g_variant_is_floating (value))
|
||||
g_variant_ref_sink (value);
|
||||
g_variant_builder_add (&builder,
|
||||
"{sv}",
|
||||
property_info->name,
|
||||
value);
|
||||
g_variant_unref (value);
|
||||
}
|
||||
g_variant_builder_close (&builder);
|
||||
|
||||
|
Reference in New Issue
Block a user