[seahorse] Fix assertion when destroying object with children.



commit e344df96c7828f321d13eca670c04c9484090067
Author: Stef Walter <stef memberwebs com>
Date:   Fri Oct 9 00:30:49 2009 +0000

    Fix assertion when destroying object with children.
    
    This is due to a modify while iterating a list. We copy the list
    so that the original is modified, while we iterate the copy.
    
    Fixes bug #596842

 libseahorse/seahorse-object.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/libseahorse/seahorse-object.c b/libseahorse/seahorse-object.c
index 30626b4..7adf2d0 100644
--- a/libseahorse/seahorse-object.c
+++ b/libseahorse/seahorse-object.c
@@ -381,7 +381,7 @@ seahorse_object_dispose (GObject *obj)
 {
 	SeahorseObject *self = SEAHORSE_OBJECT (obj);
 	SeahorseObject *parent;
-	GList *l;
+	GList *l, *children;
 	
 	if (self->pv->context != NULL) {
 		seahorse_context_remove_object (self->pv->context, self);
@@ -407,11 +407,13 @@ seahorse_object_dispose (GObject *obj)
 	parent = self->pv->parent;
 	if (parent)
 		g_object_ref (parent);
-	
-	for (l = self->pv->children; l; l = g_list_next (l)) {
+
+	children = g_list_copy (self->pv->children);
+	for (l = children; l; l = g_list_next (l)) {
 		g_return_if_fail (SEAHORSE_IS_OBJECT (l->data));
 		seahorse_object_set_parent (l->data, parent);
 	}
+	g_list_free (children);
 
 	if (parent)
 		g_object_unref (parent);



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