From 7fd87de47bbf45bb15cd9e37c2a98d0b729bf16c Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 8 Nov 2010 19:03:42 +0000 Subject: Small bug, reported by Andy in irc: Image editor & texture properties, add new Image, inits 'start' now to frame 1 for sequences. Added triple-X warning in Image Open operator, it uses SpaceImage whilst it can be called from other editors. Code is safe but not correct. --- source/blender/editors/space_image/image_ops.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index f51576c613d..fe8b499285f 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -688,9 +688,10 @@ static int open_cancel(bContext *UNUSED(C), wmOperator *op) static int open_exec(bContext *C, wmOperator *op) { - SpaceImage *sima= CTX_wm_space_image(C); + SpaceImage *sima= CTX_wm_space_image(C); /* XXX other space types can call */ Scene *scene= CTX_data_scene(C); Object *obedit= CTX_data_edit_object(C); + ImageUser *iuser= NULL; PropertyPointerRNA *pprop; PointerRNA idptr; Image *ima= NULL; @@ -724,11 +725,25 @@ static int open_exec(bContext *C, wmOperator *op) RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr); RNA_property_update(C, &pprop->ptr, pprop->prop); } - else if(sima) + else if(sima) { ED_space_image_set(C, sima, scene, obedit, ima); + iuser= &sima->iuser; + } + else { + Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; + if(tex && tex->type==TEX_IMAGE) + iuser= &tex->iuser; + + } + + /* initialize because of new image */ + if(iuser) { + iuser->sfra= 1; + iuser->offset= 0; + iuser->fie_ima= 2; + } - // XXX other users? - BKE_image_signal(ima, (sima)? &sima->iuser: NULL, IMA_SIGNAL_RELOAD); + BKE_image_signal(ima, iuser, IMA_SIGNAL_RELOAD); WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, ima); MEM_freeN(op->customdata); @@ -738,7 +753,7 @@ static int open_exec(bContext *C, wmOperator *op) static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - SpaceImage *sima= CTX_wm_space_image(C); + SpaceImage *sima= CTX_wm_space_image(C); /* XXX other space types can call */ char *path=U.textudir; Image *ima= NULL; @@ -769,6 +784,7 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) return OPERATOR_RUNNING_MODAL; } +/* called by other space types too */ void IMAGE_OT_open(wmOperatorType *ot) { /* identifiers */ -- cgit v1.2.3