Bug 48230

Summary: [next] tp_am_set_default() should keep a weak ref instead of strong ref
Product: Telepathy Reporter: Xavier Claessens <xclaesse>
Component: tp-glibAssignee: Telepathy bugs list <telepathy-bugs>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium CC: xclaesse
Version: unspecifiedKeywords: patch
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 31668    
Attachments: tp_am_set_default(): Take a weak ref instead of a strong one

Description Xavier Claessens 2012-04-03 03:01:46 UTC
tp_account_manager_set_default() adds an internal ref to @manager that can't be be dropped. This can be annoying to debug leaks. Usually we only keep weak ref to singletons, like tp_account_manager_dup() does.

Note: from a quick look, empathy actually depend on this behaviour since empathy_init() does not keep the initial ref on its AM. So when/if fixing this bug, we need to make sure to fix that in empathy too.
Comment 1 Xavier Claessens 2012-04-25 07:41:03 UTC
Created attachment 60571 [details] [review]
tp_am_set_default(): Take a weak ref instead of a strong one
Comment 2 Jonny Lamb 2012-04-25 07:56:31 UTC
Comment on attachment 60571 [details] [review]
tp_am_set_default(): Take a weak ref instead of a strong one

Review of attachment 60571 [details] [review]:
-----------------------------------------------------------------

Looks good, but I've slightly re-worded your doc.

::: telepathy-glib/account-manager.c
@@ +786,5 @@
>   * tp_account_manager_new_with_factory().
>   *
> + * Only a weak reference is taken on @manager, it is caller's responsability to
> + * keep it alive. Otherwise next call to tp_account_manager_dup() will return
> + * a newly created #TpAccountManager.

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.
Comment 3 Xavier Claessens 2012-04-25 08:19:54 UTC
Thanks, merged with your text.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.