[libchamplain] When removing tiles from container, iterate using clutter_container_get_children()
- From: Pierre-Luc Beaudoin <plbeaudoin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] When removing tiles from container, iterate using clutter_container_get_children()
- Date: Tue, 23 Mar 2010 14:41:25 +0000 (UTC)
commit 04201ed4735127a8c676a1bceae0536d64d9b20e
Author: JiÅ?Ã Techet <techet gmail com>
Date: Sun Mar 14 19:11:42 2010 +0100
When removing tiles from container, iterate using clutter_container_get_children()
Iterating through container using clutter_group_get_nth_child()
and removing them inside the loop relies on the stability of deletion in
ClutterGroup, which isn't documented anywhere. Better to use
clutter_container_get_children() here.
Signed-off-by: JiÅ?Ã Techet <techet gmail com>
champlain/champlain-view.c | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index 0a993ee..2d71016 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -2193,6 +2193,7 @@ view_load_visible_tiles (ChamplainView *view)
ChamplainViewPrivate *priv = GET_PRIVATE (view);
ChamplainRectangle viewport = priv->viewport_size;
gint size;
+ GList *children;
ChamplainZoomLevel *level;
size = champlain_map_source_get_tile_size (priv->map_source);
@@ -2226,24 +2227,21 @@ view_load_visible_tiles (ChamplainView *view)
guint k = 0;
// Get rid of old tiles first
- int count = clutter_group_get_n_children (CLUTTER_GROUP (level));
- while (k < count)
+ children = clutter_container_get_children (CLUTTER_CONTAINER (level));
+ for ( ; children != NULL; children = g_list_next (children))
{
- ChamplainTile *tile = CHAMPLAIN_TILE (clutter_group_get_nth_child (CLUTTER_GROUP (level), k));
+ ChamplainTile *tile = CHAMPLAIN_TILE (children->data);
gint tile_x = champlain_tile_get_x (tile);
gint tile_y = champlain_tile_get_y (tile);
if (tile_x < x_first || tile_x > x_last ||
tile_y < y_first || tile_y > y_last)
- {
clutter_container_remove_actor (CLUTTER_CONTAINER (level), CLUTTER_ACTOR (tile));
- count--;
- }
- else
- k++;
}
+ g_list_free (children);
+
//Load new tiles if needed
gint arm_size, arm_max, spiral_pos;
gint dirs[5] = {0, 1, 0, -1, 0};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]