[Bf-blender-cvs] [edb4e553f50] master: LibOverride: Fix issues related to ID name differences.

Bastien Montagne noreply at git.blender.org
Wed Jun 10 09:38:41 CEST 2020


Commit: edb4e553f506c858e7df5e45ad6235cd59a181eb
Author: Bastien Montagne
Date:   Tue Jun 9 19:35:11 2020 +0200
Branches: master
https://developer.blender.org/rBedb4e553f506c858e7df5e45ad6235cd59a181eb

LibOverride: Fix issues related to ID name differences.

Local datablocks (including overrides) need to have a unique name, which
can then differ from the reference linked one (especially when there are
several local overrides of a same linked data).

Issue is, ID name is a 'rna name property', and as such used as
reference when dealing with override of collections of IDs, so we cannot
have a changing name.

The solution implemented here should work and is simple, but it may have
some issues in corner cases (time will say), it is not really robust.

Alternative solution would be to store ID pointers as reference in
override operations, instead of there name. But that would potentially
add quiet a lot of overhead to foreach looping in `lib_query.c`.

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

M	source/blender/blenkernel/intern/lib_override.c
M	source/blender/makesrna/RNA_types.h
M	source/blender/makesrna/intern/rna_ID.c
M	source/blender/makesrna/intern/rna_access_compare_override.c

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

diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index 9426d229e01..8d1a4e3594c 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -937,6 +937,12 @@ void BKE_lib_override_library_update(Main *bmain, ID *local)
     return;
   }
 
+  /* This ID name is problematic, since it is an 'rna name property' it should not be editable or
+   * different from reference linked ID. But local ID names need to be unique in a given type list
+   * of Main, so we cannot always keep it identical, which is why we need this special manual
+   * handling here. */
+  BLI_strncpy(tmp_id->name, local->name, sizeof(tmp_id->name));
+
   PointerRNA rnaptr_src, rnaptr_dst, rnaptr_storage_stack, *rnaptr_storage = NULL;
   RNA_id_pointer_create(local, &rnaptr_src);
   RNA_id_pointer_create(tmp_id, &rnaptr_dst);
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index 2a5d3890150..ee7c045ebf9 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -299,6 +299,18 @@ typedef enum PropertyOverrideFlag {
    */
   PROPOVERRIDE_NO_COMPARISON = (1 << 1),
 
+  /**
+   * Means the property can be fully ignored by override process.
+   * Unlike NO_COMPARISON, it can still be used by diffing code, but no override operation will be
+   * created for it, and no attempt to restore the data from linked reference either.
+   *
+   * WARNING: This flag should be used with a lot of caution, as it completely by-passes override
+   * system. It is currently only used for ID's names, since we cannot prevent local override to
+   * get a different name from the linked reference, and ID names are 'rna name property' (i.e. are
+   * used in overrides of collections of IDs). See also `BKE_lib_override_library_update()` where
+   * we deal manually with the value of that property at DNA level. */
+  PROPOVERRIDE_IGNORE = (1 << 2),
+
   /*** Collections-related ***/
 
   /** The property supports insertion (collections only). */
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 891c30af466..56be654639f 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -1476,6 +1476,7 @@ static void rna_def_ID(BlenderRNA *brna)
   RNA_def_property_string_maxlength(prop, MAX_ID_NAME - 2);
   RNA_def_property_editable_func(prop, "rna_ID_name_editable");
   RNA_def_property_update(prop, NC_ID | NA_RENAME, NULL);
+  RNA_def_property_override_flag(prop, PROPOVERRIDE_IGNORE);
   RNA_def_struct_name_property(srna, prop);
 
   prop = RNA_def_property(srna, "name_full", PROP_STRING, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c
index fbd86d78472..265e83ddcba 100644
--- a/source/blender/makesrna/intern/rna_access_compare_override.c
+++ b/source/blender/makesrna/intern/rna_access_compare_override.c
@@ -636,6 +636,10 @@ bool RNA_struct_override_matches(Main *bmain,
       continue;
     }
 
+    if (RNA_property_override_flag(prop_local) & PROPOVERRIDE_IGNORE) {
+      continue;
+    }
+
 #if 0 /* This actually makes things slower, since it has to check for animation paths etc! */
     if (RNA_property_animated(ptr_local, prop_local)) {
       /* We cannot do anything here really, animation is some kind of dynamic overrides that has



More information about the Bf-blender-cvs mailing list