diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-11-07 19:06:55 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-11-07 19:08:34 +0300 |
commit | 1b18e158025a488e1ba2446ad93c2eb563c11611 (patch) | |
tree | 9fa432d1bd7e622cb0d7cd4a9160bdff7d30c554 /source/blender/blenkernel | |
parent | fc789803cabc9dfd47319a7f0297456c8f60153c (diff) |
Sanitize use of BLI_iterator
We now initialize iter.valid as true as part of the main iterator (and manually
when using via Python). And we don't even bother setting iter->current to NULL
if it's invalid. Let's stick to using iter->valid only.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/collection.c | 9 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/layer.c | 4 |
2 files changed, 4 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index 2b69c176c39..2a1157cf6b4 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -535,7 +535,6 @@ void BKE_scene_collections_iterator_begin(BLI_Iterator *iter, void *data_in) data->cur = 0; iter->current = data->array[data->cur]; - iter->valid = true; } void BKE_scene_collections_iterator_next(struct BLI_Iterator *iter) @@ -585,10 +584,10 @@ void BKE_scene_objects_iterator_begin(BLI_Iterator *iter, void *data_in) BKE_scene_collections_iterator_begin(&data->scene_collection_iter, scene); SceneCollection *sc = data->scene_collection_iter.current; - iter->current = sc->objects.first ? ((LinkData *)sc->objects.first)->data : NULL; - iter->valid = true; - - if (iter->current == NULL) { + if (sc->objects.first != NULL) { + iter->current = ((LinkData *)sc->objects.first)->data; + } + else { BKE_scene_objects_iterator_next(iter); } } diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index 2e1495b2e11..3544cf02afb 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -1674,7 +1674,6 @@ static void object_bases_iterator_begin(BLI_Iterator *iter, void *data_in, const return; } - iter->valid = true; iter->data = base; if ((base->flag & flag) == 0) { @@ -1698,7 +1697,6 @@ static void object_bases_iterator_next(BLI_Iterator *iter, const int flag) base = base->next; } - iter->current = NULL; iter->valid = false; } @@ -1800,7 +1798,6 @@ void BKE_renderable_objects_iterator_begin(BLI_Iterator *iter, void *data_in) data->iter.set = NULL; - iter->valid = true; iter->data = data_in; BKE_renderable_objects_iterator_next(iter); } @@ -1855,7 +1852,6 @@ void BKE_renderable_objects_iterator_next(BLI_Iterator *iter) return; } - iter->current = NULL; iter->valid = false; } |