fix [#34118] Crash, when clicking "Assign image to UV Map"

This commit is contained in:
Campbell Barton 2013-02-05 14:33:55 +00:00
parent 25cbd13d22
commit ef457d5994

@ -575,12 +575,18 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
Main *bmain = CTX_data_main(C); Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C); Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C); View3D *v3d = CTX_wm_view3d(C);
Base *base = ED_view3d_give_base_under_cursor(C, event->mval); Base *base;
Image *ima = NULL; Image *ima = NULL;
Mesh *me; Mesh *me;
Object *obedit; Object *obedit;
int exitmode = 0; 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 */ /* Check context */
if (base == NULL || base->object->type != OB_MESH) { if (base == NULL || base->object->type != OB_MESH) {
@ -596,6 +602,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
ima = BKE_image_load_exists(path); ima = BKE_image_load_exists(path);
} }
else { else {
char name[MAX_ID_NAME - 2];
RNA_string_get(op->ptr, "name", name); RNA_string_get(op->ptr, "name", name);
ima = (Image *)BKE_libblock_find_name(ID_IM, name); ima = (Image *)BKE_libblock_find_name(ID_IM, name);
} }