[libegg] Fixed EggSpreadTable GtkContainer:forall() implementation



commit 443e9aed7ff41a041d5f9f0fd3f78e5793cdda15
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Wed Nov 10 13:20:10 2010 +0900

    Fixed EggSpreadTable GtkContainer:forall() implementation
    
    Fixed egg_spread_table_forall() to be safe at :destroy() time.
    it's now safe to remove the element that is being iterated over
    while calling gtk_container_foreach().

 libegg/spreadtable/eggspreadtable.c |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/libegg/spreadtable/eggspreadtable.c b/libegg/spreadtable/eggspreadtable.c
index 3ee48db..c5dbbd1 100644
--- a/libegg/spreadtable/eggspreadtable.c
+++ b/libegg/spreadtable/eggspreadtable.c
@@ -864,19 +864,18 @@ egg_spread_table_forall (GtkContainer *container,
 {
   EggSpreadTable        *table = EGG_SPREAD_TABLE (container);
   EggSpreadTablePrivate *priv = table->priv;
-  GList                 *list = NULL;
+  GList                 *list;
+  GtkWidget             *child;
 
-  /* We use a copy of the list,
-   * because the callback could call egg_spread_table_remove(),
-   * which would change the list, causing us to use a list->next that
-   * is no longer valid.
-   */
-  for (list = g_list_copy(priv->children); list; list = list->next)
-  {
-    (* callback) ((GtkWidget*) list->data, callback_data);
-  }
+  list = priv->children;
 
-  g_list_free(list);
+  while (list)
+    {
+      child = list->data;
+      list  = list->next;
+      
+      (* callback) ((GtkWidget*) child, callback_data);
+    }
 }
 
 static GType



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