DEBUG ("Range %d, %d to %d, %d", x_first, y_first, x_count, y_count);
int i, j;
- guint k;
+ guint k = 0;
// Get rid of old tiles first
- for (k = 0; k < champlain_zoom_level_tile_count (level); k++)
+ int count = champlain_zoom_level_tile_count (level);
+ while (k < count)
{
ChamplainTile *tile = champlain_zoom_level_get_nth_tile (level, k);
+
+ if (tile == NULL)
+ {
+ k++;
+ continue;
+ }
+
gint tile_x = champlain_tile_get_x (tile);
gint tile_y = champlain_tile_get_y (tile);
+
if (tile_x < x_first || tile_x > x_count ||
tile_y < y_first || tile_y > y_count)
{
clutter_container_remove_actor (CLUTTER_CONTAINER (group), actor);
}
champlain_zoom_level_remove_tile (level, tile);
+ count = champlain_zoom_level_tile_count (level);
}
+ else
+ k++;
}
//Load new tiles if needed
for (k = 0; k < champlain_zoom_level_tile_count (level) && !exist; k++)
{
ChamplainTile *tile = champlain_zoom_level_get_nth_tile (level, k);
+
+ if (tile == NULL)
+ continue;
+
gint tile_x = champlain_tile_get_x (tile);
gint tile_y = champlain_tile_get_y (tile);
for (i = 0; i < champlain_zoom_level_tile_count (priv->map->current_level); i++)
{
ChamplainTile *tile = champlain_zoom_level_get_nth_tile (priv->map->current_level, i);
+
+ if (tile == NULL)
+ continue;
+
if (champlain_tile_get_state (tile) == CHAMPLAIN_STATE_DONE)
view_position_tile (view, tile);
}
for (i = 0; i < champlain_zoom_level_tile_count (priv->map->current_level); i++)
{
ChamplainTile *tile = champlain_zoom_level_get_nth_tile (priv->map->current_level, i);
+
+ if (tile == NULL)
+ continue;
+
if (champlain_tile_get_state (tile) == CHAMPLAIN_STATE_LOADING)
new_state = CHAMPLAIN_STATE_LOADING;
}
static void
champlain_zoom_level_dispose (GObject *object)
{
- //FIXME: Get rid of tiles here?
guint k;
ChamplainZoomLevel *level = CHAMPLAIN_ZOOM_LEVEL (object);
ChamplainZoomLevelPrivate *priv = level->priv;
int count = champlain_zoom_level_tile_count (level);
for (k = 0; k < count; k++)
{
- ChamplainTile *tile = champlain_zoom_level_get_nth_tile (level, k);
- champlain_zoom_level_remove_tile (level, tile);
+ ChamplainTile *tile = champlain_zoom_level_get_nth_tile (level, 0);
+ if (tile != NULL)
+ champlain_zoom_level_remove_tile (level, tile);
}
g_ptr_array_free (priv->tiles, TRUE);
priv->tiles = NULL;
g_return_val_if_fail (CHAMPLAIN_ZOOM_LEVEL (self), NULL);
ChamplainZoomLevelPrivate *priv = self->priv;
+ g_return_val_if_fail (index < priv->tiles->len, NULL);
+ g_return_val_if_fail (index >= 0, NULL);
return g_ptr_array_index (priv->tiles, index);
}