[epiphany] ephy-embed: stop listening to progress updates after dispose



commit 2dfb8e7976d83847c3a6b0c515f273f507d9162c
Author: Xan Lopez <xan igalia com>
Date:   Thu Jan 19 19:10:31 2012 +0100

    ephy-embed: stop listening to progress updates after dispose
    
    Similar to status message updates, otherwise we might end up updating
    dead widgets. This fixes:
    
     #0  0x00007ffff592b9c8 in g_logv (log_domain=0x7ffff66de0cf "Gtk", log_level=G_LOG_LEVEL_CRITICAL, format=0x7ffff59ade60 "%s: assertion `%s' failed", args1=0x7fffffffd588) at gmessages.c:758
     #1  0x00007ffff592babc in g_log (log_domain=0x7ffff66de0cf "Gtk", log_level=G_LOG_LEVEL_CRITICAL, format=0x7ffff59ade60 "%s: assertion `%s' failed") at gmessages.c:792
     #2  0x00007ffff592bafd in g_return_if_fail_warning (log_domain=0x7ffff66de0cf "Gtk", pretty_function=0x7ffff66e27f0 "gtk_widget_hide", expression=0x7ffff66df7e8 "GTK_IS_WIDGET (widget)") at gmessages.c:801
     #3  0x00007ffff657c430 in gtk_widget_hide (widget=0x15ca190) at gtkwidget.c:3992
     #4  0x00000000004703f6 in clear_progress_cb (embed=0x516450) at ../../embed/ephy-embed.c:525
     #5  0x00007ffff5923c2c in g_timeout_dispatch (source=0x1bb9400, callback=0x4703d6 <clear_progress_cb>, user_data=0x516450) at gmain.c:3857
     #6  0x00007ffff5921e83 in g_main_dispatch (context=0x524f70) at gmain.c:2513
     #7  0x00007ffff5922b44 in g_main_context_dispatch (context=0x524f70) at gmain.c:3050
     #8  0x00007ffff5922d27 in g_main_context_iterate (context=0x524f70, block=1, dispatch=1, self=0x629c90) at gmain.c:3121
     #9  0x00007ffff5922deb in g_main_context_iteration (context=0x524f70, may_block=1) at gmain.c:3182
     #10 0x00007ffff5b2705e in g_application_run (application=0x508000, argc=1, argv=0x7fffffffda78) at gapplication.c:1496
     #11 0x000000000042d6e2 in main (argc=1, argv=0x7fffffffda78) at ../../src/ephy-main.c:472

 embed/ephy-embed.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index 9495a7c..a371ea8 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -90,6 +90,7 @@ struct _EphyEmbedPrivate
   guint clear_progress_source_id;
 
   gulong status_handler_id;
+  gulong progress_update_handler_id;
 };
 
 G_DEFINE_TYPE (EphyEmbed, ephy_embed, GTK_TYPE_BOX)
@@ -277,6 +278,11 @@ ephy_embed_dispose (GObject *object)
     priv->pop_statusbar_later_source_id = 0;
   }
 
+  if (priv->clear_progress_source_id) {
+    g_source_remove (priv->clear_progress_source_id);
+    priv->clear_progress_source_id = 0;
+  }
+
   /* Do not listen to status message notifications anymore, if we try
    * to update the statusbar after dispose we might crash. */
   if (priv->status_handler_id) {
@@ -284,6 +290,11 @@ ephy_embed_dispose (GObject *object)
     priv->status_handler_id = 0;
   }
 
+  if (priv->progress_update_handler_id) {
+    g_signal_handler_disconnect (priv->web_view, priv->progress_update_handler_id);
+    priv->progress_update_handler_id = 0;
+  }
+
   G_OBJECT_CLASS (ephy_embed_parent_class)->dispose (object);
 }
 
@@ -322,9 +333,6 @@ ephy_embed_finalize (GObject *object)
   g_slist_free (priv->keys);
   priv->keys = NULL;
 
-  if (priv->clear_progress_source_id)
-    g_source_remove (priv->clear_progress_source_id);
-
   G_OBJECT_CLASS (ephy_embed_parent_class)->finalize (object);
 }
 
@@ -551,7 +559,7 @@ progress_update (EphyWebView *view, GParamSpec *pspec, EphyEmbed *embed)
 
   if (progress == 1.0 || !loading)
     priv->clear_progress_source_id = g_timeout_add (500,
-                                                    (GSourceFunc) clear_progress_cb,
+                                                    (GSourceFunc)clear_progress_cb,
                                                     embed);
   else
     gtk_widget_show (priv->progress);
@@ -599,8 +607,8 @@ ephy_embed_constructed (GObject *object)
   paned = GTK_WIDGET (priv->paned);
 
   priv->web_view = web_view;
-  g_signal_connect (web_view, "notify::progress",
-                    G_CALLBACK (progress_update), object);
+  priv->progress_update_handler_id =  g_signal_connect (web_view, "notify::progress",
+                                                        G_CALLBACK (progress_update), object);
 
   gtk_container_add (GTK_CONTAINER (scrolled_window),
                      GTK_WIDGET (web_view));



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