Fix for dropping images into the 3D View

- wasn't allocing image-user.
- wasn't managing user counts.
This commit is contained in:
Campbell Barton 2014-05-07 16:53:58 +10:00
parent 77d11a52b3
commit dcabd3f81f
1 changed files with 7 additions and 2 deletions

View File

@ -795,6 +795,8 @@ void OBJECT_OT_empty_add(wmOperatorType *ot)
static int empty_drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Scene *scene = CTX_data_scene(C);
Base *base = NULL;
Image *ima = NULL;
Object *ob = NULL;
@ -823,7 +825,7 @@ static int empty_drop_named_image_invoke(bContext *C, wmOperator *op, const wmEv
/* if empty under cursor, then set object */
if (base && base->object->type == OB_EMPTY) {
ob = base->object;
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, CTX_data_scene(C));
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
}
else {
/* add new empty */
@ -840,8 +842,11 @@ static int empty_drop_named_image_invoke(bContext *C, wmOperator *op, const wmEv
ED_view3d_cursor3d_position(C, ob->loc, event->mval);
}
ob->empty_drawtype = OB_EMPTY_IMAGE;
BKE_object_empty_draw_type_set(ob, OB_EMPTY_IMAGE);
id_us_min(ob->data);
ob->data = ima;
id_us_plus(ob->data);
return OPERATOR_FINISHED;
}