diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-01-15 20:17:53 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-01-15 20:54:11 +0300 |
commit | b1fa2a8fbbd9d17da7e1fea8afd29055f47113c8 (patch) | |
tree | 964af322d2f74961de27892b7a5feb465a4d1ec4 /source/blender/editors/gpencil/drawgpencil.c | |
parent | eb61e6840efc1323bc021b44f1bb0f958b3f71b8 (diff) |
Fix T59826: grease pencil crash with empty material slot.
Diffstat (limited to 'source/blender/editors/gpencil/drawgpencil.c')
-rw-r--r-- | source/blender/editors/gpencil/drawgpencil.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 72660c90837..548ccac7de3 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -602,7 +602,7 @@ static void gp_draw_stroke_fill( { BLI_assert(gps->totpoints >= 3); Material *ma = gpd->mat[gps->mat_nr]; - MaterialGPencilStyle *gp_style = ma->gp_style; + MaterialGPencilStyle *gp_style = (ma) ? ma->gp_style : NULL; /* Calculate triangles cache for filling area (must be done only after changes) */ if ((gps->flag & GP_STROKE_RECALC_GEOMETRY) || (gps->tot_triangles == 0) || (gps->triangles == NULL)) { @@ -1013,7 +1013,7 @@ static void gp_draw_strokes(tGPDdraw *tgpw) } /* check if the color is visible */ Material *ma = tgpw->gpd->mat[gps->mat_nr]; - MaterialGPencilStyle *gp_style = ma->gp_style; + MaterialGPencilStyle *gp_style = (ma) ? ma->gp_style : NULL; if ((gp_style == NULL) || (gp_style->flag & GP_STYLE_COLOR_HIDE) || @@ -1233,7 +1233,7 @@ static void gp_draw_strokes_edit( /* verify color lock */ { Material *ma = gpd->mat[gps->mat_nr]; - MaterialGPencilStyle *gp_style = ma->gp_style; + MaterialGPencilStyle *gp_style = (ma) ? ma->gp_style : NULL; if (gp_style != NULL) { if (gp_style->flag & GP_STYLE_COLOR_HIDE) { @@ -1263,7 +1263,7 @@ static void gp_draw_strokes_edit( /* for now, we assume that the base color of the points is not too close to the real color */ /* set color using material */ Material *ma = gpd->mat[gps->mat_nr]; - MaterialGPencilStyle *gp_style = ma->gp_style; + MaterialGPencilStyle *gp_style = (ma) ? ma->gp_style : NULL; float selectColor[4]; UI_GetThemeColor3fv(TH_GP_VERTEX_SELECT, selectColor); @@ -1307,10 +1307,14 @@ static void gp_draw_strokes_edit( immAttr3fv(color, selectColor); immAttr1f(size, vsize); } - else { + else if (gp_style) { immAttr3fv(color, gp_style->stroke_rgba); immAttr1f(size, bsize); } + else { + immAttr3f(color, 0.0f, 0.0f, 0.0f); + immAttr1f(size, bsize); + } /* then position */ if (gps->flag & GP_STROKE_3DSPACE) { |