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`).
This commit is contained in:
parent
9954cbfca6
commit
ac723db57f
Notes:
blender-bot
2023-02-14 00:10:09 +01:00
Referenced by commit6744f4d108
, Cleanup of previous rBac723db57fd8ba5 commit. Referenced by commitfb0fc1d613
, Fix T73170: New Scene -> "Full Copy" Crashes Blender. Referenced by issue #73170, New Scene -> "Full Copy" Crashes Blender Referenced by issue #71798, Full Copy Scene produce Orphan Data objects
|
@ -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. */
|
||||
|
|
Loading…
Reference in New Issue