mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-24 04:56:14 +01: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:
parent
d31c1c863a
commit
0d0a9bb448
@ -3635,6 +3635,7 @@ invoke_get_property_in_idle_cb (gpointer _data)
|
|||||||
{
|
{
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
|
|
||||||
|
if (g_variant_is_floating (value))
|
||||||
g_variant_ref_sink (value);
|
g_variant_ref_sink (value);
|
||||||
reply = g_dbus_message_new_method_reply (data->message);
|
reply = g_dbus_message_new_method_reply (data->message);
|
||||||
g_dbus_message_set_body (reply, g_variant_new ("(v)", value));
|
g_dbus_message_set_body (reply, g_variant_new ("(v)", value));
|
||||||
@ -3966,10 +3967,13 @@ invoke_get_all_properties_in_idle_cb (gpointer _data)
|
|||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (g_variant_is_floating (value))
|
||||||
|
g_variant_ref_sink (value);
|
||||||
g_variant_builder_add (&builder,
|
g_variant_builder_add (&builder,
|
||||||
"{sv}",
|
"{sv}",
|
||||||
property_info->name,
|
property_info->name,
|
||||||
value);
|
value);
|
||||||
|
g_variant_unref (value);
|
||||||
}
|
}
|
||||||
g_variant_builder_close (&builder);
|
g_variant_builder_close (&builder);
|
||||||
|
|
||||||
|
@ -221,7 +221,9 @@ typedef void (*GDBusInterfaceMethodCallFunc) (GDBusConnection *connection,
|
|||||||
*
|
*
|
||||||
* The type of the @get_property function in #GDBusInterfaceVTable.
|
* The type of the @get_property function in #GDBusInterfaceVTable.
|
||||||
*
|
*
|
||||||
* Returns: A newly-allocated #GVariant with the value for @property_name or %NULL if @error is set.
|
* Returns: A #GVariant with the value for @property_name or %NULL if
|
||||||
|
* @error is set. If the returned #GVariant is floating, it is
|
||||||
|
* consumed - otherwise its reference count is decreased by one.
|
||||||
*
|
*
|
||||||
* Since: 2.26
|
* Since: 2.26
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user