[Bf-blender-cvs] [914617f8fd0] master: Fix (unreported) LibOverride: invalid behaviors when creating (partial) overrides.

Bastien Montagne noreply at git.blender.org
Fri Jul 15 14:15:07 CEST 2022


Commit: 914617f8fd01f8e84daf4ae0b8ea750a1bfbdc42
Author: Bastien Montagne
Date:   Fri Jul 15 12:57:37 2022 +0200
Branches: master
https://developer.blender.org/rB914617f8fd01f8e84daf4ae0b8ea750a1bfbdc42

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.

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

M	source/blender/blenkernel/intern/lib_override.cc
M	source/blender/editors/space_outliner/outliner_tools.cc

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

diff --git a/source/blender/blenkernel/intern/lib_override.cc b/source/blender/blenkernel/intern/lib_override.cc
index aa3210b64ad..0c5f59be768 100644
--- a/source/blender/blenkernel/intern/lib_override.cc
+++ b/source/blender/blenkernel/intern/lib_override.cc
@@ -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,
diff --git a/source/blender/editors/space_outliner/outliner_tools.cc b/source/blender/editors/space_outliner/outliner_tools.cc
index 7b7182eb106..9d52103a266 100644
--- a/source/blender/editors/space_outliner/outliner_tools.cc
+++ b/source/blender/editors/space_outliner/outliner_tools.cc
@@ -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 {



More information about the Bf-blender-cvs mailing list