From: Pierre-Luc Beaudoin Date: Sat, 23 Aug 2008 18:06:01 +0000 (-0400) Subject: Fix a memory leak X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8be35ae74ae8cbf5aee986ad3bbbe7b87c1f63e5;p=libchamplain Fix a memory leak --- diff --git a/champlain/map.c b/champlain/map.c index 536e3b6..a997745 100644 --- a/champlain/map.c +++ b/champlain/map.c @@ -105,9 +105,26 @@ map_zoom_in (Map* map) gboolean map_zoom_out (Map* map) { - if(map->current_level->level - 1 >= 0) + gint new_level = map->current_level->level - 1; + if(new_level >= 0) { - map_load_level(map, map->current_level->level - 1); + gboolean exist = FALSE; + int i; + for (i = 0; i < map->current_level->tiles->len && !exist; i++) + { + ZoomLevel* level = g_ptr_array_index(map->levels, i); + if ( level->level == new_level) + { + exist = TRUE; + map->current_level = level; + g_print("Found!"); + } + } + + if(!exist) + { + map_load_level(map, map->current_level->level - 1); + } return TRUE; } return FALSE; diff --git a/champlain/zoomlevel.c b/champlain/zoomlevel.c index 634964e..cdec98c 100644 --- a/champlain/zoomlevel.c +++ b/champlain/zoomlevel.c @@ -34,6 +34,8 @@ zoom_level_new(gint zoom_level, gint row, gint column, gint tile_size) level->tiles = g_ptr_array_sized_new (row * column); level->group = clutter_group_new (); + g_object_ref(level->group); // so that the group isn't destroyed when removed from the viewport + return level; }