diff options
author | Antonioya <blendergit@gmail.com> | 2019-01-21 19:38:47 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2019-01-21 19:39:00 +0300 |
commit | 0af8ad51c07f987d8cf449efd95a7068f7edeffa (patch) | |
tree | b42308c0d23ad4b040603af7be1a41bb633212a7 /source/blender/editors/gpencil/gpencil_utils.c | |
parent | 2b0fb0d7bfb84cc5d77cdaa2e89c8fd5d8bd5e59 (diff) |
GP: Fix memory leaks when use cutter with weights
There were some issues when copy the weights and other memory leaks.
Also some code cleanup.
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_utils.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_utils.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 226a2bc7a98..776576807b4 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -2057,6 +2057,11 @@ static bool gpencil_check_collision( static void gp_copy_points( bGPDstroke *gps, bGPDspoint *pt, bGPDspoint *pt_final, int i, int i2) { + /* don't copy same point */ + if (i == i2) { + return; + } + copy_v3_v3(&pt_final->x, &pt->x); pt_final->pressure = pt->pressure; pt_final->strength = pt->strength; @@ -2068,9 +2073,16 @@ static void gp_copy_points( if (gps->dvert != NULL) { MDeformVert *dvert = &gps->dvert[i]; MDeformVert *dvert_final = &gps->dvert[i2]; + MEM_SAFE_FREE(dvert_final->dw); dvert_final->totweight = dvert->totweight; - dvert_final->dw = dvert->dw; + if (dvert->dw == NULL) { + dvert_final->dw = NULL; + dvert_final->totweight = 0; + } + else { + dvert_final->dw = MEM_dupallocN(dvert->dw); + } } } |