Fix #22870: Can't save modified non-packed images. File exist check
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 21 Jul 2010 14:09:45 +0000 (14:09 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 21 Jul 2010 14:09:45 +0000 (14:09 +0000)
wasn't taking into account that there could be relative paths.

source/blender/editors/space_image/image_ops.c

index 3e26963..03fc7da 100644 (file)
@@ -127,10 +127,15 @@ static int space_image_file_exists_poll(bContext *C)
                SpaceImage *sima= CTX_wm_space_image(C);
                ImBuf *ibuf;
                void *lock;
-               int poll;
-               
+               int poll= 0;
+               char name[FILE_MAX];
+
                ibuf= ED_space_image_acquire_buffer(sima, &lock);
-               poll= (ibuf && BLI_exists(ibuf->name) && BLI_is_writable(ibuf->name));
+               if(ibuf) {
+                       BLI_strncpy(name, ibuf->name, FILE_MAX);
+                       BLI_path_abs(name, G.sce);
+                       poll= (BLI_exists(name) && BLI_is_writable(name));
+               }
                ED_space_image_release_buffer(sima, lock);
 
                return poll;
@@ -1030,6 +1035,8 @@ static int save_exec(bContext *C, wmOperator *op)
        BLI_strncpy(name, ibuf->name, FILE_MAX);
        if(name[0]==0)
                BLI_strncpy(name, G.ima, FILE_MAX);
+       else
+               BLI_path_abs(name, G.sce);
        
        if(BLI_exists(name) && BLI_is_writable(name)) {
                rr= BKE_image_acquire_renderresult(scene, ima);