]> err.no Git - libchamplain/commitdiff
Fix 593505: Memory leak in ChamplainLayer
authorFelix Riemann <friemann@gnome.org>
Sun, 30 Aug 2009 15:22:49 +0000 (11:22 -0400)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Sun, 30 Aug 2009 15:22:58 +0000 (11:22 -0400)
The list of children wasn't freed and the code was sub-optimal

AUTHORS
champlain/champlain-layer.c

diff --git a/AUTHORS b/AUTHORS
index b5abf4cd50938a06238f4f0c0712c39b99b2c15e..328eabf2673ef0ac24eb4a70cf3c204b4abe3eb9 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -23,3 +23,4 @@ Tim Horton <hortont424@gmail.com>
 Frederic Peters <fpeters@0d.be>
 Cosimo Cecchi <cosimoc@gnome.org>
 Vincent Untz <vuntz@gnome.org>
+Felix Riemann <friemann@gnome.org>
index 25cf61db487eb6c126c8e63fe376ac3c026fb3fd..c6b6da29787f54d53ad9cabfb0118fc57db10708 100644 (file)
@@ -118,24 +118,24 @@ reorder_marker (ClutterGroup *layer,
     ChamplainBaseMarker *marker)
 {
   GList* markers = clutter_container_get_children (CLUTTER_CONTAINER(layer));
-  gint size, i;
+  GList* it;
   gdouble y, tmp_y, low_y;
   ChamplainBaseMarker *lowest = NULL;
 
-  size = g_list_length (markers);
   g_object_get (G_OBJECT (marker), "latitude", &y, NULL);
   y = 90 - y;
   low_y = G_MAXDOUBLE;
 
-  for (i = 0; i < size; i++)
+  for (it = markers; it != NULL; it = it->next)
     {
-      ChamplainBaseMarker *prev_marker = (ChamplainBaseMarker*) g_list_nth_data (markers, i);
-      g_object_get(G_OBJECT(prev_marker), "latitude", &tmp_y, NULL);
-      tmp_y = 90 - tmp_y;
+      ChamplainBaseMarker *prev_marker = (ChamplainBaseMarker*) it->data;
 
       if (prev_marker == (ChamplainBaseMarker*) marker)
         continue;
 
+      g_object_get(G_OBJECT(prev_marker), "latitude", &tmp_y, NULL);
+      tmp_y = 90 - tmp_y;
+
       if (y < tmp_y && tmp_y < low_y)
         {
           lowest = prev_marker;
@@ -146,6 +146,8 @@ reorder_marker (ClutterGroup *layer,
   if (lowest)
     clutter_container_lower_child (CLUTTER_CONTAINER(layer),
         CLUTTER_ACTOR (marker), CLUTTER_ACTOR (lowest));
+
+  g_list_free (markers);
 }
 
 static void