Small bug, reported by Andy in irc:
authorTon Roosendaal <ton@blender.org>
Mon, 8 Nov 2010 19:03:42 +0000 (19:03 +0000)
committerTon Roosendaal <ton@blender.org>
Mon, 8 Nov 2010 19:03:42 +0000 (19:03 +0000)
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/blenkernel/intern/texture.c
source/blender/editors/space_image/image_ops.c

index da3dea3722006cb8222d330250fea096807ca397..6a5e5a007f348117ea5d916b8c50270016a03444 100644 (file)
@@ -573,6 +573,7 @@ void default_tex(Tex *tex)
        tex->iuser.fie_ima= 2;
        tex->iuser.ok= 1;
        tex->iuser.frames= 100;
+       tex->iuser.sfra= 1;
        
        tex->preview = NULL;
 }
index f51576c613d9682e587216ff9cb8c4a45cf79ca9..fe8b499285f173b49c17bcad80cd685a363b3c99 100644 (file)
@@ -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 */