diff options
author | Campbell Barton <campbell@blender.org> | 2022-02-15 12:07:54 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-02-15 12:13:00 +0300 |
commit | 07ed869b94fa8acf18d64864c6d8662bfbec33dd (patch) | |
tree | 8ff07b7983bb693c704550104fae0cc3c1a4dfde /source/blender/editors | |
parent | 4637e83990babd208e932e7f7b09a86e1de2e4fd (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')
-rw-r--r-- | source/blender/editors/curve/editcurve_paint.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_add.c | 8 |
3 files changed, 7 insertions, 5 deletions
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index eee806898f6..0d6db8743af 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -577,7 +577,7 @@ static bool curve_draw_init(bContext *C, wmOperator *op, bool is_invoke) /* Using an empty stroke complicates logic later, * it's simplest to disallow early on (see: T94085). */ - if (RNA_collection_length(op->ptr, "stroke") == 0) { + if (RNA_collection_is_empty(op->ptr, "stroke")) { MEM_freeN(cdd); BKE_report(op->reports, RPT_ERROR, "The \"stroke\" cannot be empty"); return false; diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 64ac20123d9..311f3719864 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -186,7 +186,7 @@ static int open_exec(bContext *C, wmOperator *op) MovieClip *clip = NULL; char str[FILE_MAX]; - if (RNA_collection_length(op->ptr, "files")) { + if (!RNA_collection_is_empty(op->ptr, "files")) { PointerRNA fileptr; PropertyRNA *prop; char dir_only[FILE_MAX], file_only[FILE_MAX]; 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); |