[Pkg-telepathy-commits] [telepathy-glib-1] 204/212: Make TpWeakRef use GWeakRef

Simon McVittie smcv at debian.org
Wed May 14 12:09:15 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository telepathy-glib-1.

commit c426d3352fcae3cc37c6abc0e88d8cdc49043289
Author: Xavier Claessens <xavier.claessens at collabora.co.uk>
Date:   Wed Apr 16 20:39:45 2014 +0100

    Make TpWeakRef use GWeakRef
---
 telepathy-glib/util.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/telepathy-glib/util.c b/telepathy-glib/util.c
index 3fd63d4..a3f36d7 100644
--- a/telepathy-glib/util.c
+++ b/telepathy-glib/util.c
@@ -584,13 +584,13 @@ _tp_quark_array_copy (const GQuark *quarks)
  * common in practice.
  *
  * If more than one piece of auxiliary data is required, the @user_data
- * argument to the constructor can be a struct or a #GValueArray.
+ * argument to the constructor can be a struct.
  *
  * Since: 0.11.3
  */
 struct _TpWeakRef {
     /*<private>*/
-    gpointer object;
+    GWeakRef object;
     gpointer user_data;
     GDestroyNotify destroy;
 };
@@ -620,8 +620,7 @@ tp_weak_ref_new (gpointer object,
   g_return_val_if_fail (G_IS_OBJECT (object), NULL);
 
   self = g_slice_new (TpWeakRef);
-  self->object = object;
-  g_object_add_weak_pointer (self->object, &self->object);
+  g_weak_ref_init (&self->object, object);
   self->user_data = user_data;
   self->destroy = destroy;
   return self;
@@ -658,10 +657,7 @@ tp_weak_ref_get_user_data (TpWeakRef *self)
 gpointer
 tp_weak_ref_dup_object (TpWeakRef *self)
 {
-  if (self->object != NULL)
-    return g_object_ref (self->object);
-
-  return NULL;
+  return g_weak_ref_get (&self->object);
 }
 
 /**
@@ -677,8 +673,7 @@ tp_weak_ref_dup_object (TpWeakRef *self)
 void
 tp_weak_ref_destroy (TpWeakRef *self)
 {
-  if (self->object != NULL)
-    g_object_remove_weak_pointer (self->object, &self->object);
+  g_weak_ref_clear (&self->object);
 
   if (self->destroy != NULL)
     (self->destroy) (self->user_data);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/telepathy-glib-1.git



More information about the Pkg-telepathy-commits mailing list