[Bf-blender-cvs] [6fc5f241ca2] greasepencil-object: Fix segment fault if palette is missing

Antonio Vazquez noreply at git.blender.org
Thu Jun 15 18:38:25 CEST 2017


Commit: 6fc5f241ca2b4bba188d0478de51e39372241a24
Author: Antonio Vazquez
Date:   Thu Jun 15 16:57:37 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB6fc5f241ca2b4bba188d0478de51e39372241a24

Fix segment fault if palette is missing

In some weird situations the palette can be removed.

We could consider to remove all strokes in this situation, but need further analysis. We keep the pointer checking as initial solution.

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

M	source/blender/draw/engines/gpencil/gpencil_geom.c
M	source/blender/editors/gpencil/gpencil_utils.c

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_geom.c b/source/blender/draw/engines/gpencil/gpencil_geom.c
index db7c26a74f5..2f12843a6c6 100644
--- a/source/blender/draw/engines/gpencil/gpencil_geom.c
+++ b/source/blender/draw/engines/gpencil/gpencil_geom.c
@@ -373,7 +373,7 @@ bool gpencil_can_draw_stroke(const bGPDstroke *gps, const bool onion)
 
 	/* check if the color is visible */
 	PaletteColor *palcolor = gps->palcolor;
-	if ((palcolor == NULL) ||
+	if ((gps->palette == NULL) || (palcolor == NULL) ||
 		(palcolor->flag & PC_COLOR_HIDE) ||
 		(onion && (palcolor->flag & PC_COLOR_ONIONSKIN)))
 	{
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index a3ab81584d7..1b799433efe 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -428,7 +428,7 @@ bool ED_gpencil_stroke_color_use(const bGPDlayer *gpl, const bGPDstroke *gps)
 {
 	/* check if the color is editable */
 	PaletteColor *palcolor = gps->palcolor;
-	if (palcolor != NULL) {
+	if ((gps->palette) && (palcolor != NULL)) {
 		if (palcolor->flag & PC_COLOR_HIDE)
 			return false;
 		if (((gpl->flag & GP_LAYER_UNLOCK_COLOR) == 0) && (palcolor->flag & PC_COLOR_LOCKED))




More information about the Bf-blender-cvs mailing list