diff options
author | Campbell Barton <campbell@blender.org> | 2022-02-15 12:07:54 +0300 |
---|---|---|
committer | Fabian Schempp <fabianschempp@googlemail.com> | 2022-04-11 01:29:35 +0300 |
commit | fafeb063d7b494f77c6b3397db27f242d4982307 (patch) | |
tree | 06971f9ec849f34485ff1fa7372adec199be94e8 /source/blender/editors/space_sequencer/sequencer_add.c | |
parent | fddaef10cfb6162d4daf7180581f3dbc2be3e8e0 (diff) |
RNA: add RNA_collection_is_empty & RNA_property_collection_is_empty
Some collections needed to be iterated over to count their length.
Provide a function to check if the collection is empty to avoid this.
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_add.c')
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_add.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index f371c663416..e5f267bb9fa 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -747,7 +747,8 @@ static int sequencer_add_movie_strip_invoke(bContext *C, RNA_enum_set(op->ptr, "fit_method", SEQ_tool_settings_fit_method_get(scene)); /* This is for drag and drop. */ - if ((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) || + if ((RNA_struct_property_is_set(op->ptr, "files") && + !RNA_collection_is_empty(op->ptr, "files")) || RNA_struct_property_is_set(op->ptr, "filepath")) { sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_MOVIE); return sequencer_add_movie_strip_exec(C, op); @@ -901,7 +902,8 @@ static int sequencer_add_sound_strip_invoke(bContext *C, const wmEvent *UNUSED(event)) { /* This is for drag and drop. */ - if ((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) || + if ((RNA_struct_property_is_set(op->ptr, "files") && + !RNA_collection_is_empty(op->ptr, "files")) || RNA_struct_property_is_set(op->ptr, "filepath")) { sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_SOUND_RAM); return sequencer_add_sound_strip_exec(C, op); @@ -1094,7 +1096,7 @@ static int sequencer_add_image_strip_invoke(bContext *C, RNA_enum_set(op->ptr, "fit_method", SEQ_tool_settings_fit_method_get(scene)); /* Name set already by drag and drop. */ - if (RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) { + if (RNA_struct_property_is_set(op->ptr, "files") && !RNA_collection_is_empty(op->ptr, "files")) { sequencer_generic_invoke_xy__internal( C, op, SEQPROP_ENDFRAME | SEQPROP_NOPATHS, SEQ_TYPE_IMAGE); return sequencer_add_image_strip_exec(C, op); |