[Bf-blender-cvs] [2681e480eac] master: Fix T98579: image save operators changing file path to absolute

Brecht Van Lommel noreply at git.blender.org
Fri Jun 3 19:26:35 CEST 2022


Commit: 2681e480eac0603d21174ce3bba5166dae010279
Author: Brecht Van Lommel
Date:   Fri Jun 3 19:22:57 2022 +0200
Branches: master
https://developer.blender.org/rB2681e480eac0603d21174ce3bba5166dae010279

Fix T98579: image save operators changing file path to absolute

===================================================================

M	source/blender/blenkernel/intern/image_save.cc
M	source/blender/editors/space_image/image_ops.c

===================================================================

diff --git a/source/blender/blenkernel/intern/image_save.cc b/source/blender/blenkernel/intern/image_save.cc
index 6bfdaf9b522..9dda3762553 100644
--- a/source/blender/blenkernel/intern/image_save.cc
+++ b/source/blender/blenkernel/intern/image_save.cc
@@ -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);
 
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index e5b30372758..3e7ea663fcc 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -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);
   }



More information about the Bf-blender-cvs mailing list