mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-09 19:06:15 +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,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);
|
||||
|
||||
|
@ -221,7 +221,9 @@ typedef void (*GDBusInterfaceMethodCallFunc) (GDBusConnection *connection,
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user