Fix T82996: Library Overrides: Duplicate of overridden collection on Resync

Properly use given reference pointer in
`lib_override_library_create_post_process` when it is a Collection one
too.
This commit is contained in:
Bastien Montagne 2020-11-30 17:17:43 +01:00
parent a7cf6ad547
commit 3bdc42f97a
Notes: blender-bot 2023-02-14 06:32:27 +01:00
Referenced by issue #84840, Library Override resync issues
Referenced by issue #82996, Library Overrides: Duplicate of overridden collection appears in scene collection on Resync
1 changed files with 8 additions and 0 deletions

View File

@ -551,6 +551,10 @@ static void lib_override_library_create_post_process(
if (ob_reference != NULL) {
BKE_collection_add_from_object(bmain, scene, ob_reference, collection_new);
}
else if (id_reference != NULL) {
BKE_collection_add_from_collection(
bmain, scene, ((Collection *)id_reference), collection_new);
}
else {
BKE_collection_add_from_collection(bmain, scene, ((Collection *)id_root), collection_new);
}
@ -841,6 +845,10 @@ bool BKE_lib_override_library_resync(Main *bmain, Scene *scene, ViewLayer *view_
id_root = id_root_reference->newid;
/* Essentially ensures that potentially new overrides of new objects will be instantiated. */
/* Note: Here 'reference' collection and 'newly added' collection are the same, which is fine
* since we already relinked old root override collection to new resync'ed one above. So this
* call is not expected to instantiate this new resync'ed collection anywhere, just to ensure
* that we do not have any stray objects. */
lib_override_library_create_post_process(bmain, scene, view_layer, id_root_reference, id_root);
/* Cleanup. */