[Bf-blender-cvs] [9f7f4c1a6a8] master: Fix T62194: Blender crash after makingnew file after using Grease Pencil.

Antonioya noreply at git.blender.org
Tue Mar 5 12:06:57 CET 2019


Commit: 9f7f4c1a6a838329ce6d11974a9d5595595b6032
Author: Antonioya
Date:   Tue Mar 5 12:06:37 2019 +0100
Branches: master
https://developer.blender.org/rB9f7f4c1a6a838329ce6d11974a9d5595595b6032

Fix T62194: Blender crash after makingnew file after using Grease Pencil.

The crash was detected in draw_manager, but the real problem was a wrong pointer that corrupted the struct, so the free function failed.

Redesign this area to keep pointer correct all the time.

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

M	source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M	source/blender/draw/engines/gpencil/gpencil_engine.c
M	source/blender/draw/engines/gpencil/gpencil_engine.h

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 24bb2c9dd14..fb84cd5b612 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -565,9 +565,7 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(
 
 		/* viewport x-ray */
 		DRW_shgroup_uniform_int(grp, "viewport_xray", &stl->storage->is_xray, 1);
-
-		stl->shgroups[id].shading_type[0] = (int)OB_RENDER;
-		DRW_shgroup_uniform_int(grp, "shading_type", &stl->shgroups[id].shading_type[0], 2);
+		DRW_shgroup_uniform_int(grp, "shading_type", (const int *)&stl->storage->shade_render, 2);
 	}
 
 	if ((gpd) && (id > -1)) {
@@ -1347,7 +1345,6 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data, void *vedata, T
 	bGPdata *gpd = (bGPdata *)DEG_get_original_id(&gpd_eval->id);
 
 	MaterialGPencilStyle *gp_style = NULL;
-	const int shade_render[2] = { OB_RENDER, 0 };
 	float obscale = mat4_to_scale(ob->obmat);
 
 	/* use the brush material */
@@ -1375,12 +1372,12 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data, void *vedata, T
 				if ((gp_style) && (gp_style->mode == GP_STYLE_MODE_LINE)) {
 					stl->g_data->shgrps_drawing_stroke = DRW_gpencil_shgroup_stroke_create(
 						e_data, vedata, psl->drawing_pass, e_data->gpencil_stroke_sh, NULL,
-						gpd, NULL, NULL, gp_style, -1, false, 1.0f, shade_render);
+						gpd, NULL, NULL, gp_style, -1, false, 1.0f, stl->storage->shade_render);
 				}
 				else {
 					stl->g_data->shgrps_drawing_stroke = DRW_gpencil_shgroup_point_create(
 						e_data, vedata, psl->drawing_pass, e_data->gpencil_point_sh, NULL,
-						gpd, NULL, gp_style, -1, false, 1.0f, shade_render);
+						gpd, NULL, gp_style, -1, false, 1.0f, stl->storage->shade_render);
 				}
 
 				/* clean previous version of the batch */
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 2cbdb3bb918..97b81e3ba1f 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -248,6 +248,8 @@ void GPENCIL_engine_init(void *vedata)
 
 		/* unit matrix */
 		unit_m4(stl->storage->unit_matrix);
+		stl->storage->shade_render[0] = OB_RENDER;
+		stl->storage->shade_render[1] = 0;
 	}
 
 	stl->storage->multisamples = U.gpencil_multisamples;
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index c988033e722..fc45463fa1a 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -170,6 +170,7 @@ typedef struct GPENCIL_Storage {
 	float view_vecs[2][4]; /* vec4[2] */
 
 	float grid_matrix[4][4];
+	int shade_render[2];
 
 	Object *camera; /* camera pointer for render mode */
 } GPENCIL_Storage;



More information about the Bf-blender-cvs mailing list