[Bf-blender-cvs] [1201352217a] master: LibOverride: Fix several issues in handling of overridable status for IDProps.

Bastien Montagne noreply at git.blender.org
Wed Sep 25 14:28:12 CEST 2019


Commit: 1201352217a8cd3072eea3a1109a8a19915be14d
Author: Bastien Montagne
Date:   Tue Sep 24 17:21:21 2019 +0200
Branches: master
https://developer.blender.org/rB1201352217a8cd3072eea3a1109a8a19915be14d

LibOverride: Fix several issues in handling of overridable status for IDProps.

The triple possible status of an PropertyRNA (actual C-defined prop,
py-defined IDprop behaving similar ot RNA one, or actual 'pure' custom
prop) is really confusing... Not to mention the _RNA_UI ugly thingy on
top of that. :/

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

M	source/blender/makesrna/intern/rna_access.c
M	source/blender/makesrna/intern/rna_access_compare_override.c
M	source/blender/makesrna/intern/rna_rna.c

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

diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 6e98b5f4727..f412930f603 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -2081,15 +2081,15 @@ bool RNA_property_editable_info(PointerRNA *ptr, PropertyRNA *prop, const char *
   ID *id = ptr->owner_id;
   int flag;
 
-  prop = rna_ensure_property(prop);
+  PropertyRNA *prop_type = rna_ensure_property(prop);
   *r_info = "";
 
   /* get flag */
-  if (prop->editable) {
-    flag = prop->editable(ptr, r_info);
+  if (prop_type->editable) {
+    flag = prop_type->editable(ptr, r_info);
   }
   else {
-    flag = prop->flag;
+    flag = prop_type->flag;
     if ((flag & PROP_EDITABLE) == 0 || (flag & PROP_REGISTER)) {
       *r_info = N_("This property is for internal use only and can't be edited");
     }
@@ -2097,17 +2097,21 @@ bool RNA_property_editable_info(PointerRNA *ptr, PropertyRNA *prop, const char *
 
   /* property from linked data-block */
   if (id) {
-    if (ID_IS_LINKED(id) && (prop->flag & PROP_LIB_EXCEPTION) == 0) {
+    if (ID_IS_LINKED(id) && (prop_type->flag & PROP_LIB_EXCEPTION) == 0) {
       if (!(*r_info)[0]) {
         *r_info = N_("Can't edit this property from a linked data-block");
       }
       return false;
     }
-    if (id->override_library != NULL && !RNA_property_overridable_get(ptr, prop)) {
-      if (!(*r_info)[0]) {
-        *r_info = N_("Can't edit this property from an override data-block");
+    if (id->override_library != NULL) {
+      /* We need the real data property in case of IDProperty here... */
+      PropertyRNA *real_prop = rna_ensure_property_realdata(&prop, ptr);
+      if (real_prop == NULL || !RNA_property_overridable_get(ptr, real_prop)) {
+        if (!(*r_info)[0]) {
+          *r_info = N_("Can't edit this property from an override data-block");
+        }
+        return false;
       }
-      return false;
     }
   }
 
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c
index b0a83ea38c6..b061c72157e 100644
--- a/source/blender/makesrna/intern/rna_access_compare_override.c
+++ b/source/blender/makesrna/intern/rna_access_compare_override.c
@@ -76,8 +76,8 @@ bool RNA_property_overridable_get(PointerRNA *ptr, PropertyRNA *prop)
   }
   else {
     /* If this is a real 'pure' IDProp (aka custom property), we want to use the IDProp flag. */
-    return !(prop->flag_override & PROPOVERRIDE_NO_COMPARISON) &&
-           (((IDProperty *)prop)->flag & IDP_FLAG_OVERRIDABLE_LIBRARY);
+    IDProperty *idprop = (IDProperty *)prop;
+    return (idprop->flag & IDP_FLAG_OVERRIDABLE_LIBRARY) != 0;
   }
 }
 
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index 6e21d02c0b3..26c8df4c7bb 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -613,7 +613,10 @@ static bool rna_Property_overridable_get(PointerRNA *ptr)
 {
   PropertyRNA *prop = (PropertyRNA *)ptr->data;
 
-  return (prop->flag_override & PROPOVERRIDE_OVERRIDABLE_LIBRARY) != 0;
+  IDProperty *idprop = rna_idproperty_check(&prop, ptr);
+
+  return idprop != NULL ? (idprop->flag & IDP_FLAG_OVERRIDABLE_LIBRARY) != 0 :
+                          (prop->flag_override & PROPOVERRIDE_OVERRIDABLE_LIBRARY) != 0;
 }
 
 static bool rna_Property_use_output_get(PointerRNA *ptr)



More information about the Bf-blender-cvs mailing list