diff options
author | Antonioya <blendergit@gmail.com> | 2018-08-08 17:56:56 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-08-08 17:56:56 +0300 |
commit | 5c4fd526124c348c8f324a2d0a384958c6e793b8 (patch) | |
tree | 4147a301d31e79e16a584769e61a506721a0ca6f /source/blender/editors/gpencil/gpencil_add_stroke.c | |
parent | 78a6fa1a7294d73a4f35b08d569d03f1afdd71ac (diff) |
Fix T56220: Adding Grease Object crashes if link Material is set to Object
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_add_stroke.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_add_stroke.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/source/blender/editors/gpencil/gpencil_add_stroke.c b/source/blender/editors/gpencil/gpencil_add_stroke.c index f932f98ac1d..c5020593bcb 100644 --- a/source/blender/editors/gpencil/gpencil_add_stroke.c +++ b/source/blender/editors/gpencil/gpencil_add_stroke.c @@ -55,11 +55,10 @@ typedef struct ColorTemplate { /* Add color an ensure duplications (matched by name) */ static int gp_stroke_material(Main *bmain, Object *ob, const ColorTemplate *pct) { - Material *ma = NULL; - Material ***matar = give_matarar(ob); short *totcol = give_totcolp(ob); + Material *ma = NULL; for (short i = 0; i < *totcol; i++) { - ma = (*matar)[i]; + ma = give_current_material(ob, i + 1); if (STREQ(ma->id.name, pct->name)) { return i; } @@ -73,7 +72,7 @@ static int gp_stroke_material(Main *bmain, Object *ob, const ColorTemplate *pct) copy_v4_v4(ma->gp_style->stroke_rgba, pct->line); copy_v4_v4(ma->gp_style->fill_rgba, pct->fill); - return BKE_object_material_slot_find_index(ob, ma) - 1; + return BKE_gpencil_get_material_index(ob, ma) - 1; } /* ***************************************************************** */ |