[geary/wip/765516-gtk-widget-conversation-viewer: 126/207] Fix some critical warnings during object destruction.



commit 440368734d79d2e8d8b1fe89b9b5103c858e81ed
Author: Michael James Gratton <mike vee net>
Date:   Mon Aug 1 10:11:42 2016 +1000

    Fix some critical warnings during object destruction.
    
    * src/client/conversation-viewer/conversation-message.vala: Always
      release by setting ::context_menu_element to null after use.
    
    * src/client/conversation-viewer/conversation-viewer.vala: Reset
      ::conversation_timeout_id after its callback has completed.

 .../conversation-viewer/conversation-message.vala  |   14 +++++++++-----
 .../conversation-viewer/conversation-viewer.vala   |    1 +
 2 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-message.vala 
b/src/client/conversation-viewer/conversation-message.vala
index cf58fa5..3bf4733 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -221,7 +221,8 @@ public class ConversationMessage : Gtk.Box {
                 web_view.copy_clipboard();
             });
         add_action(ACTION_OPEN_INSPECTOR, Args.inspector).activate.connect(() => {
-                web_view.web_inspector.inspect_node(context_menu_element);
+                web_view.web_inspector.inspect_node(this.context_menu_element);
+                this.context_menu_element = null;
             });
         add_action(ACTION_OPEN_LINK, true, VariantType.STRING)
             .activate.connect(on_open_link);
@@ -1051,7 +1052,10 @@ public class ConversationMessage : Gtk.Box {
 
     private ReplacedImage? get_replaced_image() {
         ReplacedImage? image = null;
-        string? replaced_id = context_menu_element.get_attribute("replaced-id");
+        string? replaced_id = this.context_menu_element.get_attribute(
+            "replaced-id"
+        );
+        this.context_menu_element = null;
         if (!Geary.String.is_empty(replaced_id)) {
             image = replaced_images.get(replaced_id);
         }
@@ -1087,8 +1091,8 @@ public class ConversationMessage : Gtk.Box {
 
     private void on_context_menu_self(WebKit.DOM.Element element,
                                       WebKit.DOM.Event event) {
-        context_menu_element = event.get_target() as WebKit.DOM.HTMLElement;
-
+        this.context_menu_element =
+             event.get_target() as WebKit.DOM.HTMLElement;
         if (context_menu != null) {
             context_menu.detach();
         }
@@ -1108,7 +1112,7 @@ public class ConversationMessage : Gtk.Box {
                 null, set_action_param_string(link_menu, this.hover_url)
             );
         }
-        if (context_menu_element.local_name.down() == "img") {
+        if (this.context_menu_element.local_name.down() == "img") {
             ReplacedImage image = get_replaced_image();
             set_action_enabled(ACTION_SAVE_IMAGE, image != null);
             model.append_section(null, context_menu_image);
diff --git a/src/client/conversation-viewer/conversation-viewer.vala 
b/src/client/conversation-viewer/conversation-viewer.vala
index 5895b10..91c5430 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -227,6 +227,7 @@ public class ConversationViewer : Gtk.Stack {
                             debug("Loading timed out\n");
                             show_loading();
                         }
+                        this.conversation_timeout_id = 0;
                         return false;
                     });
 


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