Bug 48230 - [next] tp_am_set_default() should keep a weak ref instead of strong ref
Summary: [next] tp_am_set_default() should keep a weak ref instead of strong ref
Status: RESOLVED FIXED
Alias: None
Product: Telepathy
Classification: Unclassified
Component: tp-glib (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Telepathy bugs list
QA Contact: Telepathy bugs list
URL:
Whiteboard:
Keywords: patch
Depends on:
Blocks: tp-glib-1.0
  Show dependency treegraph
 
Reported: 2012-04-03 03:01 UTC by Xavier Claessens
Modified: 2012-04-25 08:19 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
tp_am_set_default(): Take a weak ref instead of a strong one (1.45 KB, patch)
2012-04-25 07:41 UTC, Xavier Claessens
Details | Splinter Review

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.