[libchamplain] Fix 593505: Memory leak in ChamplainLayer
- From: Pierre-Luc Beaudoin <plbeaudoin src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libchamplain] Fix 593505: Memory leak in ChamplainLayer
- Date: Sun, 30 Aug 2009 15:37:16 +0000 (UTC)
commit c800c8d4b5b327a45475875d70018efffe3040a0
Author: Felix Riemann <friemann gnome org>
Date: Sun Aug 30 11:22:49 2009 -0400
Fix 593505: Memory leak in ChamplainLayer
The list of children wasn't freed and the code was sub-optimal
AUTHORS | 1 +
champlain/champlain-layer.c | 14 ++++++++------
2 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/AUTHORS b/AUTHORS
index b5abf4c..328eabf 100644
--- 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>
diff --git a/champlain/champlain-layer.c b/champlain/champlain-layer.c
index 25cf61d..c6b6da2 100644
--- a/champlain/champlain-layer.c
+++ b/champlain/champlain-layer.c
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]