diff options
author | Campbell Barton <campbell@blender.org> | 2022-01-07 07:13:31 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-01-07 07:15:08 +0300 |
commit | b3dc1a17a0e7b7e38a8ece70ca0d353aff82c154 (patch) | |
tree | 2eec6693f681341e9b9235ed639489aa3d217eb3 /source | |
parent | 2cd8238ce3394aa3cf89c4d8c17c71757dd61a08 (diff) |
Fix BKE_image_ensure_tile_token being called with a full path
Assert that only the file name component is passed in
since special handling for UDIM should only be applied to the file name.
Also remove an unnecessary NULL check on the filename argument.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_image.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 5 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_path_util.h | 10 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_300.c | 3 |
4 files changed, 10 insertions, 9 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index eb7738b9307..7b87189a13f 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -436,6 +436,7 @@ typedef enum { /** * Ensures that `filename` contains a UDIM token if we find a supported format pattern. + * \note This must only be the name component (without slashes). */ void BKE_image_ensure_tile_token(char *filename); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 2d4366846aa..4899c3671aa 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -4062,9 +4062,8 @@ bool BKE_image_fill_tile(struct Image *ima, void BKE_image_ensure_tile_token(char *filename) { - if (filename == NULL) { - return; - } + BLI_assert_msg(BLI_path_slash_find(filename) == NULL, + "Only the file-name component should be used!"); /* Is there a '<' character in the filename? Assume tokens already present. */ if (strstr(filename, "<") != NULL) { diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 85d4ed4a307..16f479cb3b8 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -142,7 +142,11 @@ bool BLI_path_contains(const char *container_path, const char *containee_path) ATTR_WARN_UNUSED_RESULT; /** - * Returns pointer to the rightmost path separator in string. + * \return pointer to the leftmost path separator in string (or NULL when not found). + */ +const char *BLI_path_slash_find(const char *string) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; +/** + * \return pointer to the rightmost path separator in string (or NULL when not found). */ const char *BLI_path_slash_rfind(const char *string) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; /** @@ -155,10 +159,6 @@ int BLI_path_slash_ensure(char *string) ATTR_NONNULL(); */ void BLI_path_slash_rstrip(char *string) ATTR_NONNULL(); /** - * Returns pointer to the leftmost path separator in string. Not actually used anywhere. - */ -const char *BLI_path_slash_find(const char *string) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; -/** * Changes to the path separators to the native ones for this OS. */ void BLI_path_slash_native(char *path) ATTR_NONNULL(); diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c index 5cfc937acf1..152684db8f1 100644 --- a/source/blender/blenloader/intern/versioning_300.c +++ b/source/blender/blenloader/intern/versioning_300.c @@ -824,7 +824,8 @@ void do_versions_after_linking_300(Main *bmain, ReportList *UNUSED(reports)) /* Ensure tiled image sources contain a UDIM token. */ LISTBASE_FOREACH (Image *, ima, &bmain->images) { if (ima->source == IMA_SRC_TILED) { - BKE_image_ensure_tile_token(ima->filepath); + char *filename = (char *)BLI_path_basename(ima->filepath); + BKE_image_ensure_tile_token(filename); } } } |