From baa55fcf630236980d8dcf0fa0851de5fa22d62a Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 7 Apr 2022 14:51:59 +0200 Subject: Fix T97123: Applying modifier to multi-user: other objects were also converted The first element of the iterator was not being tested against the flag. So in some cases it would lead to more objects been made into single-user than the active (or selected) ones. --- source/blender/blenkernel/intern/collection.c | 29 ++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index c215321bc30..939f7c7b3ff 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -1929,6 +1929,26 @@ void BKE_scene_objects_iterator_begin(BLI_Iterator *iter, void *data_in) scene_objects_iterator_begin(iter, scene, NULL); } +static void scene_objects_iterator_skip_invalid_flag(BLI_Iterator *iter) +{ + if (!iter->valid) { + return; + } + + /* Unpack the data. */ + SceneObjectsIteratorExData *data = iter->data; + iter->data = data->iter_data; + + Object *ob = iter->current; + if (ob && (ob->flag & data->flag) == 0) { + iter->skip = true; + } + + /* Pack the data. */ + data->iter_data = iter->data; + iter->data = data; +} + void BKE_scene_objects_iterator_begin_ex(BLI_Iterator *iter, void *data_in) { SceneObjectsIteratorExData *data = data_in; @@ -1938,6 +1958,8 @@ void BKE_scene_objects_iterator_begin_ex(BLI_Iterator *iter, void *data_in) /* Pack the data. */ data->iter_data = iter->data; iter->data = data_in; + + scene_objects_iterator_skip_invalid_flag(iter); } void BKE_scene_objects_iterator_next_ex(struct BLI_Iterator *iter) @@ -1948,14 +1970,11 @@ void BKE_scene_objects_iterator_next_ex(struct BLI_Iterator *iter) BKE_scene_objects_iterator_next(iter); - Object *ob = iter->current; - if (ob && (ob->flag & data->flag) == 0) { - iter->skip = true; - } - /* Pack the data. */ data->iter_data = iter->data; iter->data = data; + + scene_objects_iterator_skip_invalid_flag(iter); } void BKE_scene_objects_iterator_end_ex(struct BLI_Iterator *iter) -- cgit v1.2.3