diff options
author | fiaxh <git@mx.ax.lt> | 2017-11-22 21:09:39 +0100 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2017-11-23 01:28:29 +0100 |
commit | 64774241e587eab64b10a0c35dd455f6a2288a55 (patch) | |
tree | e019252bce51a684dc1c97c97d897a193715d360 /main/src/ui/conversation_summary | |
parent | 9165c4db278b2d3da636d53e89c3b80cff66977f (diff) | |
download | dino-64774241e587eab64b10a0c35dd455f6a2288a55.tar.gz dino-64774241e587eab64b10a0c35dd455f6a2288a55.zip |
Fix memory leak
Diffstat (limited to 'main/src/ui/conversation_summary')
3 files changed, 13 insertions, 5 deletions
diff --git a/main/src/ui/conversation_summary/conversation_item_skeleton.vala b/main/src/ui/conversation_summary/conversation_item_skeleton.vala index ed540e5d..03e9facb 100644 --- a/main/src/ui/conversation_summary/conversation_item_skeleton.vala +++ b/main/src/ui/conversation_summary/conversation_item_skeleton.vala @@ -46,7 +46,8 @@ public class ConversationItemSkeleton : Grid { } public void remove_meta_item(Plugins.MetaConversationItem item) { - box.remove(item_widgets[item]); + item_widgets[item].destroy(); + item_widgets.unset(item); items.remove(item); } diff --git a/main/src/ui/conversation_summary/conversation_view.vala b/main/src/ui/conversation_summary/conversation_view.vala index 5aeb27fc..15a86ca7 100644 --- a/main/src/ui/conversation_summary/conversation_view.vala +++ b/main/src/ui/conversation_summary/conversation_view.vala @@ -84,9 +84,10 @@ public class ConversationView : Box, Plugins.ConversationItemCollection { if (skeleton.items.size > 1) { skeleton.remove_meta_item(item); } else { - main.remove(widgets[item]); + widgets[item].destroy(); widgets.unset(item); - item_skeletons.remove(item_item_skeletons[item]); + skeleton.destroy(); + item_skeletons.remove(skeleton); item_item_skeletons.unset(item); } meta_items.remove(item); @@ -233,7 +234,8 @@ public class ConversationView : Box, Plugins.ConversationItemCollection { meta_after_items.clear(); item_skeletons.clear(); item_item_skeletons.clear(); - main.@foreach((widget) => { main.remove(widget); }); + widgets.clear(); + main.@foreach((widget) => { widget.destroy(); }); } } diff --git a/main/src/ui/conversation_summary/message_populator.vala b/main/src/ui/conversation_summary/message_populator.vala index dc4b5770..df44a14b 100644 --- a/main/src/ui/conversation_summary/message_populator.vala +++ b/main/src/ui/conversation_summary/message_populator.vala @@ -55,8 +55,13 @@ public class MessagePopulator : Object { if (meta_item == null) return; meta_item.mark = message.marked; + WeakRef weak_meta_item = WeakRef(meta_item); + WeakRef weak_message = WeakRef(message); message.notify["marked"].connect(() => { - meta_item.mark = message.marked; + Plugins.MetaConversationItem? mi = weak_meta_item.get() as Plugins.MetaConversationItem; + Message? m = weak_message.get() as Message; + if (mi == null || m == null) return; + mi.mark = m.marked; }); item_collection.insert_item(meta_item); } |