[Bf-blender-cvs] [ba10cd49220] master: LibOverride: Fix last main issue with overriding custom properties.

Bastien Montagne noreply at git.blender.org
Fri Oct 4 12:27:22 CEST 2019


Commit: ba10cd49220a778014fa2e77eff45c32ca106fbe
Author: Bastien Montagne
Date:   Thu Oct 3 20:29:38 2019 +0200
Branches: master
https://developer.blender.org/rBba10cd49220a778014fa2e77eff45c32ca106fbe

LibOverride: Fix last main issue with overriding custom properties.

Now, custom props defined as overriddable can be overridden, saved,
reloaded, etc. That fixes the last main issue with them.

Note that custom props still have a lot of glitches and weirdness in
their overriding behavior, but for now the most important is finally
achieved, will let them rest and settle a bit, those have been
incredibly painful to tame... :(

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

M	source/blender/makesrna/intern/rna_access.c
M	source/blender/makesrna/intern/rna_access_compare_override.c
M	source/blender/makesrna/intern/rna_access_internal.h

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

diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 71a3be24810..aeb6d528cdb 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -393,7 +393,7 @@ bool RNA_struct_idprops_check(StructRNA *srna)
   return (srna && srna->idproperties);
 }
 
-static IDProperty *rna_idproperty_find(PointerRNA *ptr, const char *name)
+IDProperty *rna_idproperty_find(PointerRNA *ptr, const char *name)
 {
   IDProperty *group = RNA_struct_idprops(ptr, 0);
 
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c
index df1554ac7bc..18fbe7886e9 100644
--- a/source/blender/makesrna/intern/rna_access_compare_override.c
+++ b/source/blender/makesrna/intern/rna_access_compare_override.c
@@ -625,6 +625,21 @@ bool RNA_struct_override_matches(Main *bmain,
     prop_local = rna_ensure_property_realdata(&prop_local, ptr_local);
     prop_reference = rna_ensure_property_realdata(&prop_reference, ptr_reference);
 
+    /* IDProps (custom properties) are even more of a PITA here, we cannot use
+     * `rna_ensure_property_realdata()` to deal with them, we have to use the path generated from
+     * `prop_local` (which is valid) to access to the actual reference counterpart... */
+    if (prop_local != NULL && prop_local->magic != RNA_MAGIC && prop_local == prop_reference) {
+      /* We could also use (lower in this code, after rna_path has been computed):
+       *    RNA_path_resolve_property(ptr_reference, rna_path, &some_rna_ptr, &prop_reference);
+       * But that would be much more costly, and would also fail when ptr_reference
+       * is not an ID pointer itself, so we'd need to rebuild it from its owner_id, then check that
+       * generated some_rna_ptr and ptr_reference do point to the same data, etc.
+       * For now, let's try that simple access, it won't cover all cases but should handle fine
+       * most basic custom properties situations. */
+      prop_reference = (PropertyRNA *)rna_idproperty_find(ptr_reference,
+                                                          ((IDProperty *)prop_local)->name);
+    }
+
     if (ELEM(NULL, prop_local, prop_reference)) {
       continue;
     }
diff --git a/source/blender/makesrna/intern/rna_access_internal.h b/source/blender/makesrna/intern/rna_access_internal.h
index 28ec504e376..c7995746d08 100644
--- a/source/blender/makesrna/intern/rna_access_internal.h
+++ b/source/blender/makesrna/intern/rna_access_internal.h
@@ -30,5 +30,6 @@ struct IDProperty;
 PropertyRNA *rna_ensure_property(PropertyRNA *prop);
 
 void rna_idproperty_touch(struct IDProperty *idprop);
+struct IDProperty *rna_idproperty_find(PointerRNA *ptr, const char *name);
 
 #endif /* __ACCESS_RNA_INTERNAL_H__ */



More information about the Bf-blender-cvs mailing list