[Bf-blender-cvs] [28f4e5cd6bc] master: RNA: Add a way to prevent automatic addition of 'no ownership' flag for ID pointer properties.

Bastien Montagne noreply at git.blender.org
Mon Jun 29 17:28:09 CEST 2020


Commit: 28f4e5cd6bc718d91d0f637c89bce4ce68671b71
Author: Bastien Montagne
Date:   Fri Jun 26 18:08:12 2020 +0200
Branches: master
https://developer.blender.org/rB28f4e5cd6bc718d91d0f637c89bce4ce68671b71

RNA: Add a way to prevent automatic addition of 'no ownership' flag for ID pointer properties.

Since makesrna runs after all properties have been defined, we have to
remember with a new internal flag when we explicitely disable the
'PROP_PTR_NO_OWNERSHIP' flag for a property.

Otherwise there was no way to do so for ID pointer properties...

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

M	source/blender/makesrna/intern/makesrna.c
M	source/blender/makesrna/intern/rna_define.c
M	source/blender/makesrna/intern/rna_internal_types.h

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

diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 6256fd47ade..59087df16dd 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -3770,7 +3770,8 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
       /* XXX This systematically enforces that flag on ID pointers...
        * we'll probably have to revisit. :/ */
       StructRNA *type = rna_find_struct((const char *)pprop->type);
-      if (type && (type->flag & STRUCT_ID)) {
+      if (type && (type->flag & STRUCT_ID) &&
+          !(prop->flag_internal & PROP_INTERN_PTR_OWNERSHIP_FORCED)) {
         prop->flag |= PROP_PTR_NO_OWNERSHIP;
       }
       break;
@@ -3781,7 +3782,8 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
       /* XXX This systematically enforces that flag on ID pointers...
        * we'll probably have to revisit. :/ */
       StructRNA *type = rna_find_struct((const char *)cprop->item_type);
-      if (type && (type->flag & STRUCT_ID)) {
+      if (type && (type->flag & STRUCT_ID) &&
+          !(prop->flag_internal & PROP_INTERN_PTR_OWNERSHIP_FORCED)) {
         prop->flag |= PROP_PTR_NO_OWNERSHIP;
       }
       break;
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 7919c014bb2..bb791dd6e2d 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -1515,6 +1515,9 @@ void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
 void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
 {
   prop->flag &= ~flag;
+  if (flag & PROP_PTR_NO_OWNERSHIP) {
+    prop->flag_internal |= PROP_INTERN_PTR_OWNERSHIP_FORCED;
+  }
 }
 
 void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h
index bc83ed25ce5..345d84fc5b1 100644
--- a/source/blender/makesrna/intern/rna_internal_types.h
+++ b/source/blender/makesrna/intern/rna_internal_types.h
@@ -329,6 +329,9 @@ typedef enum PropertyFlagIntern {
   PROP_INTERN_RAW_ACCESS = (1 << 2),
   PROP_INTERN_RAW_ARRAY = (1 << 3),
   PROP_INTERN_FREE_POINTERS = (1 << 4),
+  /* Negative mirror of PROP_PTR_NO_OWNERSHIP, used to prevent automatically setting that one in
+   * makesrna when pointer is an ID... */
+  PROP_INTERN_PTR_OWNERSHIP_FORCED = (1 << 5),
 } PropertyFlagIntern;
 
 /* Property Types */



More information about the Bf-blender-cvs mailing list