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.
This commit is contained in:
Campbell Barton 2022-01-07 15:13:31 +11:00
parent 2cd8238ce3
commit b3dc1a17a0
4 changed files with 10 additions and 9 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -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;
/**
@ -154,10 +158,6 @@ int BLI_path_slash_ensure(char *string) ATTR_NONNULL();
* Removes the last slash and everything after it to the end of string, if there is one.
*/
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.
*/

View File

@ -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);
}
}
}