[glib] GDBusInterfaceSkeleton: fix odd use of floating refs
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GDBusInterfaceSkeleton: fix odd use of floating refs
- Date: Tue, 12 Jul 2011 17:44:46 +0000 (UTC)
commit 8f5e0cd24016cdf852a809dfb7b1356328542201
Author: Ryan Lortie <desrt desrt ca>
Date: Tue Jul 12 02:56:57 2011 +0200
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
gio/gdbusinterfaceskeleton.c | 5 ++---
gio/gdbusinterfaceskeleton.h | 2 +-
gio/gdbusobjectmanagerserver.c | 18 ++++++++++--------
3 files changed, 13 insertions(+), 12 deletions(-)
---
diff --git a/gio/gdbusinterfaceskeleton.c b/gio/gdbusinterfaceskeleton.c
index 3695c15..6c7ba7d 100644
--- a/gio/gdbusinterfaceskeleton.c
+++ b/gio/gdbusinterfaceskeleton.c
@@ -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);
}
/**
diff --git a/gio/gdbusinterfaceskeleton.h b/gio/gdbusinterfaceskeleton.h
index ff322e1..69dcc2f 100644
--- a/gio/gdbusinterfaceskeleton.h
+++ b/gio/gdbusinterfaceskeleton.h
@@ -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.
*
diff --git a/gio/gdbusobjectmanagerserver.c b/gio/gdbusobjectmanagerserver.c
index 7f71b24..065eace 100644
--- a/gio/gdbusobjectmanagerserver.c
+++ b/gio/gdbusobjectmanagerserver.c
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]