Fix #109561: Overwrite existing imagepath based on relativepath property #109815

Merged
Pratik Borhade merged 5 commits from PratikPB2123/blender:109561-overrite-image-path into main 2023-09-02 07:20:01 +02:00
Showing only changes of commit 29db26024b - Show all commits

View File

@ -1291,39 +1291,44 @@ static Image *image_open_single(Main *bmain,
return NULL;
}
if (!exists) {
/* only image path after save, never ibuf */
if (is_relative_path) {
BLI_path_rel(ima->filepath, relbase);
}
/* If image already exists, update its file path based on relative path property, see: #109561.
*/
if (exists) {
STRNCPY(ima->filepath, range->filepath);
return ima;
}

Doesn't this always make the path absolute?

I would think this following code needs to run for both the exists and not exists case?

  if (is_relative_path) {
    BLI_path_rel(ima->filepath, relbase);
  } 
Doesn't this always make the path absolute? I would think this following code needs to run for both the exists and not exists case? ``` if (is_relative_path) { BLI_path_rel(ima->filepath, relbase); } ```

Doesn't this always make the path absolute?

No. Before calling image_open_single, range->filepath is set to relative/absolute in ED_image_filesel_detect_sequences function execution.

So I don't think additional change is needed :)

@brecht , let me know if you think this change is not good and the explanation is not convincing. I'll update the PR then 😅

> Doesn't this always make the path absolute? No. Before calling `image_open_single`, range->filepath is set to relative/absolute in [ED_image_filesel_detect_sequences](https://projects.blender.org/blender/blender/src/branch/main/source/blender/editors/space_image/image_sequence.cc#L164) function execution. So I don't think additional change is needed :) @brecht , let me know if you think this change is not good and the explanation is not convincing. I'll update the PR then 😅

Then that would mean this code is also not needed for the !exists case, and can be removed? Otherwise it's confusing to me.

Then that would mean this code is also not needed for the `!exists` case, and can be removed? Otherwise it's confusing to me.

Yes, not needed. removed :)

Yes, not needed. removed :)
/* handle multiview images */
if (use_multiview) {
ImageOpenData *iod = op->customdata;
ImageFormatData *imf = &iod->im_format;
/* only image path after save, never ibuf */
if (is_relative_path) {
BLI_path_rel(ima->filepath, relbase);
}
ima->flag |= IMA_USE_VIEWS;
ima->views_format = imf->views_format;
*ima->stereo3d_format = imf->stereo3d_format;
}
else {
ima->flag &= ~IMA_USE_VIEWS;
BKE_image_free_views(ima);
}
/* handle multiview images */
if (use_multiview) {
ImageOpenData *iod = op->customdata;
ImageFormatData *imf = &iod->im_format;
if (ima->source == IMA_SRC_FILE) {
if (range->udims_detected && range->udim_tiles.first) {
ima->source = IMA_SRC_TILED;
ImageTile *first_tile = ima->tiles.first;
first_tile->tile_number = range->offset;
LISTBASE_FOREACH (LinkData *, node, &range->udim_tiles) {
BKE_image_add_tile(ima, POINTER_AS_INT(node->data), NULL);
}
}
else if (range->length > 1) {
ima->source = IMA_SRC_SEQUENCE;
ima->flag |= IMA_USE_VIEWS;
ima->views_format = imf->views_format;
*ima->stereo3d_format = imf->stereo3d_format;
}
else {
ima->flag &= ~IMA_USE_VIEWS;
BKE_image_free_views(ima);
}
if (ima->source == IMA_SRC_FILE) {
if (range->udims_detected && range->udim_tiles.first) {
ima->source = IMA_SRC_TILED;
ImageTile *first_tile = ima->tiles.first;
first_tile->tile_number = range->offset;
LISTBASE_FOREACH (LinkData *, node, &range->udim_tiles) {
BKE_image_add_tile(ima, POINTER_AS_INT(node->data), NULL);
}
}
else if (range->length > 1) {
ima->source = IMA_SRC_SEQUENCE;
}
}
return ima;