Fix (unreported) LibOverride: invalid behaviors when creating (partial) overrides.

The outliner would tagg all existing local IDs (for remap from linked
reference data to newly created overrides) when creating a new override.
This would become critical issue in case there is several existing
copies of the same override hierarchy (leading to several hierarchies
using the same override).

Further more, BKE override creation code would not systematically
properly remapp linked usages to new overrides one whithin the affected
override hierarchy, leading to potential undesired remaining usages of
linked data.
This commit is contained in:
Bastien Montagne 2022-07-15 12:57:37 +02:00
parent 523bbf7065
commit 914617f8fd
2 changed files with 16 additions and 4 deletions

View File

@ -1149,14 +1149,26 @@ static bool lib_override_library_create_do(Main *bmain,
BKE_main_relations_tag_set(bmain, MAINIDRELATIONS_ENTRY_TAGS_PROCESSED, false);
lib_override_hierarchy_dependencies_recursive_tag(&data);
/* In case the operation is on an already partially overridden hierarchy, all existing overrides
* in that hierarchy need to be tagged for remapping from linked reference ID usages to newly
* created overrides ones. */
if (id_hierarchy_root_reference->lib != id_root_reference->lib) {
BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_hierarchy_root_reference));
BLI_assert(id_hierarchy_root_reference->override_library->reference->lib ==
id_root_reference->lib);
BKE_main_relations_tag_set(bmain, MAINIDRELATIONS_ENTRY_TAGS_PROCESSED, false);
data.hierarchy_root_id = id_hierarchy_root_reference;
data.id_root = id_hierarchy_root_reference;
data.is_override = true;
lib_override_overrides_group_tag(&data);
}
BKE_main_relations_free(bmain);
lib_override_group_tag_data_clear(&data);
bool success = false;
if (id_hierarchy_root_reference->lib != id_root_reference->lib) {
BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_hierarchy_root_reference));
BLI_assert(id_hierarchy_root_reference->override_library->reference->lib ==
id_root_reference->lib);
success = BKE_lib_override_library_create_from_tag(bmain,
owner_library,
id_root_reference,

View File

@ -875,7 +875,7 @@ static void id_override_library_create_fn(bContext *C,
/* For now, remap all local usages of linked ID to local override one here. */
ID *id_iter;
FOREACH_MAIN_ID_BEGIN (bmain, id_iter) {
if (ID_IS_LINKED(id_iter)) {
if (ID_IS_LINKED(id_iter) || ID_IS_OVERRIDE_LIBRARY(id_iter)) {
id_iter->tag &= ~LIB_TAG_DOIT;
}
else {