diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-04-13 06:30:53 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-04-13 06:37:27 +0300 |
commit | 64660b902c3fb52fe5a3cb5bf232f90283db8732 (patch) | |
tree | c9549b247ca35e92c3f03db4f07d95aaede60e48 /source/blender/draw/modes | |
parent | c080702e73f1729897033343d44198488b6fed9f (diff) |
Use 'safe' macros for common free operation
Same as MEM_SAFE_FREE macro,
checks for NULL, runs free then sets NULL.
Blocks of code that do this many times are noisy and likely
errors here wouldn't be noticed immediately.
Also NULL's static vars which were being left set.
Diffstat (limited to 'source/blender/draw/modes')
-rw-r--r-- | source/blender/draw/modes/edit_curve_mode.c | 3 | ||||
-rw-r--r-- | source/blender/draw/modes/edit_lattice_mode.c | 3 | ||||
-rw-r--r-- | source/blender/draw/modes/edit_mesh_mode.c | 36 | ||||
-rw-r--r-- | source/blender/draw/modes/edit_metaball_mode.c | 3 | ||||
-rw-r--r-- | source/blender/draw/modes/edit_surface_mode.c | 3 | ||||
-rw-r--r-- | source/blender/draw/modes/edit_text_mode.c | 3 | ||||
-rw-r--r-- | source/blender/draw/modes/object_mode.c | 12 | ||||
-rw-r--r-- | source/blender/draw/modes/paint_texture_mode.c | 3 | ||||
-rw-r--r-- | source/blender/draw/modes/paint_vertex_mode.c | 3 | ||||
-rw-r--r-- | source/blender/draw/modes/paint_weight_mode.c | 3 | ||||
-rw-r--r-- | source/blender/draw/modes/particle_mode.c | 3 | ||||
-rw-r--r-- | source/blender/draw/modes/pose_mode.c | 3 | ||||
-rw-r--r-- | source/blender/draw/modes/sculpt_mode.c | 3 |
13 files changed, 27 insertions, 54 deletions
diff --git a/source/blender/draw/modes/edit_curve_mode.c b/source/blender/draw/modes/edit_curve_mode.c index 2cb03018254..e0b1a4eac0c 100644 --- a/source/blender/draw/modes/edit_curve_mode.c +++ b/source/blender/draw/modes/edit_curve_mode.c @@ -230,8 +230,7 @@ static void EDIT_CURVE_draw_scene(void *vedata) * Mostly used for freeing shaders */ static void EDIT_CURVE_engine_free(void) { - // if (custom_shader) - // DRW_shader_free(custom_shader); + // DRW_SHADER_FREE_SAFE(custom_shader); } /* Create collection settings here. diff --git a/source/blender/draw/modes/edit_lattice_mode.c b/source/blender/draw/modes/edit_lattice_mode.c index ea5256b42a5..473f9074536 100644 --- a/source/blender/draw/modes/edit_lattice_mode.c +++ b/source/blender/draw/modes/edit_lattice_mode.c @@ -228,8 +228,7 @@ static void EDIT_LATTICE_draw_scene(void *vedata) * Mostly used for freeing shaders */ static void EDIT_LATTICE_engine_free(void) { - // if (custom_shader) - // DRW_shader_free(custom_shader); + // DRW_SHADER_FREE_SAFE(custom_shader); } /* Create collection settings here. diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c index 08a6a6e778b..46a3e8e2e4e 100644 --- a/source/blender/draw/modes/edit_mesh_mode.c +++ b/source/blender/draw/modes/edit_mesh_mode.c @@ -499,30 +499,18 @@ void EDIT_MESH_collection_settings_create(IDProperty *properties) static void EDIT_MESH_engine_free(void) { - if (e_data.overlay_tri_sh) - DRW_shader_free(e_data.overlay_tri_sh); - if (e_data.overlay_tri_fast_sh) - DRW_shader_free(e_data.overlay_tri_fast_sh); - if (e_data.overlay_tri_vcol_sh) - DRW_shader_free(e_data.overlay_tri_vcol_sh); - if (e_data.overlay_tri_vcol_fast_sh) - DRW_shader_free(e_data.overlay_tri_vcol_fast_sh); - if (e_data.overlay_edge_sh) - DRW_shader_free(e_data.overlay_edge_sh); - if (e_data.overlay_edge_vcol_sh) - DRW_shader_free(e_data.overlay_edge_vcol_sh); - if (e_data.overlay_vert_sh) - DRW_shader_free(e_data.overlay_vert_sh); - if (e_data.overlay_facedot_sh) - DRW_shader_free(e_data.overlay_facedot_sh); - if (e_data.overlay_mix_sh) - DRW_shader_free(e_data.overlay_mix_sh); - if (e_data.overlay_facefill_sh) - DRW_shader_free(e_data.overlay_facefill_sh); - if (e_data.normals_face_sh) - DRW_shader_free(e_data.normals_face_sh); - if (e_data.normals_sh) - DRW_shader_free(e_data.normals_sh); + DRW_SHADER_FREE_SAFE(e_data.overlay_tri_sh); + DRW_SHADER_FREE_SAFE(e_data.overlay_tri_fast_sh); + DRW_SHADER_FREE_SAFE(e_data.overlay_tri_vcol_sh); + DRW_SHADER_FREE_SAFE(e_data.overlay_tri_vcol_fast_sh); + DRW_SHADER_FREE_SAFE(e_data.overlay_edge_sh); + DRW_SHADER_FREE_SAFE(e_data.overlay_edge_vcol_sh); + DRW_SHADER_FREE_SAFE(e_data.overlay_vert_sh); + DRW_SHADER_FREE_SAFE(e_data.overlay_facedot_sh); + DRW_SHADER_FREE_SAFE(e_data.overlay_mix_sh); + DRW_SHADER_FREE_SAFE(e_data.overlay_facefill_sh); + DRW_SHADER_FREE_SAFE(e_data.normals_face_sh); + DRW_SHADER_FREE_SAFE(e_data.normals_sh); } static const DrawEngineDataSize EDIT_MESH_data_size = DRW_VIEWPORT_DATA_SIZE(EDIT_MESH_Data); diff --git a/source/blender/draw/modes/edit_metaball_mode.c b/source/blender/draw/modes/edit_metaball_mode.c index 20d78fdffda..5d08d4e5076 100644 --- a/source/blender/draw/modes/edit_metaball_mode.c +++ b/source/blender/draw/modes/edit_metaball_mode.c @@ -228,8 +228,7 @@ static void EDIT_METABALL_draw_scene(void *vedata) * Mostly used for freeing shaders */ static void EDIT_METABALL_engine_free(void) { - // if (custom_shader) - // DRW_shader_free(custom_shader); + // DRW_SHADER_FREE_SAFE(custom_shader); } /* Create collection settings here. diff --git a/source/blender/draw/modes/edit_surface_mode.c b/source/blender/draw/modes/edit_surface_mode.c index c09a10dcc91..783defaf4ec 100644 --- a/source/blender/draw/modes/edit_surface_mode.c +++ b/source/blender/draw/modes/edit_surface_mode.c @@ -228,8 +228,7 @@ static void EDIT_SURFACE_draw_scene(void *vedata) * Mostly used for freeing shaders */ static void EDIT_SURFACE_engine_free(void) { - // if (custom_shader) - // DRW_shader_free(custom_shader); + // DRW_SHADER_FREE_SAFE(custom_shader); } /* Create collection settings here. diff --git a/source/blender/draw/modes/edit_text_mode.c b/source/blender/draw/modes/edit_text_mode.c index f105e2d316c..101202cea40 100644 --- a/source/blender/draw/modes/edit_text_mode.c +++ b/source/blender/draw/modes/edit_text_mode.c @@ -228,8 +228,7 @@ static void EDIT_TEXT_draw_scene(void *vedata) * Mostly used for freeing shaders */ static void EDIT_TEXT_engine_free(void) { - // if (custom_shader) - // DRW_shader_free(custom_shader); + // DRW_SHADER_FREE_SAFE(custom_shader); } /* Create collection settings here. diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index ad4da8870f2..0ac27cdbf1e 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -371,14 +371,10 @@ static void OBJECT_engine_init(void *vedata) static void OBJECT_engine_free(void) { - if (e_data.outline_resolve_sh) - DRW_shader_free(e_data.outline_resolve_sh); - if (e_data.outline_detect_sh) - DRW_shader_free(e_data.outline_detect_sh); - if (e_data.outline_fade_sh) - DRW_shader_free(e_data.outline_fade_sh); - if (e_data.grid_sh) - DRW_shader_free(e_data.grid_sh); + DRW_SHADER_FREE_SAFE(e_data.outline_resolve_sh); + DRW_SHADER_FREE_SAFE(e_data.outline_detect_sh); + DRW_SHADER_FREE_SAFE(e_data.outline_fade_sh); + DRW_SHADER_FREE_SAFE(e_data.grid_sh); } static DRWShadingGroup *shgroup_outline(DRWPass *pass, const float col[4], struct GPUShader *sh) diff --git a/source/blender/draw/modes/paint_texture_mode.c b/source/blender/draw/modes/paint_texture_mode.c index 06799e549e5..5bace8b2a77 100644 --- a/source/blender/draw/modes/paint_texture_mode.c +++ b/source/blender/draw/modes/paint_texture_mode.c @@ -228,8 +228,7 @@ static void PAINT_TEXTURE_draw_scene(void *vedata) * Mostly used for freeing shaders */ static void PAINT_TEXTURE_engine_free(void) { - // if (custom_shader) - // DRW_shader_free(custom_shader); + // DRW_SHADER_FREE_SAFE(custom_shader); } /* Create collection settings here. diff --git a/source/blender/draw/modes/paint_vertex_mode.c b/source/blender/draw/modes/paint_vertex_mode.c index 61bd376072f..7f58efd73af 100644 --- a/source/blender/draw/modes/paint_vertex_mode.c +++ b/source/blender/draw/modes/paint_vertex_mode.c @@ -228,8 +228,7 @@ static void PAINT_VERTEX_draw_scene(void *vedata) * Mostly used for freeing shaders */ static void PAINT_VERTEX_engine_free(void) { - // if (custom_shader) - // DRW_shader_free(custom_shader); + // DRW_SHADER_FREE_SAFE(custom_shader); } /* Create collection settings here. diff --git a/source/blender/draw/modes/paint_weight_mode.c b/source/blender/draw/modes/paint_weight_mode.c index fa02ac3f3d8..af9333cdd8f 100644 --- a/source/blender/draw/modes/paint_weight_mode.c +++ b/source/blender/draw/modes/paint_weight_mode.c @@ -225,8 +225,7 @@ static void PAINT_WEIGHT_draw_scene(void *vedata) * Mostly used for freeing shaders */ static void PAINT_WEIGHT_engine_free(void) { - // if (custom_shader) - // DRW_shader_free(custom_shader); + // DRW_SHADER_FREE_SAFE(custom_shader); } /* Create collection settings here. diff --git a/source/blender/draw/modes/particle_mode.c b/source/blender/draw/modes/particle_mode.c index e51be560476..b9fb8d031a8 100644 --- a/source/blender/draw/modes/particle_mode.c +++ b/source/blender/draw/modes/particle_mode.c @@ -223,8 +223,7 @@ static void PARTICLE_draw_scene(void *vedata) * Mostly used for freeing shaders */ static void PARTICLE_engine_free(void) { - // if (custom_shader) - // DRW_shader_free(custom_shader); + // DRW_SHADER_FREE_SAFE(custom_shader); } /* Create collection settings here. diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c index 390becf2d91..fda993c4b82 100644 --- a/source/blender/draw/modes/pose_mode.c +++ b/source/blender/draw/modes/pose_mode.c @@ -223,8 +223,7 @@ static void POSE_draw_scene(void *vedata) * Mostly used for freeing shaders */ static void POSE_engine_free(void) { - // if (custom_shader) - // DRW_shader_free(custom_shader); + // DRW_SHADER_FREE_SAFE(custom_shader); } /* Create collection settings here. diff --git a/source/blender/draw/modes/sculpt_mode.c b/source/blender/draw/modes/sculpt_mode.c index 14140ae6711..0fc212ee177 100644 --- a/source/blender/draw/modes/sculpt_mode.c +++ b/source/blender/draw/modes/sculpt_mode.c @@ -222,8 +222,7 @@ static void SCULPT_draw_scene(void *vedata) * Mostly used for freeing shaders */ static void SCULPT_engine_free(void) { - // if (custom_shader) - // DRW_shader_free(custom_shader); + // DRW_SHADER_FREE_SAFE(custom_shader); } /* Create collection settings here. |