[geary/wip/disconnect-lambdas-726295] Disconnect lambdas on shutdown



commit fedc984a9d3dacb1f517ee2a56f39e6de7455ff3
Author: Charles Lindsay <chaz yorba org>
Date:   Fri Mar 14 11:09:11 2014 -0700

    Disconnect lambdas on shutdown
    
    We're getting warnings about unref-ing already unref-ed g_closures when
    the conversation viewer gets destructed.  Maybe this'll fix the problem.

 .../conversation-viewer/conversation-viewer.vala   |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-viewer.vala 
b/src/client/conversation-viewer/conversation-viewer.vala
index d81fb1c..e7fea71 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -148,6 +148,7 @@ public class ConversationViewer : Gtk.Box {
     private Geary.State.Machine fsm;
     private DisplayMode display_mode = DisplayMode.NONE;
     private uint select_conversation_timeout_id = 0;
+    private Gee.ArrayList<ulong> closure_connections = new Gee.ArrayList<ulong>();
     
     public ConversationViewer() {
         Object(orientation: Gtk.Orientation.VERTICAL, spacing: 0);
@@ -180,11 +181,14 @@ public class ConversationViewer : Gtk.Box {
         
GearyApplication.instance.controller.conversation_count_changed.connect(on_conversation_count_changed);
         
         web_view.hovering_over_link.connect(on_hovering_over_link);
-        web_view.context_menu.connect(() => { return true; }); // Suppress default context menu.
-        web_view.realize.connect( () => { web_view.get_vadjustment().value_changed.connect(mark_read); });
+        closure_connections.add(
+            web_view.context_menu.connect(() => { return true; })); // Suppress default context menu.
+        closure_connections.add(
+            web_view.realize.connect( () => { web_view.get_vadjustment().value_changed.connect(mark_read); 
}));
         web_view.size_allocate.connect(mark_read);
 
-        web_view.link_selected.connect((link) => { link_selected(link); });
+        closure_connections.add(
+            web_view.link_selected.connect((link) => { link_selected(link); }));
         
         Gtk.ScrolledWindow conversation_viewer_scrolled = new Gtk.ScrolledWindow(null, null);
         conversation_viewer_scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
@@ -196,11 +200,17 @@ public class ConversationViewer : Gtk.Box {
         
         conversation_find_bar = new ConversationFindBar(web_view);
         conversation_find_bar.no_show_all = true;
-        conversation_find_bar.close.connect(() => { fsm.issue(SearchEvent.CLOSE_FIND_BAR); });
+        closure_connections.add(
+            conversation_find_bar.close.connect(() => { fsm.issue(SearchEvent.CLOSE_FIND_BAR); }));
         
         pack_start(conversation_find_bar, false);
     }
     
+    ~ConversationViewer() {
+        foreach (ulong id in closure_connections)
+            disconnect(id);
+    }
+    
     public Geary.Email? get_last_message() {
         return messages.is_empty ? null : messages.last();
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]