diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2019-09-13 17:22:02 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2019-09-13 17:22:02 +0300 |
commit | 59f9c39f74bb3a73f163cf7714c3dfe67a952b5b (patch) | |
tree | b33a47a25b8da1fe0e8f66706b6679fecc0c7592 | |
parent | d4fb85036640505b5bcbd5e0ef69512de46aa0ad (diff) |
Fix T69846: Segment fault converting Curves to GPencil strokes
The problem was when the material slot had something, but the material was NULL.
-rw-r--r-- | source/blender/blenkernel/intern/gpencil.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index a7301af3176..a50926ae7ab 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -2817,23 +2817,27 @@ static void gpencil_convert_spline(Main *bmain, /* If object has more than 1 material, use second material for stroke color. */ if ((!only_stroke) && (ob_cu->totcol > 1) && (give_current_material(ob_cu, 2))) { mat_curve = give_current_material(ob_cu, 2); - linearrgb_to_srgb_v3_v3(mat_gp->gp_style->stroke_rgba, &mat_curve->r); - mat_gp->gp_style->stroke_rgba[3] = mat_curve->a; + if (mat_curve) { + linearrgb_to_srgb_v3_v3(mat_gp->gp_style->stroke_rgba, &mat_curve->r); + mat_gp->gp_style->stroke_rgba[3] = mat_curve->a; + } } else if ((only_stroke) || (do_stroke)) { /* Also use the first color if the fill is none for stroke color. */ if (ob_cu->totcol > 0) { mat_curve = give_current_material(ob_cu, 1); - linearrgb_to_srgb_v3_v3(mat_gp->gp_style->stroke_rgba, &mat_curve->r); - mat_gp->gp_style->stroke_rgba[3] = mat_curve->a; - /* Set fill and stroke depending of curve type (3D or 2D). */ - if ((cu->flag & CU_3D) || ((cu->flag & (CU_FRONT | CU_BACK)) == 0)) { - mat_gp->gp_style->flag |= GP_STYLE_STROKE_SHOW; - mat_gp->gp_style->flag &= ~GP_STYLE_FILL_SHOW; - } - else { - mat_gp->gp_style->flag &= ~GP_STYLE_STROKE_SHOW; - mat_gp->gp_style->flag |= GP_STYLE_FILL_SHOW; + if (mat_curve) { + linearrgb_to_srgb_v3_v3(mat_gp->gp_style->stroke_rgba, &mat_curve->r); + mat_gp->gp_style->stroke_rgba[3] = mat_curve->a; + /* Set fill and stroke depending of curve type (3D or 2D). */ + if ((cu->flag & CU_3D) || ((cu->flag & (CU_FRONT | CU_BACK)) == 0)) { + mat_gp->gp_style->flag |= GP_STYLE_STROKE_SHOW; + mat_gp->gp_style->flag &= ~GP_STYLE_FILL_SHOW; + } + else { + mat_gp->gp_style->flag &= ~GP_STYLE_STROKE_SHOW; + mat_gp->gp_style->flag |= GP_STYLE_FILL_SHOW; + } } } } |