[next] telepathy-glib: tp_asv_to_vardict: return a floating ref

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Fri Feb 28 06:25:07 PST 2014


Module: telepathy-glib
Branch: next
Commit: 5abda8fc4560696c852991454b3193586bf97736
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=5abda8fc4560696c852991454b3193586bf97736

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Fri Feb 28 14:59:16 2014 +0100

tp_asv_to_vardict: return a floating ref

---

 telepathy-glib/account-channel-request.c |    2 +-
 telepathy-glib/account.c                 |    8 +++++---
 telepathy-glib/channel.c                 |    3 ++-
 telepathy-glib/client-factory.c          |    1 +
 telepathy-glib/connection.c              |    2 +-
 telepathy-glib/contact.c                 |    2 +-
 telepathy-glib/dbus-tube-channel.c       |    3 ++-
 telepathy-glib/message.c                 |    3 ++-
 telepathy-glib/stream-tube-channel.c     |    3 ++-
 telepathy-glib/tls-certificate.c         |    1 +
 telepathy-glib/variant-util.c            |    6 +++---
 tests/asv.c                              |    1 +
 12 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/telepathy-glib/account-channel-request.c b/telepathy-glib/account-channel-request.c
index 6f48655..f0fff11 100644
--- a/telepathy-glib/account-channel-request.c
+++ b/telepathy-glib/account-channel-request.c
@@ -552,7 +552,7 @@ tp_account_channel_request_dup_request (
 {
   g_return_val_if_fail (TP_IS_ACCOUNT_CHANNEL_REQUEST (self), NULL);
 
-  return tp_asv_to_vardict (self->priv->request);
+  return g_variant_ref_sink (tp_asv_to_vardict (self->priv->request));
 }
 
 /**
diff --git a/telepathy-glib/account.c b/telepathy-glib/account.c
index b578ee6..dc953db 100644
--- a/telepathy-glib/account.c
+++ b/telepathy-glib/account.c
@@ -930,7 +930,7 @@ _tp_account_update (TpAccount *account,
       if (priv->parameters != NULL)
         g_variant_unref (priv->parameters);
 
-      priv->parameters = tp_asv_to_vardict (parameters);
+      priv->parameters = g_variant_ref_sink (tp_asv_to_vardict (parameters));
       /* this isn't a property, so we don't notify */
     }
 
@@ -3649,7 +3649,8 @@ tp_account_dup_detailed_error (TpAccount *self,
     return NULL;
 
   if (details != NULL)
-    *details = tp_asv_to_vardict (self->priv->error_details);
+    *details = g_variant_ref_sink (
+        tp_asv_to_vardict (self->priv->error_details));
 
   return g_strdup (self->priv->error);
 }
@@ -3730,7 +3731,8 @@ _tp_account_get_storage_specific_information_cb (TpProxy *self,
       GHashTable *asv = g_value_get_boxed (value);
 
       g_simple_async_result_set_op_res_gpointer (result,
-          tp_asv_to_vardict (asv), (GDestroyNotify) g_variant_unref);
+          g_variant_ref_sink (tp_asv_to_vardict (asv)),
+          (GDestroyNotify) g_variant_unref);
     }
 
   g_simple_async_result_complete (result);
diff --git a/telepathy-glib/channel.c b/telepathy-glib/channel.c
index e212aca..f0500bc 100644
--- a/telepathy-glib/channel.c
+++ b/telepathy-glib/channel.c
@@ -345,7 +345,8 @@ tp_channel_dup_immutable_properties (TpChannel *self)
 {
   g_return_val_if_fail (TP_IS_CHANNEL (self), NULL);
 
-  return tp_asv_to_vardict (self->priv->channel_properties);
+  return g_variant_ref_sink (
+      tp_asv_to_vardict (self->priv->channel_properties));
 }
 
 /**
diff --git a/telepathy-glib/client-factory.c b/telepathy-glib/client-factory.c
index 0e5f602..8187878 100644
--- a/telepathy-glib/client-factory.c
+++ b/telepathy-glib/client-factory.c
@@ -1160,6 +1160,7 @@ _tp_client_factory_ensure_channel_request (TpClientFactory *self,
 
   props = tp_asv_to_vardict (immutable_properties);
 
+  g_variant_ref_sink (props);
   request = _tp_channel_request_new_with_factory (self, self->priv->dbus,
       object_path, props, error);
   g_variant_unref (props);
diff --git a/telepathy-glib/connection.c b/telepathy-glib/connection.c
index 09ee97d..754c7ca 100644
--- a/telepathy-glib/connection.c
+++ b/telepathy-glib/connection.c
@@ -2633,7 +2633,7 @@ tp_connection_dup_detailed_error (TpConnection *self,
     return NULL;
 
   if (details != NULL)
-    *details = tp_asv_to_vardict (asv);
+    *details = g_variant_ref_sink (tp_asv_to_vardict (asv));
 
   return g_strdup (error);
 }
diff --git a/telepathy-glib/contact.c b/telepathy-glib/contact.c
index 7c27689..95665e7 100644
--- a/telepathy-glib/contact.c
+++ b/telepathy-glib/contact.c
@@ -1812,7 +1812,7 @@ contact_maybe_set_location (TpContact *self,
     g_hash_table_ref (location);
 
   self->priv->has_features |= CONTACT_FEATURE_FLAG_LOCATION;
-  self->priv->location = tp_asv_to_vardict (location);
+  self->priv->location = g_variant_ref_sink (tp_asv_to_vardict (location));
   g_object_notify ((GObject *) self, "location");
   g_hash_table_unref (location);
 }
diff --git a/telepathy-glib/dbus-tube-channel.c b/telepathy-glib/dbus-tube-channel.c
index 8dbe50c..8e84753 100644
--- a/telepathy-glib/dbus-tube-channel.c
+++ b/telepathy-glib/dbus-tube-channel.c
@@ -313,7 +313,8 @@ tp_dbus_tube_channel_constructed (GObject *obj)
         }
       else
         {
-          self->priv->parameters = tp_asv_to_vardict (params);
+          self->priv->parameters = g_variant_ref_sink (
+              tp_asv_to_vardict (params));
         }
     }
 
diff --git a/telepathy-glib/message.c b/telepathy-glib/message.c
index 2d6a3bb..c0face0 100644
--- a/telepathy-glib/message.c
+++ b/telepathy-glib/message.c
@@ -179,7 +179,8 @@ tp_message_dup_part (TpMessage *self,
   if (part >= self->parts->len)
     return NULL;
 
-  return tp_asv_to_vardict (g_ptr_array_index (self->parts, part));
+  return g_variant_ref_sink (tp_asv_to_vardict (g_ptr_array_index (
+          self->parts, part)));
 }
 
 
diff --git a/telepathy-glib/stream-tube-channel.c b/telepathy-glib/stream-tube-channel.c
index c6f0e87..db81322 100644
--- a/telepathy-glib/stream-tube-channel.c
+++ b/telepathy-glib/stream-tube-channel.c
@@ -398,7 +398,8 @@ tp_stream_tube_channel_constructed (GObject *obj)
         }
       else
         {
-          self->priv->parameters = tp_asv_to_vardict (params);
+          self->priv->parameters = g_variant_ref_sink (
+              tp_asv_to_vardict (params));
         }
     }
 
diff --git a/telepathy-glib/tls-certificate.c b/telepathy-glib/tls-certificate.c
index 35a600a..86700b9 100644
--- a/telepathy-glib/tls-certificate.c
+++ b/telepathy-glib/tls-certificate.c
@@ -184,6 +184,7 @@ tp_tls_certificate_rejected_cb (TpTLSCertificate *self,
 
           vardict = tp_asv_to_vardict (details);
 
+          g_variant_ref_sink (vardict);
           rej = _tp_tls_certificate_rejection_new (error,
               reason, error_name, vardict);
 
diff --git a/telepathy-glib/variant-util.c b/telepathy-glib/variant-util.c
index a17e49b..0541fbe 100644
--- a/telepathy-glib/variant-util.c
+++ b/telepathy-glib/variant-util.c
@@ -56,13 +56,13 @@
  * Convert a #TP_HASH_TYPE_STRING_VARIANT_MAP to a #GVariant of type
  * %G_VARIANT_TYPE_VARDICT
  *
- * Returns: (transfer full): a #GVariant of type %G_VARIANT_TYPE_VARDICT
+ * Returns: a new floating #GVariant of type %G_VARIANT_TYPE_VARDICT
  **/
 GVariant *
 tp_asv_to_vardict (const GHashTable *asv)
 {
-  return g_variant_ref_sink (_tp_boxed_to_variant (
-        TP_HASH_TYPE_STRING_VARIANT_MAP, "a{sv}", (gpointer) asv));
+  return _tp_boxed_to_variant (TP_HASH_TYPE_STRING_VARIANT_MAP, "a{sv}",
+      (gpointer) asv);
 }
 
 GVariant *
diff --git a/tests/asv.c b/tests/asv.c
index 3c04bdb..0275a21 100644
--- a/tests/asv.c
+++ b/tests/asv.c
@@ -114,6 +114,7 @@ int main (int argc, char **argv)
   tp_asv_dump (hash);
 
   vardict = tp_asv_to_vardict (hash);
+  g_variant_ref_sink (vardict);
 
   /* Tests: tp_asv_get_boolean */
 



More information about the telepathy-commits mailing list