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:
authorAntonioya <blendergit@gmail.com>2018-08-28 00:04:58 +0300
committerAntonioya <blendergit@gmail.com>2018-08-28 00:04:58 +0300
commit35c1baef27b81959d2c16f9f5e935fc91fb02667 (patch)
tree63197709de78bcd807b5002210a2c7c730b0d53d
parent0bdabaa3f634c8168ba3b7ab3558f534c4c26057 (diff)
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.
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c7
1 files changed, 6 insertions, 1 deletions
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;