Commit 8f5e0cd2 authored by Allison Karlitskaya's avatar Allison Karlitskaya

GDBusInterfaceSkeleton: fix odd use of floating refs

The get_properties() function was documented as returning a floating

Switch it over to returning a normal reference and patch a couple of
uses.

https://bugzilla.gnome.org/show_bug.cgi?id=654394
parent 58c247e5
......@@ -320,7 +320,7 @@ g_dbus_interface_skeleton_get_vtable (GDBusInterfaceSkeleton *interface_)
*
* Gets all D-Bus properties for @interface_.
*
* Returns: A new, floating, #GVariant of type <link linkend="G-VARIANT-TYPE-VARDICT:CAPS">'a{sv}'</link>. Free with g_variant_unref().
* Returns: (transfer full): A #GVariant of type <link linkend="G-VARIANT-TYPE-VARDICT:CAPS">'a{sv}'</link>. Free with g_variant_unref().
*
* Since: 2.30
*/
......@@ -330,8 +330,7 @@ g_dbus_interface_skeleton_get_properties (GDBusInterfaceSkeleton *interface_)
GVariant *ret;
g_return_val_if_fail (G_IS_DBUS_INTERFACE_SKELETON (interface_), NULL);
ret = G_DBUS_INTERFACE_SKELETON_GET_CLASS (interface_)->get_properties (interface_);
g_warn_if_fail (g_variant_is_floating (ret));
return ret;
return g_variant_take_ref (ret);
}
/**
......
......@@ -57,7 +57,7 @@ struct _GDBusInterfaceSkeleton
* @parent_class: The parent class.
* @get_info: Returns a #GDBusInterfaceInfo. See g_dbus_interface_skeleton_get_info() for details.
* @get_vtable: Returns a #GDBusInterfaceVTable. See g_dbus_interface_skeleton_get_vtable() for details.
* @get_properties: Returns a new, floating, #GVariant with all properties. See g_dbus_interface_skeleton_get_properties().
* @get_properties: Returns a #GVariant with all properties. See g_dbus_interface_skeleton_get_properties().
* @flush: Emits outstanding changes, if any. See g_dbus_interface_skeleton_flush().
* @g_authorize_method: Signal class handler for the #GDBusInterfaceSkeleton::g-authorize-method signal.
*
......
......@@ -760,10 +760,11 @@ manager_method_call (GDBusConnection *connection,
g_hash_table_iter_init (&interface_iter, data->map_iface_name_to_iface);
while (g_hash_table_iter_next (&interface_iter, NULL, (gpointer) &iface))
{
g_variant_builder_add_value (&interfaces_builder,
g_variant_new ("{s@a{sv}}",
g_dbus_interface_skeleton_get_info (iface)->name,
g_dbus_interface_skeleton_get_properties (iface)));
GVariant *properties = g_dbus_interface_skeleton_get_properties (iface);
g_variant_builder_add (&interfaces_builder, "{s@a{sv}}",
g_dbus_interface_skeleton_get_info (iface)->name,
properties);
g_variant_unref (properties);
}
iter_object_path = g_dbus_object_get_object_path (G_DBUS_OBJECT (data->object));
g_variant_builder_add (&array_builder,
......@@ -824,12 +825,13 @@ g_dbus_object_manager_server_emit_interfaces_added (GDBusObjectManagerServer *ma
for (n = 0; interfaces[n] != NULL; n++)
{
GDBusInterfaceSkeleton *iface;
GVariant *properties;
iface = g_hash_table_lookup (data->map_iface_name_to_iface, interfaces[n]);
g_assert (iface != NULL);
g_variant_builder_add_value (&array_builder,
g_variant_new ("{s@a{sv}}",
interfaces[n],
g_dbus_interface_skeleton_get_properties (iface)));
properties = g_dbus_interface_skeleton_get_properties (iface);
g_variant_builder_add (&array_builder, "{s@a{sv}}", interfaces[n], properties);
g_variant_unref (properties);
}
error = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment