Introduce "skip" in BLI_Iterator struct

This helps iterators prevent recursion.
This commit is contained in:
Dalai Felinto 2017-10-30 19:34:46 -02:00
parent 7aabe3f66c
commit 16f06e9dc9
Notes: blender-bot 2023-09-13 08:48:34 +02:00
Referenced by issue #53215, Report crash and bugs on Blender v2.80.1 16f06e9
1 changed files with 10 additions and 3 deletions

View File

@ -30,6 +30,7 @@
typedef struct BLI_Iterator {
void *current; /* current pointer we iterate over */
void *data; /* stored data required for this iterator */
bool skip;
bool valid;
} BLI_Iterator;
@ -40,12 +41,18 @@ typedef void (*IteratorBeginCb)(BLI_Iterator *iter, void *data_in);
{ \
_type _instance; \
IteratorCb callback_end_func = callback_end; \
BLI_Iterator iter_macro; \
BLI_Iterator iter_macro = { \
.skip = false, \
}; \
for (callback_begin(&iter_macro, (_data_in)); \
iter_macro.valid; \
callback_next(&iter_macro)) \
{ \
_instance = (_type ) iter_macro.current;
{ \
if (iter_macro.skip) { \
iter_macro.skip = false; \
continue; \
} \
_instance = (_type ) iter_macro.current;
#define ITER_END \
} \