]> err.no Git - libchamplain/commitdiff
Fix a memory leak
authorPierre-Luc Beaudoin <pierre-luc@squidy.info>
Sat, 23 Aug 2008 18:06:01 +0000 (14:06 -0400)
committerPierre-Luc Beaudoin <pierre-luc@squidy.info>
Sat, 23 Aug 2008 18:06:01 +0000 (14:06 -0400)
champlain/map.c
champlain/zoomlevel.c

index 536e3b68ea3a18919861393aff6d459bac5a1775..a997745c527d4d8b9634768d7b3d7ae210c0bad7 100644 (file)
@@ -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;
index 634964e5d4c0dc435f9f1976b89f874f4d50eb10..cdec98cc19f48dbbccfd2d8151a5e224dc992c6d 100644 (file)
@@ -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;
 }