[Bf-blender-cvs] [8d20d6b2eb4] master: RNA: add fallback update function

Campbell Barton noreply at git.blender.org
Wed May 22 16:36:12 CEST 2019


Commit: 8d20d6b2eb40c5a54863e33784eabb3fb6c8d012
Author: Campbell Barton
Date:   Thu May 23 00:29:31 2019 +1000
Branches: master
https://developer.blender.org/rB8d20d6b2eb40c5a54863e33784eabb3fb6c8d012

RNA: add fallback update function

Use so we can have a default update function,
that doesn't need to be set for every property.

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

M	source/blender/makesrna/RNA_define.h
M	source/blender/makesrna/intern/rna_define.c
M	source/blender/makesrna/intern/rna_internal.h

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

diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h
index 59c03cf34b3..0beb14614ec 100644
--- a/source/blender/makesrna/RNA_define.h
+++ b/source/blender/makesrna/RNA_define.h
@@ -48,6 +48,7 @@ void RNA_define_free(BlenderRNA *brna);
 void RNA_free(BlenderRNA *brna);
 void RNA_define_verify_sdna(bool verify);
 void RNA_define_animate_sdna(bool animate);
+void RNA_define_fallback_property_update(int noteflag, const char *updatefunc);
 
 void RNA_init(void);
 void RNA_exit(void);
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 8e24e9a8364..b1818cae62a 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -709,6 +709,14 @@ void RNA_define_animate_sdna(bool animate)
 }
 #endif
 
+#ifndef RNA_RUNTIME
+void RNA_define_fallback_property_update(int noteflag, const char *updatefunc)
+{
+  DefRNA.fallback.property_update.noteflag = noteflag;
+  DefRNA.fallback.property_update.updatefunc = updatefunc;
+}
+#endif
+
 void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *ext)
 {
 #ifdef RNA_RUNTIME
@@ -1413,6 +1421,12 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_,
   }
   /* TODO: do we want that for runtime-defined stuff too? I’d say no, but... maybe yes :/ */
 
+#ifndef RNA_RUNTIME
+  /* Both are typically cleared. */
+  RNA_def_property_update(
+      prop, DefRNA.fallback.property_update.noteflag, DefRNA.fallback.property_update.updatefunc);
+#endif
+
   rna_addtail(&cont->properties, prop);
 
   return prop;
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 16125399b2d..0ced20d4d42 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -116,6 +116,16 @@ typedef struct BlenderDefRNA {
   ListBase allocs;
   struct StructRNA *laststruct;
   int error, silent, preprocess, verify, animate;
+  /* Keep last. */
+#ifndef RNA_RUNTIME
+  struct {
+    /** #RNA_def_property_update */
+    struct {
+      int noteflag;
+      const char *updatefunc;
+    } property_update;
+  } fallback;
+#endif
 } BlenderDefRNA;
 
 extern BlenderDefRNA DefRNA;



More information about the Bf-blender-cvs mailing list