diff options
author | Richard Antalik <richardantalik@gmail.com> | 2021-03-30 03:41:12 +0300 |
---|---|---|
committer | Richard Antalik <richardantalik@gmail.com> | 2021-03-30 03:58:53 +0300 |
commit | 6c6f3baaa8c5d3a0cc3eb033e93cc6fb0f5721cc (patch) | |
tree | a7f2c1c3cb4965209cc02e88a51b493a60770d54 /source/blender/editors/space_sequencer | |
parent | 7d467915a461d003daf26bb9f82afa2e93d4b8ea (diff) |
VSE: Fix image adding inconsistency
When adding images with operator, image file path is split into filename
and directory passed to load function in name and path fields of
SeqLoadData struct. This is because when loading images directory
and filenames are split.
RNA API function passes whole path in path filed.
Apart from loading API inconsistency, this causes initial image loading
to fail, so strip resolution is not set. Also name field of SeqLoadData
should be reserved for strip name.
Let operator code concatenate and split filepath when needed so loading
API can be consistent with RNA API and also between strip types.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D10818
Diffstat (limited to 'source/blender/editors/space_sequencer')
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_add.c | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index a6e7903d1b1..2df8dce0b3c 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -228,7 +228,6 @@ static void load_data_init_from_operator(SeqLoadData *load_data, bContext *C, wm PropertyRNA *prop; const bool relative = (prop = RNA_struct_find_property(op->ptr, "relative_path")) && RNA_property_boolean_get(op->ptr, prop); - int is_file = -1; memset(load_data, 0, sizeof(SeqLoadData)); load_data->start_frame = RNA_int_get(op->ptr, "frame_start"); @@ -242,17 +241,26 @@ static void load_data_init_from_operator(SeqLoadData *load_data, bContext *C, wm } if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) { - /* Full path, file is set by the caller. */ RNA_property_string_get(op->ptr, prop, load_data->path); - is_file = 1; + BLI_strncpy(load_data->name, BLI_path_basename(load_data->path), sizeof(load_data->name)); } else if ((prop = RNA_struct_find_property(op->ptr, "directory"))) { - /* Full path, file is set by the caller. */ - RNA_property_string_get(op->ptr, prop, load_data->path); - is_file = 0; + char *directory = RNA_string_get_alloc(op->ptr, "directory", NULL, 0); + + if ((prop = RNA_struct_find_property(op->ptr, "files"))) { + RNA_PROP_BEGIN (op->ptr, itemptr, prop) { + char *filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0); + BLI_strncpy(load_data->name, filename, sizeof(load_data->name)); + BLI_snprintf(load_data->path, sizeof(load_data->path), "%s%s", directory, filename); + MEM_freeN(filename); + break; + } + RNA_PROP_END; + } + MEM_freeN(directory); } - if ((is_file != -1) && relative) { + if (relative) { BLI_path_rel(load_data->path, BKE_main_blendfile_path(bmain)); } @@ -276,19 +284,6 @@ static void load_data_init_from_operator(SeqLoadData *load_data, bContext *C, wm load_data->flags |= SEQ_LOAD_MOVIE_SYNC_FPS; } - if (is_file == 1) { - BLI_strncpy(load_data->name, BLI_path_basename(load_data->path), sizeof(load_data->name)); - } - else if ((prop = RNA_struct_find_property(op->ptr, "files"))) { - RNA_PROP_BEGIN (op->ptr, itemptr, prop) { - char *name = RNA_string_get_alloc(&itemptr, "name", NULL, 0); - BLI_strncpy(load_data->name, name, sizeof(load_data->name)); - MEM_freeN(name); - break; - } - RNA_PROP_END; - } - if ((prop = RNA_struct_find_property(op->ptr, "use_multiview")) && RNA_property_boolean_get(op->ptr, prop)) { if (op->customdata) { @@ -990,8 +985,10 @@ static void sequencer_add_image_strip_load_files( wmOperator *op, Sequence *seq, SeqLoadData *load_data, const int minframe, const int numdigits) { const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders"); - - SEQ_add_image_set_directory(seq, load_data->path); + /* size of Strip->dir. */ + char directory[768]; + BLI_split_dir_part(load_data->path, directory, sizeof(directory)); + SEQ_add_image_set_directory(seq, directory); if (use_placeholders) { sequencer_image_seq_reserve_frames( |