[Bf-blender-cvs] [a813e259d63] master: Fix T63220: Cannot make object single user after Duplicate Scene with Link Object Data.

Bastien Montagne noreply at git.blender.org
Tue Apr 2 21:54:01 CEST 2019


Commit: a813e259d6309b25fbd0a6d506df810ad2b11395
Author: Bastien Montagne
Date:   Tue Apr 2 21:50:17 2019 +0200
Branches: master
https://developer.blender.org/rBa813e259d6309b25fbd0a6d506df810ad2b11395

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...

===================================================================

M	source/blender/editors/object/object_relations.c

===================================================================

diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index ec6c1059ed3..d069772a0ce 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -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;
+			}
 		}
 	}



More information about the Bf-blender-cvs mailing list