Fix T98579: image save operators changing file path to absolute

This commit is contained in:
Brecht Van Lommel 2022-06-03 19:22:57 +02:00
parent da45c12bef
commit 2681e480ea
Notes: blender-bot 2023-02-14 09:29:42 +01:00
Referenced by issue #98579, Saving external image texture makes path absolute
2 changed files with 8 additions and 7 deletions

View File

@ -274,6 +274,12 @@ static void image_save_post(ReportList *reports,
if (opts->do_newpath) {
BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name));
BLI_strncpy(ima->filepath, filepath, sizeof(ima->filepath));
/* only image path, never ibuf */
if (opts->relative) {
const char *relbase = ID_BLEND_PATH(opts->bmain, &ima->id);
BLI_path_rel(ima->filepath, relbase); /* only after saving */
}
}
ibuf->userflags &= ~IB_BITMAPDIRTY;
@ -303,12 +309,6 @@ static void image_save_post(ReportList *reports,
ima->type = IMA_TYPE_IMAGE;
}
/* only image path, never ibuf */
if (opts->relative) {
const char *relbase = ID_BLEND_PATH(opts->bmain, &ima->id);
BLI_path_rel(ima->filepath, relbase); /* only after saving */
}
/* Update image file color space when saving to another color space. */
const bool linear_float_output = BKE_imtype_requires_linear_float(opts->im_format.imtype);

View File

@ -1810,7 +1810,6 @@ static void image_save_options_from_op(Main *bmain, ImageSaveOptions *opts, wmOp
RNA_boolean_get(op->ptr, "copy"));
opts->save_as_render = (RNA_struct_find_property(op->ptr, "save_as_render") &&
RNA_boolean_get(op->ptr, "save_as_render"));
opts->do_newpath = true;
}
static bool save_image_op(
@ -1847,6 +1846,8 @@ static ImageSaveData *image_save_as_init(bContext *C, wmOperator *op)
return NULL;
}
isd->opts.do_newpath = true;
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
RNA_string_set(op->ptr, "filepath", isd->opts.filepath);
}