[Nautilus-list] Bugs #73301 & #75232



Hi,

These 2 bugs both cause SEGVs when the gtkhtml view is destroyed:

http://bugzilla.gnome.org/show_bug.cgi?id=73301
http://bugzilla.gnome.org/show_bug.cgi?id=75232

Attached are patches which should fix them. I could reproduce 73301 and
I can't any more. I'm not quite so sure about the other one.

Anders has approved the gtkhtml2 patch, but I need approval for the
nautilus-gtkhtml patch. (I need to commit them together.)

Damon


Index: nautilus-gtkhtml-view.c
===================================================================
RCS file: /cvs/gnome/nautilus-gtkhtml/src/nautilus-gtkhtml-view.c,v
retrieving revision 1.4
diff -u -r1.4 nautilus-gtkhtml-view.c
--- nautilus-gtkhtml-view.c	10 Feb 2002 19:11:24 -0000	1.4
+++ nautilus-gtkhtml-view.c	24 Apr 2002 18:25:56 -0000
@@ -766,7 +766,13 @@
 	view = NAUTILUS_GTKHTML_VIEW (object);
 
 	gnome_vfs_uri_unref (view->details->base);
-	g_object_unref (G_OBJECT (view->details->view));
+
+	/* We shouldn't really need to call html_document_clear() but
+	   libgtkhtml seems to have a bug with reference counting otherwise. */
+	kill_old_connections (view->details->doc);
+	html_document_clear (view->details->doc);
+	g_object_unref (G_OBJECT (view->details->doc));
+
 #if 0
 	if (view->details->menu) {
 		gtk_widget_unref (view->details->menu);
Index: htmlview.c
===================================================================
RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/view/htmlview.c,v
retrieving revision 1.135
diff -u -r1.135 htmlview.c
--- htmlview.c	15 Apr 2002 15:51:42 -0000	1.135
+++ htmlview.c	24 Apr 2002 18:06:07 -0000
@@ -784,19 +784,45 @@
 	g_object_set_data (G_OBJECT (data), "saved-focus", NULL);
 }
 
+/* We must release all references to other objects here. But be careful as
+   it can be called multiple times. */
 static void
-html_view_finalize (GObject *object)
+html_view_destroy (GtkObject *object)
 {
 	HtmlView *view = HTML_VIEW (object);
+
 	gpointer saved_focus;
 
+	if (view->relayout_timeout_id != 0) {
+		gtk_timeout_remove (view->relayout_timeout_id);
+		view->relayout_timeout_id = 0;
+	}
+
+	if (view->relayout_idle_id != 0) {
+		gtk_idle_remove (view->relayout_idle_id);
+		view->relayout_idle_id = 0;
+	}
+
 	saved_focus = g_object_get_data (G_OBJECT (view), "saved-focus");
 	if (saved_focus) {
 		g_object_weak_unref (G_OBJECT (saved_focus),
 			   	     (GWeakNotify) focus_element_destroyed,
 				     view);
+		g_object_set_data (G_OBJECT (view), "saved-focus", NULL);
+	}
+
+	if (view->document) {
+		g_object_unref (view->document);
+		view->document = NULL;
 	}
-	g_object_unref (view->document);
+
+	GTK_OBJECT_CLASS (parent_class)->destroy (object);
+}
+
+static void
+html_view_finalize (GObject *object)
+{
+	/*HtmlView *view = HTML_VIEW (object);*/
 
 	if (G_OBJECT_CLASS (parent_class)->finalize)
 		(G_OBJECT_CLASS (parent_class)->finalize) (object);
@@ -928,7 +954,7 @@
 	
 	if (view->document != NULL) {
 		html_view_disconnect_document (view, view->document);
-		
+		g_object_unref (view->document);
 		html_view_layout_tree_free (view, view->root);
 	}
 	
@@ -1047,6 +1073,7 @@
 html_view_class_init (HtmlViewClass *klass)
 {
 	GObjectClass *object_class = (GObjectClass *)klass;
+	GtkObjectClass *gtkobject_class = (GtkObjectClass *)klass;
 	GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
 	GtkContainerClass *container_class = (GtkContainerClass *)klass;
 	GtkBindingSet *binding_set;
@@ -1055,6 +1082,8 @@
 	parent_class = gtk_type_class (GTK_TYPE_LAYOUT);
 
 	object_class->finalize = html_view_finalize;
+
+	gtkobject_class->destroy = html_view_destroy;
 
 	widget_class->focus = html_view_focus;
 	


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