diff options
author | Antonioya <blendergit@gmail.com> | 2018-08-28 00:04:58 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-08-28 00:04:58 +0300 |
commit | 35c1baef27b81959d2c16f9f5e935fc91fb02667 (patch) | |
tree | 63197709de78bcd807b5002210a2c7c730b0d53d | |
parent | 0bdabaa3f634c8168ba3b7ab3558f534c4c26057 (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.c | 7 |
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; |