From ef457d599467ac9211bb9e3dc218e5c40f5a6a9a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 5 Feb 2013 14:33:55 +0000 Subject: [PATCH] fix [#34118] Crash, when clicking "Assign image to UV Map" --- source/blender/editors/mesh/mesh_data.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 1d13aa36a6b..3b7517d3987 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -575,13 +575,19 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - Base *base = ED_view3d_give_base_under_cursor(C, event->mval); + Base *base; Image *ima = NULL; Mesh *me; Object *obedit; int exitmode = 0; - char name[MAX_ID_NAME - 2]; + if (v3d == NULL) { + BKE_report(op->reports, RPT_ERROR, "No 3D View Available"); + return OPERATOR_CANCELLED; + } + + base = ED_view3d_give_base_under_cursor(C, event->mval); + /* Check context */ if (base == NULL || base->object->type != OB_MESH) { BKE_report(op->reports, RPT_ERROR, "Not an object or mesh"); @@ -596,6 +602,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) ima = BKE_image_load_exists(path); } else { + char name[MAX_ID_NAME - 2]; RNA_string_get(op->ptr, "name", name); ima = (Image *)BKE_libblock_find_name(ID_IM, name); }