[Bf-blender-cvs] [59f9c39f74b] master: Fix T69846: Segment fault converting Curves to GPencil strokes

Antonio Vazquez noreply at git.blender.org
Fri Sep 13 16:22:09 CEST 2019


Commit: 59f9c39f74bb3a73f163cf7714c3dfe67a952b5b
Author: Antonio Vazquez
Date:   Fri Sep 13 16:22:02 2019 +0200
Branches: master
https://developer.blender.org/rB59f9c39f74bb3a73f163cf7714c3dfe67a952b5b

Fix T69846: Segment fault converting Curves to GPencil strokes

The problem was when the material slot had something, but the material was NULL.

===================================================================

M	source/blender/blenkernel/intern/gpencil.c

===================================================================

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;
+          }
         }
       }
     }



More information about the Bf-blender-cvs mailing list