Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/atk/ChangeLog,v
retrieving revision 1.329
diff -u -p -r1.329 ChangeLog
--- ChangeLog	31 Oct 2003 08:18:18 -0000	1.329
+++ ChangeLog	31 Oct 2003 09:33:25 -0000
@@ -1,5 +1,11 @@
 2003-10-31  Padraig O'Briain  <padraig.obriain@sun.com>
 
+	* atk/atkrelation.c: Use weak references for objects in a relation
+	instead of object references so that objects are not leaked when
+	corresponding widgets are destroyed.
+
+	This fixes bug #125725.
+	
 	* configure.in: Add reference to docs/version.xml
 
 	Shopuld have been done in previous commit but was omitted.
Index: atk/atkrelation.c
===================================================================
RCS file: /cvs/gnome/atk/atk/atkrelation.c,v
retrieving revision 1.17
diff -u -p -r1.17 atkrelation.c
--- atk/atkrelation.c	24 Oct 2003 07:40:32 -0000	1.17
+++ atk/atkrelation.c	31 Oct 2003 09:33:25 -0000
@@ -246,6 +246,7 @@ atk_relation_new (AtkObject       **targ
     g_value_init (value, ATK_TYPE_OBJECT);
     g_value_set_object (value, targets[i]);
     array = g_value_array_append (array, value);
+    g_value_unset (value);
     g_free (value);
   }
   
@@ -292,6 +293,18 @@ atk_relation_get_target (AtkRelation *re
 }
 
 static void
+delete_object_while_in_relation (gpointer callback_data,
+                                 GObject *where_the_object_was)
+{
+  GPtrArray *array;
+
+  g_assert (callback_data != NULL);
+
+  array = callback_data;
+  g_ptr_array_remove (array, where_the_object_was);
+}
+
+static void
 atk_relation_finalize (GObject *object)
 {
   AtkRelation        *relation;
@@ -306,10 +319,9 @@ atk_relation_finalize (GObject *object)
 
     for (i = 0; i < relation->target->len; i++)
     {
-      /*
-       * Remove a reference to AtkObject being removed from a relation
-       */
-      g_object_unref (g_ptr_array_index (relation->target, i));
+      g_object_weak_unref (G_OBJECT (g_ptr_array_index (relation->target, i)),
+                           (GWeakNotify) delete_object_while_in_relation, 
+                           relation->target);
     }
     g_ptr_array_free (relation->target, TRUE);
   } 
@@ -381,8 +393,8 @@ atk_relation_get_ptr_array_from_value_ar
     {
       value = g_value_array_get_nth (array, i);
       obj = g_value_get_object (value);
-      g_object_ref (obj);
       g_ptr_array_add (return_array, obj);
+      g_object_weak_ref (obj, (GWeakNotify) delete_object_while_in_relation, return_array);
     }
       
   return return_array;
