From 9f7f4c1a6a838329ce6d11974a9d5595595b6032 Mon Sep 17 00:00:00 2001 From: Antonioya Date: Tue, 5 Mar 2019 12:06:37 +0100 Subject: 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. --- source/blender/draw/engines/gpencil/gpencil_draw_utils.c | 9 +++------ source/blender/draw/engines/gpencil/gpencil_engine.c | 2 ++ source/blender/draw/engines/gpencil/gpencil_engine.h | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source') 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; -- cgit v1.2.3