[Bf-blender-cvs] [35c1baef27b] blender2.8: Fix T56577: Crash when using Grease Pencil Fill Brush

Antonioya noreply at git.blender.org
Mon Aug 27 23:05:13 CEST 2018


Commit: 35c1baef27b81959d2c16f9f5e935fc91fb02667
Author: Antonioya
Date:   Mon Aug 27 23:04:58 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB35c1baef27b81959d2c16f9f5e935fc91fb02667

Fix T56577: Crash when using Grease Pencil Fill Brush

If the brush had assigned a color not present in the object material slots, the fill crashed.

Now, the material is added to the object slot before using it.

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

M	source/blender/editors/gpencil/gpencil_fill.c

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

diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 895bc760aa6..6d1c2c56d7b 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -841,7 +841,12 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
 	gps->flag |= GP_STROKE_CYCLIC;
 	gps->flag |= GP_STROKE_3DSPACE;
 
-	gps->mat_nr = BKE_gpencil_get_material_index(tgpf->ob, tgpf->mat) - 1;
+	gps->mat_nr = BKE_object_material_slot_find_index(tgpf->ob, tgpf->mat) - 1;
+	if (gps->mat_nr < 0) {
+		BKE_object_material_slot_add(tgpf->bmain, tgpf->ob);
+		assign_material(tgpf->bmain, tgpf->ob, tgpf->mat, tgpf->ob->totcol, BKE_MAT_ASSIGN_USERPREF);
+		gps->mat_nr = tgpf->ob->totcol - 1;
+	}
 
 	/* allocate memory for storage points */
 	gps->totpoints = tgpf->sbuffer_size;



More information about the Bf-blender-cvs mailing list