Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2020-01-14 14:07:24 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2020-01-14 14:07:24 +0300
commitac723db57fd8ba5493088b135ef7c910be4ca2ff (patch)
treecdfd1ddbaff13a7d6a402431292a15cfed00b33d
parent9954cbfca6df738341f67ada2bf5cb55f897549d (diff)
Fix T71798: Full Copy Scene produce Orphan Data objects.
Never treat one of those horrorible 'IDs that are not real IDs' as regular ID, and expect ID management code to do so. Unless there is a very good reason, one should never explicitely pass those fake IDs to ID management code directly. In that specific case, user count is sort of 'disabled' in libquery code, because master collections are not in bmain (`LIB_TAG_NO_MAIN`).
-rw-r--r--source/blender/editors/object/object_relations.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index c030c551374..06d5bd8beb4 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -1706,19 +1706,29 @@ void OBJECT_OT_make_links_data(wmOperatorType *ot)
/**************************** Make Single User ********************************/
-static void libblock_relink_collection(Collection *collection)
+static void libblock_relink_collection(Collection *collection, const bool do_collection)
{
- BKE_libblock_relink_to_newid(&collection->id);
+ if (do_collection) {
+ BKE_libblock_relink_to_newid(&collection->id);
+ }
for (CollectionObject *cob = collection->gobject.first; cob != NULL; cob = cob->next) {
BKE_libblock_relink_to_newid(&cob->ob->id);
}
for (CollectionChild *child = collection->children.first; child; child = child->next) {
- libblock_relink_collection(child->collection);
+ libblock_relink_collection(child->collection, true);
}
}
+static void libblock_relink_collections_from_scene(Scene *scene)
+{
+ /* Will also handle the master collection. */
+ BKE_libblock_relink_to_newid(&scene->id);
+
+ libblock_relink_collection(scene->master_collection, false);
+}
+
static Collection *single_object_users_collection(Main *bmain,
Scene *scene,
Collection *collection,
@@ -1807,7 +1817,7 @@ static void single_object_users(
#endif
/* Collection and object pointers in collections */
- libblock_relink_collection(master_collection);
+ libblock_relink_collections_from_scene(scene);
/* collection pointers in scene */
BKE_scene_groups_relink(scene);
@@ -2056,7 +2066,7 @@ void ED_object_single_users(Main *bmain,
* rewritten at some point to make use of proper modern ID management code,
* but that is no small task.
* For now we are doomed to that kind of band-aid to try to cover most of remapping cases. */
- libblock_relink_collection(scene->master_collection);
+ libblock_relink_collections_from_scene(scene);
}
/* Relink nodetrees' pointers that have been duplicated. */