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 <bastien@blender.org>2022-03-29 12:16:18 +0300
committerBastien Montagne <bastien@blender.org>2022-03-29 12:21:39 +0300
commit31bcab0ecb2d1de74996bf1cc4bdec3eb78540c5 (patch)
tree4ab25f58d2a8f633825abb64c8395e9600d9b948 /source/blender/blenkernel/intern/lib_override.c
parentc772461741462a8c0b83309676a49e41eb0e81cc (diff)
Fix (unreported) LibOverride: re-creation of overrides in consecutive partial overrides of a same hierarchy.
If creating partial hierarchy overrides (from the outliner e.g.), that need to create extra overrides, those could be re-created everytime, leading to very bad situation where there would be several overrides of the same reference ID in the same override hierarchy. This fix makes it so that existing overrides in a given hierarchy will always be re-used in case other overrides are added to the hierarchy.
Diffstat (limited to 'source/blender/blenkernel/intern/lib_override.c')
-rw-r--r--source/blender/blenkernel/intern/lib_override.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index 64ebb08f5d0..cd5855af043 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -322,6 +322,18 @@ ID *BKE_lib_override_library_create_from_id(Main *bmain,
return local_id;
}
+static void lib_override_prefill_newid_from_existing_overrides(Main *bmain, ID *id_hierarchy_root)
+{
+ ID *id_iter;
+ FOREACH_MAIN_ID_BEGIN (bmain, id_iter) {
+ if (ID_IS_OVERRIDE_LIBRARY_REAL(id_iter) &&
+ id_iter->override_library->hierarchy_root == id_hierarchy_root) {
+ id_iter->override_library->reference->newid = id_iter;
+ }
+ }
+ FOREACH_MAIN_ID_END;
+}
+
/* TODO: Make this static local function instead? API is becoming complex, and it's not used
* outside of this file anyway. */
bool BKE_lib_override_library_create_from_tag(Main *bmain,
@@ -345,6 +357,13 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain,
* resync process mainly). */
BLI_assert((ID_IS_OVERRIDE_LIBRARY_REAL(id_hierarchy_root) &&
id_hierarchy_root->override_library->reference->lib == id_root_reference->lib));
+
+ if (!do_no_main) {
+ /* When processing within Main, set existing overrides in given hierarchy as 'newid' of their
+ * linked reference. This allows to re-use existing overrides instead of creating new ones in
+ * partial override cases. */
+ lib_override_prefill_newid_from_existing_overrides(bmain, id_hierarchy_root);
+ }
}
if (!ELEM(id_hierarchy_root_reference, NULL, id_root_reference)) {
/* If the reference hierarchy root is given, it must be from the same library as the reference