GNOME Bugzilla – Bug 677641
Use a weak reference while loading the logs asynchronously to detect when the object has been destroyed
Last modified: 2012-06-11 11:21:01 UTC
chat_add_logs gets invoked from the constructed method to asynchronously load the logs. Hold a reference to avoid hitting finalize before the callback is invoked.
Created attachment 215860 [details] [review] empathy-chat: hold a reference while loading logs
Review of attachment 215860 [details] [review]: The callback is pretty useless if the widget has been destroyed right? The logs won't be displayed. I think it's best to use TpWeakRef instead and so early return in the callback if the chat has been destroyed. See for example http://git.gnome.org/browse/empathy/commit/?id=0e095b8af9cd07ae32823f73b889fdbfb47d6f2a
Created attachment 215965 [details] [review] empathy-chat: abort got_filtered_messages_cb if object was destroyed
Created attachment 215967 [details] [review] empathy-chat: abort chat_log_filter if object was destroyed
Review of attachment 215965 [details] [review]: ::: libempathy-gtk/empathy-chat.c @@ +2550,3 @@ GList *messages; + TpWeakRef *wr = user_data; + EmpathyChat *chat = tp_weak_ref_dup_object (wr); the ref on chat is leaked if the object isn't destroyed: dup_object returns a new ref.
Review of attachment 215967 [details] [review]: ::: libempathy-gtk/empathy-chat.c @@ +2498,3 @@ { + TpWeakRef *wr = user_data; + EmpathyChat *chat = tp_weak_ref_dup_object (wr); same problem, chat is leaked.
Created attachment 216102 [details] [review] empathy-chat: abort got_filtered_messages_cb if object was destroyed
Created attachment 216103 [details] [review] empathy-chat: abort chat_log_filter if object was destroyed
Created attachment 216104 [details] [review] empathy-chat: abort got_filtered_messages_cb if object was destroyed
++
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.