Fix: failure to set relative paths when adding an image strip

Calling SEQUENCER_OT_image_strip_add from Python attempted to
read a non-existent property "filepath" to check if the path was
relative. Use the "directory" for this instead.

The error occurred with the test file from #146433.

Ref !147100
This commit is contained in:
Campbell Barton
2025-10-01 15:23:53 +10:00
parent 1884e049e8
commit 7d67113a8a

View File

@@ -29,7 +29,7 @@
*
* The output is a list of frame ranges, each containing a list of frames with matching names.
*/
static void image_sequence_get_frame_ranges(wmOperator *op, ListBase *ranges)
static void image_sequence_get_frame_ranges(wmOperator *op, ListBase *ranges, bool *r_was_relative)
{
char dir[FILE_MAXDIR];
const bool do_frame_range = RNA_boolean_get(op->ptr, "use_sequence_detection");
@@ -75,6 +75,8 @@ static void image_sequence_get_frame_ranges(wmOperator *op, ListBase *ranges)
MEM_freeN(filename);
}
RNA_END;
*r_was_relative = BLI_path_is_rel(dir);
}
static int image_cmp_frame(const void *a, const void *b)
@@ -143,16 +145,12 @@ ListBase ED_image_filesel_detect_sequences(blender::StringRefNull root_path,
ListBase ranges;
BLI_listbase_clear(&ranges);
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
/* File browser. */
if (RNA_struct_property_is_set(op->ptr, "directory") &&
RNA_struct_property_is_set(op->ptr, "files"))
{
const bool was_relative = BLI_path_is_rel(filepath);
image_sequence_get_frame_ranges(op, &ranges);
bool was_relative = false;
image_sequence_get_frame_ranges(op, &ranges, &was_relative);
LISTBASE_FOREACH (ImageFrameRange *, range, &ranges) {
image_detect_frame_range(range, detect_udim);
@@ -163,6 +161,9 @@ ListBase ED_image_filesel_detect_sequences(blender::StringRefNull root_path,
}
/* Filepath property for drag & drop etc. */
else {
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
ImageFrameRange *range = MEM_callocN<ImageFrameRange>(__func__);
BLI_addtail(&ranges, range);