Fix T63220: Cannot make object single user after Duplicate Scene with Link Object Data.

Caused by own recent rB17c15798c35f33e (already a fix in that code).

We cannot erase immediately master_collection's childrn list, as it is
used in sub-code to check in how many scenes an object is instanciated.
Further more, we only want to do the remove old/add new children
collections in case we are actually duplicating them.

Makes me even more eager to nuke that whole piece of code and rethink
from scratch that kind of ID handling. Some day...
This commit is contained in:
Bastien Montagne 2019-04-02 21:50:17 +02:00
parent cf7dc769af
commit a813e259d6
Notes: blender-bot 2023-02-14 04:07:50 +01:00
Referenced by issue #63345, changing scene and applying modifiers
Referenced by issue #63292, -texture paint- workspace makes blender crash.
Referenced by issue #63269, Feels like blender is calculating hidden meshes
Referenced by issue #63241, Instant crash upon parenting two separate armatures in the edit mode.
Referenced by issue #63220, Cannot make object single user after Duplicate Scene with Link Object Data
1 changed files with 7 additions and 5 deletions

View File

@ -1627,16 +1627,18 @@ static Collection *single_object_users_collection(
* However, this means its children need to be re-added manually here, otherwise their parent lists are empty
* (which will lead to crashes, see T63101). */
CollectionChild *child_next, *child = collection->children.first;
if (is_master_collection) {
BLI_listbase_clear(&collection->children);
}
for (; child; child = child_next) {
CollectionChild *orig_child_last = collection->children.last;
for (; child != NULL; child = child_next) {
child_next = child->next;
Collection *collection_child_new = single_object_users_collection(
bmain, scene, child->collection, flag, copy_collections, false);
if (is_master_collection) {
if (is_master_collection && copy_collections && child->collection != collection_child_new) {
BKE_collection_child_add(bmain, collection, collection_child_new);
BLI_remlink(&collection->children, child);
MEM_freeN(child);
if (child == orig_child_last) {
break;
}
}
}