Revision: 41328
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41328
Author:   campbellbarton
Date:     2011-10-28 04:05:52 +0000 (Fri, 28 Oct 2011)
Log Message:
-----------
fix [#29062] Can not save image as external on a writable path

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_image/image_ops.c

Modified: trunk/blender/source/blender/editors/space_image/image_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_ops.c        
2011-10-28 03:02:09 UTC (rev 41327)
+++ trunk/blender/source/blender/editors/space_image/image_ops.c        
2011-10-28 04:05:52 UTC (rev 41328)
@@ -134,18 +134,27 @@
                SpaceImage *sima= CTX_wm_space_image(C);
                ImBuf *ibuf;
                void *lock;
-               int poll= 0;
+               int ret= FALSE;
                char name[FILE_MAX];
 
                ibuf= ED_space_image_acquire_buffer(sima, &lock);
                if(ibuf) {
                        BLI_strncpy(name, ibuf->name, FILE_MAX);
                        BLI_path_abs(name, bmain->name);
-                       poll= (BLI_exists(name) && BLI_file_is_writable(name));
+
+                       if(BLI_exists(name) == FALSE) {
+                               CTX_wm_operator_poll_msg_set(C, "image file not 
found");
+                       }
+                       else if (BLI_file_is_writable(name) == FALSE) {
+                               CTX_wm_operator_poll_msg_set(C, "image path 
can't be written to");
+                       }
+                       else {
+                               ret= TRUE;
+                       }
                }
                ED_space_image_release_buffer(sima, lock);
 
-               return poll;
+               return ret;
        }
        return 0;
 }
@@ -1032,7 +1041,7 @@
        ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock);
 
        if (ibuf) {
-               Main *bmain= CTX_data_main(C);
+               const char *relbase= ID_BLEND_PATH(CTX_data_main(C), &ima->id);
                const short relative= (RNA_struct_find_property(op->ptr, 
"relative_path") && RNA_boolean_get(op->ptr, "relative_path"));
                const short save_copy= (RNA_struct_find_property(op->ptr, 
"copy") && RNA_boolean_get(op->ptr, "copy"));
                short ok= FALSE;
@@ -1075,19 +1084,11 @@
                        ok= TRUE;
                }
 
-               if(ok)  {
-                       if(relative)
-                               BLI_path_rel(simopts->filepath, bmain->name); 
/* only after saving */
-
-                       if(ibuf->name[0]==0) {
-                               BLI_strncpy(ibuf->name, simopts->filepath, 
sizeof(ibuf->name));
-                               BLI_strncpy(ima->name, simopts->filepath, 
sizeof(ima->name));
-                       }
-
+               if (ok) {
                        if(!save_copy) {
                                if(do_newpath) {
+                                       BLI_strncpy(ibuf->name, 
simopts->filepath, sizeof(ibuf->name));
                                        BLI_strncpy(ima->name, 
simopts->filepath, sizeof(ima->name));
-                                       BLI_strncpy(ibuf->name, 
simopts->filepath, sizeof(ibuf->name));
                                }
 
                                ibuf->userflags &= ~IB_BITMAPDIRTY;
@@ -1112,6 +1113,11 @@
                                        ima->source= IMA_SRC_FILE;
                                        ima->type= IMA_TYPE_IMAGE;
                                }
+
+                               /* only image path, never ibuf */
+                               if(relative) {
+                                       BLI_path_rel(ima->name, relbase); /* 
only after saving */
+                               }
                        }
                }
                else {

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to