Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-10-28 08:05:52 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-10-28 08:05:52 +0400
commit3ad7445e28eaf36bf7a7907072205a757cc284d7 (patch)
treee12e1adee90699a75136fccc07d8efe579ece792 /source/blender
parent592879bfca658d18fca54bd6a715304008a77f2c (diff)
fix [#29062] Can not save image as external on a writable path
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/space_image/image_ops.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 194a8bdbf01..c83baf24c1c 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -134,18 +134,27 @@ static int space_image_file_exists_poll(bContext *C)
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 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
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 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
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(ima->name, simopts->filepath, sizeof(ima->name));
BLI_strncpy(ibuf->name, simopts->filepath, sizeof(ibuf->name));
+ BLI_strncpy(ima->name, simopts->filepath, sizeof(ima->name));
}
ibuf->userflags &= ~IB_BITMAPDIRTY;
@@ -1112,6 +1113,11 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
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 {