[Bf-blender-cvs] [dcabd3f] master: Fix for dropping images into the 3D View - wasn't allocing image-user. - wasn't managing user counts.

Campbell Barton noreply at git.blender.org
Wed May 7 08:57:19 CEST 2014


Commit: dcabd3f81fd278c6029764df415b1257402c07ad
Author: Campbell Barton
Date:   Wed May 7 16:53:58 2014 +1000
https://developer.blender.org/rBdcabd3f81fd278c6029764df415b1257402c07ad

Fix for dropping images into the 3D View
- wasn't allocing image-user.
- wasn't managing user counts.

===================================================================

M	source/blender/editors/object/object_add.c

===================================================================

diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index eaa8958..99dd8b7 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -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;
 }




More information about the Bf-blender-cvs mailing list