Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano Cavalcante <germano.costa@ig.com.br>2021-06-22 14:12:59 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-06-22 14:25:32 +0300
commitab063db34d60bdda6a683b13cef36d93ad6e760f (patch)
treeba982105300099bf04f4c4bd95bd57e2aad51445
parent3f1111b2a82fe975fdb55114943009e8ef0a2c43 (diff)
Cleanup: deduplicate free code
It is more appropriate that `depths` is freed in `ED_view3d_depths_free`.
-rw-r--r--source/blender/editors/curve/editcurve_paint.c1
-rw-r--r--source/blender/editors/object/object_transform.c1
-rw-r--r--source/blender/editors/physics/particle_edit.c15
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c9
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c2
5 files changed, 15 insertions, 13 deletions
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index 94c227dfa75..febcf83116b 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -624,7 +624,6 @@ static void curve_draw_exit(wmOperator *op)
if (cdd->depths) {
ED_view3d_depths_free(cdd->depths);
- MEM_freeN(cdd->depths);
}
MEM_freeN(cdd);
op->customdata = NULL;
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index dbeaf829b7d..94b2f3fd566 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -1687,7 +1687,6 @@ static void object_transform_axis_target_free_data(wmOperator *op)
#ifdef USE_RENDER_OVERRIDE
if (xfd->depths) {
ED_view3d_depths_free(xfd->depths);
- MEM_freeN(xfd->depths);
}
#endif
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index c0d035f36cf..2bf0f842623 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -525,14 +525,12 @@ static void PE_set_view3d_data(bContext *C, PEData *data)
ED_view3d_viewcontext_init(C, &data->vc, data->depsgraph);
if (!XRAY_ENABLED(data->vc.v3d)) {
- if (!(data->vc.v3d->runtime.flag & V3D_RUNTIME_DEPTHBUF_OVERRIDDEN)) {
- ED_view3d_depth_override(data->depsgraph,
- data->vc.region,
- data->vc.v3d,
- data->vc.obact,
- V3D_DEPTH_OBJECT_ONLY,
- &data->depths);
- }
+ ED_view3d_depth_override(data->depsgraph,
+ data->vc.region,
+ data->vc.v3d,
+ data->vc.obact,
+ V3D_DEPTH_OBJECT_ONLY,
+ &data->depths);
}
}
@@ -577,7 +575,6 @@ static void PE_data_free(PEData *data)
PE_free_shape_tree(data);
if (data->depths) {
ED_view3d_depths_free(data->depths);
- MEM_freeN(data->depths);
data->depths = NULL;
}
}
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index c024bab355d..2e46deea0e8 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -2322,7 +2322,10 @@ void ED_view3d_depth_override(Depsgraph *depsgraph,
ViewDepths **r_depths)
{
if (v3d->runtime.flag & V3D_RUNTIME_DEPTHBUF_OVERRIDDEN) {
- return;
+ /* Force redraw if `r_depths` is required. */
+ if (!r_depths || *r_depths != NULL) {
+ return;
+ }
}
struct bThemeState theme_state;
Scene *scene = DEG_get_evaluated_scene(depsgraph);
@@ -2365,6 +2368,9 @@ void ED_view3d_depth_override(Depsgraph *depsgraph,
}
if (r_depths) {
+ if (*r_depths) {
+ ED_view3d_depths_free(*r_depths);
+ }
*r_depths = view3d_depths_create(region);
}
}
@@ -2384,6 +2390,7 @@ void ED_view3d_depths_free(ViewDepths *depths)
if (depths->depths) {
MEM_freeN(depths->depths);
}
+ MEM_freeN(depths);
}
/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index c7da3378ae3..ea0b1f396c3 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -1019,7 +1019,7 @@ static float view_autodist_depth_margin(ARegion *region, const int mval[2], int
ViewDepths depth_temp = {0};
view3d_depths_rect_create(region, &rect, &depth_temp);
float depth_close = view3d_depth_near(&depth_temp);
- ED_view3d_depths_free(&depth_temp);
+ MEM_SAFE_FREE(depth_temp.depths);
return depth_close;
}