[Bf-blender-cvs] [8f9e7de138b] experimental_gp_weight: Fix segment fault when draw strokes

Antonio Vazquez noreply at git.blender.org
Wed May 16 10:04:31 CEST 2018


Commit: 8f9e7de138bda98a5ba2cb22714cd74e2201e0c8
Author: Antonio Vazquez
Date:   Wed May 16 10:04:26 2018 +0200
Branches: experimental_gp_weight
https://developer.blender.org/rB8f9e7de138bda98a5ba2cb22714cd74e2201e0c8

Fix segment fault when draw strokes

The subdivide was not reallocating the weights array.

===================================================================

M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/editors/gpencil/gpencil_utils.c

===================================================================

diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index e8ab1b367cb..ef131f63fd1 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -548,9 +548,12 @@ void BKE_gpencil_stroke_weights_duplicate(bGPDstroke *gps_src, bGPDstroke *gps_d
 	for (int i = 0; i < gps_src->totpoints; i++) {
 		MDeformVert *dvert_src = &gps_src->dvert[i];
 		MDeformVert *dvert_dst = &gps_dst->dvert[i];
-		if (dvert_src->dw) {
+		if (dvert_src->totweight > 0) {
 			dvert_dst->dw = MEM_dupallocN(dvert_src->dw);
 		}
+		else {
+			dvert_dst->dw = NULL;
+		}
 	}
 }
 
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 160568141ea..2b79d0303c9 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -931,6 +931,7 @@ void gp_subdivide_stroke(bGPDstroke *gps, const int subdivide)
 		/* resize the points arrys */
 		gps->totpoints += totnewpoints;
 		gps->points = MEM_recallocN(gps->points, sizeof(*gps->points) * gps->totpoints);
+		gps->dvert = MEM_recallocN(gps->dvert, sizeof(*gps->dvert) * gps->totpoints);
 		gps->flag |= GP_STROKE_RECALC_CACHES;
 
 		/* move points from last to first to new place */



More information about the Bf-blender-cvs mailing list