Fix unfreed memory
authorClément Foucault <foucault.clem@gmail.com>
Thu, 2 Feb 2017 16:15:26 +0000 (17:15 +0100)
committerClément Foucault <foucault.clem@gmail.com>
Thu, 2 Feb 2017 16:15:26 +0000 (17:15 +0100)
source/blender/draw/intern/draw_cache.c
source/blender/draw/intern/draw_cache.h
source/blender/draw/intern/draw_manager.c

index d3e422abfd4822d569ac5f4ab12084f1a15226ad..b41c232847cafa69492adc0e73483d0450a8b38f 100644 (file)
@@ -51,6 +51,32 @@ static struct DRWShapeCache{
        Batch *drw_lamp;
 } SHC = {NULL};
 
+void DRW_shape_cache_free(void)
+{
+       if (SHC.drw_single_vertice)
+               Batch_discard_all(SHC.drw_single_vertice);
+       if (SHC.drw_fullscreen_quad)
+               Batch_discard_all(SHC.drw_fullscreen_quad);
+       if (SHC.drw_plain_axes)
+               Batch_discard_all(SHC.drw_plain_axes);
+       if (SHC.drw_single_arrow)
+               Batch_discard_all(SHC.drw_single_arrow);
+       if (SHC.drw_single_arrow_line)
+               Batch_discard_all(SHC.drw_single_arrow_line);
+       if (SHC.drw_cube)
+               Batch_discard_all(SHC.drw_cube);
+       if (SHC.drw_circle)
+               Batch_discard_all(SHC.drw_circle);
+       if (SHC.drw_empty_sphere)
+               Batch_discard_all(SHC.drw_empty_sphere);
+       if (SHC.drw_empty_cone)
+               Batch_discard_all(SHC.drw_empty_cone);
+       if (SHC.drw_arrows)
+               Batch_discard_all(SHC.drw_arrows);
+       if (SHC.drw_lamp)
+               Batch_discard_all(SHC.drw_lamp);
+}
+
 /* Quads */
 Batch *DRW_cache_fullscreen_quad_get(void)
 {
index b5d57e58a48bea0b762dd4521026ccd1ab28060a..881fc2b529be1fe4f8c7a67f93e96ab03cb027e0 100644 (file)
@@ -29,6 +29,8 @@
 struct Batch;
 struct Object;
 
+void DRW_shape_cache_free(void);
+
 /* Common Shapes */
 struct Batch *DRW_cache_fullscreen_quad_get(void);
 struct Batch *DRW_cache_single_vert_get(void);
index 7fd32d07d33b7b702d8abdb3d4132b0744280447..b2766fb7163e3149f71962ed596fe119346026d0 100644 (file)
@@ -1134,5 +1134,7 @@ void DRW_engines_free(void)
 {
        clay_engine_free();
 
+       DRW_shape_cache_free();
+
        BLI_remlink(&R_engines, &viewport_clay_type);
 }
\ No newline at end of file