Index: gailtreeview.c
===================================================================
RCS file: /cvs/gnome/gail/gail/gailtreeview.c,v
retrieving revision 1.156
diff -u -p -r1.156 gailtreeview.c
--- gailtreeview.c	24 Sep 2003 18:00:16 -0000	1.156
+++ gailtreeview.c	16 Oct 2003 08:59:32 -0000
@@ -37,6 +37,11 @@ static void             gail_tree_view_r
                                                          GParamSpec		*pspec);
 static void             gail_tree_view_finalize         (GObject                *object);
 
+static void             gail_tree_view_connect_widget_destroyed 
+                                                        (GtkAccessible        
+*accessible);
+static void             gail_tree_view_destroyed        (GtkWidget              *widget,
+                                                         GtkAccessible          *accessible); 
 /* atkobject.h */
 
 static gint             gail_tree_view_get_n_children   (AtkObject              *obj);
@@ -327,6 +332,8 @@ static GailWidgetClass *parent_class = N
 static GQuark quark_column_desc_object = 0;
 static GQuark quark_column_header_object = 0;
 static gboolean editing = FALSE;
+static const gchar* hadjustment = "hadjustment";
+static const gchar* vadjustment = "vadjustment";
 
 struct _GailTreeViewRowInfo
 {
@@ -421,9 +428,11 @@ gail_tree_view_class_init (GailTreeViewC
 {
   AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  GtkAccessibleClass *accessible_class;
   GailWidgetClass *widget_class;
   GailContainerClass *container_class;
 
+  accessible_class = (GtkAccessibleClass*)klass;
   widget_class = (GailWidgetClass*)klass;
   container_class = (GailContainerClass*)klass;
 
@@ -436,6 +445,8 @@ gail_tree_view_class_init (GailTreeViewC
 
   widget_class->notify_gtk = gail_tree_view_real_notify_gtk;
 
+  accessible_class->connect_widget_destroyed = gail_tree_view_connect_widget_destroyed;
+
   /*
    * The children of a GtkTreeView are the buttons at the top of the columns
    * we do not represent these as children so we do not want to report
@@ -470,6 +481,8 @@ gail_tree_view_real_initialize (AtkObjec
   view->col_data = NULL;
   view->cell_data = NULL;
   view->focus_cell = NULL;
+  view->old_hadj = NULL;
+  view->old_vadj = NULL;
 
   view->n_children_deleted = 0;
 
@@ -521,13 +534,17 @@ gail_tree_view_real_initialize (AtkObjec
 
   /* adjustment callbacks */
 
-  g_object_get (tree_view, "hadjustment", &adj, NULL);
+  g_object_get (tree_view, hadjustment, &adj, NULL);
+  view->old_hadj = adj;
+  g_object_add_weak_pointer (G_OBJECT (view->old_hadj), (gpointer *)&view->old_hadj);
   g_signal_connect (adj, 
                     "value_changed",
                     G_CALLBACK (adjustment_changed),
                     tree_view);
 
-  g_object_get (tree_view, "vadjustment", &adj, NULL);
+  g_object_get (tree_view, vadjustment, &adj, NULL);
+  view->old_vadj = adj;
+  g_object_add_weak_pointer (G_OBJECT (view->old_vadj), (gpointer *)&view->old_vadj);
   g_signal_connect (adj, 
                     "value_changed",
                     G_CALLBACK (adjustment_changed),
@@ -617,10 +634,6 @@ gail_tree_view_new (GtkWidget *widget)
   accessible = ATK_OBJECT (object);
   atk_object_initialize (accessible, widget);
 
-  /*
-   * The role is set in gail_tree_view_real_initialize()
-   */
-
   return accessible;
 }
 
@@ -654,6 +667,41 @@ gail_tree_view_finalize (GObject	    *ob
     }
 
   G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+gail_tree_view_connect_widget_destroyed (GtkAccessible *accessible)
+{
+  if (accessible->widget)
+    {
+      g_signal_connect_after (accessible->widget,
+                              "destroy",
+                              G_CALLBACK (gail_tree_view_destroyed),
+                              accessible);
+    }
+  GTK_ACCESSIBLE_CLASS (parent_class)->connect_widget_destroyed (accessible);
+}
+
+static void
+gail_tree_view_destroyed (GtkWidget *widget,
+                          GtkAccessible *accessible)
+{
+  GtkAdjustment *adj;
+  GailTreeView *gail_view;
+
+  g_return_if_fail (GTK_IS_TREE_VIEW (widget));
+
+  gail_view = GAIL_TREE_VIEW (accessible);
+  adj = gail_view->old_hadj;
+  if (adj)
+    g_signal_handlers_disconnect_by_func (adj, 
+                                          (gpointer) adjustment_changed,
+                                          widget);
+  adj = gail_view->old_vadj;
+  if (adj)
+    g_signal_handlers_disconnect_by_func (adj, 
+                                          (gpointer) adjustment_changed,
+                                          widget);
 }
 
 AtkObject *
Index: gailtreeview.h
===================================================================
RCS file: /cvs/gnome/gail/gail/gailtreeview.h,v
retrieving revision 1.22
diff -u -p -r1.22 gailtreeview.h
--- gailtreeview.h	10 Dec 2002 16:29:01 -0000	1.22
+++ gailtreeview.h	16 Oct 2003 08:59:32 -0000
@@ -49,6 +49,8 @@ struct _GailTreeView
   GArray*	row_data;
   GList*        cell_data;
   GtkTreeModel  *tree_model;
+  GtkAdjustment *old_hadj;
+  GtkAdjustment *old_vadj;
   AtkObject     *focus_cell;
 };
 
