From 9c5d1042244e833704cad5b50ab89c7792448f33 Mon Sep 17 00:00:00 2001 From: Antonioya Date: Wed, 12 Dec 2018 19:48:24 +0100 Subject: Fix T59248: Crash in Grease Pencil Edit mode when adding Annotation --- .../draw/engines/gpencil/gpencil_draw_utils.c | 40 ++++++++++++---------- .../blender/draw/engines/gpencil/gpencil_engine.c | 4 ++- 2 files changed, 25 insertions(+), 19 deletions(-) (limited to 'source/blender/draw') diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c index fe950d2a228..2450f9419bf 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c @@ -1387,28 +1387,32 @@ static void DRW_gpencil_shgroups_create( } case eGpencilBatchGroupType_Edit: { - const int len = elm->vertex_idx - start_edit; - /* use always the same group */ - DRW_shgroup_call_range_add( - stl->g_data->shgrps_edit_point, - cache->b_edit.batch, - (!cache_ob->is_dup_ob) ? gpf->runtime.viewmatrix : cache_ob->obmat, - start_edit, len); - - start_edit = elm->vertex_idx; + if (stl->g_data->shgrps_edit_point) { + const int len = elm->vertex_idx - start_edit; + /* use always the same group */ + DRW_shgroup_call_range_add( + stl->g_data->shgrps_edit_point, + cache->b_edit.batch, + (!cache_ob->is_dup_ob) ? gpf->runtime.viewmatrix : cache_ob->obmat, + start_edit, len); + + start_edit = elm->vertex_idx; + } break; } case eGpencilBatchGroupType_Edlin: { - const int len = elm->vertex_idx - start_edlin; - /* use always the same group */ - DRW_shgroup_call_range_add( - stl->g_data->shgrps_edit_line, - cache->b_edlin.batch, - (!cache_ob->is_dup_ob) ? gpf->runtime.viewmatrix : cache_ob->obmat, - start_edlin, len); - - start_edlin = elm->vertex_idx; + if (stl->g_data->shgrps_edit_line) { + const int len = elm->vertex_idx - start_edlin; + /* use always the same group */ + DRW_shgroup_call_range_add( + stl->g_data->shgrps_edit_line, + cache->b_edlin.batch, + (!cache_ob->is_dup_ob) ? gpf->runtime.viewmatrix : cache_ob->obmat, + start_edlin, len); + + start_edlin = elm->vertex_idx; + } break; } default: diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index 483d6a80991..11bb5c76257 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -719,6 +719,8 @@ void GPENCIL_draw_scene(void *ved) Object *obact = draw_ctx->obact; const bool playing = stl->storage->is_playing; const bool is_render = stl->storage->is_render; + bGPdata *gpd_act = (obact) && (obact->type == OB_GPENCIL) ? (bGPdata *)obact->data : NULL; + const bool is_edit = GPENCIL_ANY_EDIT_MODE(gpd_act); /* paper pass to display a comfortable area to draw over complex scenes with geometry */ if ((!is_render) && (obact) && (obact->type == OB_GPENCIL)) { @@ -875,7 +877,7 @@ void GPENCIL_draw_scene(void *ved) } } /* edit points */ - if ((!is_render) && (!playing)) { + if ((!is_render) && (!playing) && (is_edit)) { DRW_draw_pass(psl->edit_pass); } } -- cgit v1.2.3