[next] telepathy-glib: tp_am_set_default(): Take a weak ref instead of a strong one

Xavier Claessens xclaesse at kemper.freedesktop.org
Wed Apr 25 08:19:21 PDT 2012


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

Author: Xavier Claessens <xavier.claessens at collabora.co.uk>
Date:   Wed Apr 25 16:39:21 2012 +0200

tp_am_set_default(): Take a weak ref instead of a strong one

https://bugs.freedesktop.org/show_bug.cgi?id=48230

---

 telepathy-glib/account-manager.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/telepathy-glib/account-manager.c b/telepathy-glib/account-manager.c
index 33186ae..fa8900b 100644
--- a/telepathy-glib/account-manager.c
+++ b/telepathy-glib/account-manager.c
@@ -785,11 +785,13 @@ static gpointer starter_account_manager_proxy = NULL;
  * #TpAccountManager to use that factory should call this after calling
  * tp_account_manager_new_with_factory().
  *
- * Unlike tp_account_manager_dup(), this function will keep an internal
- * reference to @manager, so it will never be destroyed.
+ * Only a weak reference is taken on @manager. It is the caller's responsibility
+ * to keep it alive. If @manager is disposed after calling this function, the
+ * next call to tp_account_manager_dup() will return a newly created
+ * #TpAccountManager.
  *
  * Note that @manager must use the default #TpDBusDaemon as returned by
- * tp_dbus_daemon_dup()
+ * tp_dbus_daemon_dup().
  *
  * Since: 0.15.5
  */
@@ -812,7 +814,9 @@ tp_account_manager_set_default (TpAccountManager *manager)
       g_return_if_reached ();
     }
 
-  starter_account_manager_proxy = g_object_ref (manager);
+  starter_account_manager_proxy = manager;
+  g_object_add_weak_pointer (starter_account_manager_proxy,
+      &starter_account_manager_proxy);
 }
 
 /**



More information about the telepathy-commits mailing list