[Bf-blender-cvs] [34fb3a19dff] refactor-idprop-ui-data: Merge branch 'master' into refactor-idprop-ui-data

Hans Goudey noreply at git.blender.org
Wed Jul 14 17:21:57 CEST 2021


Commit: 34fb3a19dffd325a615f09b9ad8e66aa8caf0f33
Author: Hans Goudey
Date:   Wed Jul 14 10:58:39 2021 -0400
Branches: refactor-idprop-ui-data
https://developer.blender.org/rB34fb3a19dffd325a615f09b9ad8e66aa8caf0f33

Merge branch 'master' into refactor-idprop-ui-data

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



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

diff --cc source/blender/blenloader/intern/versioning_300.c
index 236b757fe98,3c58c29c162..3bbf93628e1
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@@ -41,8 -37,8 +41,9 @@@
  #include "BKE_action.h"
  #include "BKE_animsys.h"
  #include "BKE_collection.h"
+ #include "BKE_deform.h"
  #include "BKE_fcurve_driver.h"
 +#include "BKE_idprop.h"
  #include "BKE_lib_id.h"
  #include "BKE_main.h"
  #include "BKE_node.h"
diff --cc source/blender/makesrna/intern/rna_access.c
index 50ddf0478e5,eb347987f87..ab5949138b6
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@@ -245,15 -245,156 +245,32 @@@ void rna_idproperty_touch(IDProperty *i
    idprop->flag &= ~IDP_FLAG_GHOST;
  }
  
- IDProperty *RNA_struct_idprops(PointerRNA *ptr, bool create)
 -static IDProperty *rna_idproperty_ui_container(PropertyRNA *prop)
 -{
 -  IDProperty *idprop;
 -
 -  for (idprop = ((IDProperty *)prop)->prev; idprop; idprop = idprop->prev) {
 -    if (STREQ(RNA_IDP_UI, idprop->name)) {
 -      break;
 -    }
 -  }
 -
 -  if (idprop == NULL) {
 -    for (idprop = ((IDProperty *)prop)->next; idprop; idprop = idprop->next) {
 -      if (STREQ(RNA_IDP_UI, idprop->name)) {
 -        break;
 -      }
 -    }
 -  }
 -
 -  return idprop;
 -}
 -
 -/* return a UI local ID prop definition for this prop */
 -static const IDProperty *rna_idproperty_ui(const PropertyRNA *prop)
 -{
 -  IDProperty *idprop = rna_idproperty_ui_container((PropertyRNA *)prop);
 -
 -  if (idprop) {
 -    return IDP_GetPropertyTypeFromGroup(idprop, ((IDProperty *)prop)->name, IDP_GROUP);
 -  }
 -
 -  return NULL;
 -}
 -
 -/* return or create a UI local ID prop definition for this prop */
 -static IDProperty *rna_idproperty_ui_ensure(PointerRNA *ptr, PropertyRNA *prop, bool create)
 -{
 -  IDProperty *idprop = rna_idproperty_ui_container(prop);
 -  IDPropertyTemplate dummy = {0};
 -
 -  if (idprop == NULL && create) {
 -    IDProperty *props = RNA_struct_idprops(ptr, false);
 -
 -    /* Sanity check: props is the actual container of this property. */
 -    if (props != NULL && BLI_findindex(&props->data.group, prop) >= 0) {
 -      idprop = IDP_New(IDP_GROUP, &dummy, RNA_IDP_UI);
 -
 -      if (!IDP_AddToGroup(props, idprop)) {
 -        IDP_FreePropertyContent(idprop);
 -        return NULL;
 -      }
 -    }
 -  }
 -
 -  if (idprop) {
 -    const char *name = ((IDProperty *)prop)->name;
 -    IDProperty *rv = IDP_GetPropertyTypeFromGroup(idprop, name, IDP_GROUP);
 -
 -    if (rv == NULL && create) {
 -      rv = IDP_New(IDP_GROUP, &dummy, name);
 -
 -      if (!IDP_AddToGroup(idprop, rv)) {
 -        IDP_FreePropertyContent(rv);
 -        return NULL;
 -      }
 -    }
 -
 -    return rv;
 -  }
 -
 -  return NULL;
 -}
 -
 -static bool rna_idproperty_ui_set_default(PointerRNA *ptr,
 -                                          PropertyRNA *prop,
 -                                          const char type,
 -                                          IDPropertyTemplate *value)
 -{
 -  BLI_assert(ELEM(type, IDP_INT, IDP_DOUBLE));
 -
 -  if (prop->magic == RNA_MAGIC) {
 -    return false;
 -  }
 -
 -  /* attempt to get the local ID values */
 -  IDProperty *idp_ui = rna_idproperty_ui_ensure(ptr, prop, value != NULL);
 -
 -  if (idp_ui == NULL) {
 -    return (value == NULL);
 -  }
 -
 -  IDProperty *item = IDP_GetPropertyTypeFromGroup(idp_ui, "default", type);
 -
 -  if (value == NULL) {
 -    if (item != NULL) {
 -      IDP_RemoveFromGroup(idp_ui, item);
 -    }
 -  }
 -  else {
 -    if (item != NULL) {
 -      switch (type) {
 -        case IDP_INT:
 -          IDP_Int(item) = value->i;
 -          break;
 -        case IDP_DOUBLE:
 -          IDP_Double(item) = value->d;
 -          break;
 -        default:
 -          BLI_assert(false);
 -          return false;
 -      }
 -    }
 -    else {
 -      item = IDP_New(type, value, "default");
 -
 -      if (!IDP_AddToGroup(idp_ui, item)) {
 -        IDP_FreePropertyContent(item);
 -        return false;
 -      }
 -    }
 -  }
 -
 -  return true;
 -}
 -
+ IDProperty **RNA_struct_idprops_p(PointerRNA *ptr)
  {
    StructRNA *type = ptr->type;
+   if (type == NULL) {
+     return NULL;
+   }
+   if (type->idproperties == NULL) {
+     return NULL;
+   }
  
-   if (type && type->idproperties) {
-     return type->idproperties(ptr, create);
+   return type->idproperties(ptr);
+ }
+ 
+ IDProperty *RNA_struct_idprops(PointerRNA *ptr, bool create)
+ {
+   IDProperty **property_ptr = RNA_struct_idprops_p(ptr);
+   if (property_ptr == NULL) {
+     return NULL;
    }
  
-   return NULL;
+   if (create && *property_ptr == NULL) {
+     IDPropertyTemplate val = {0};
+     *property_ptr = IDP_New(IDP_GROUP, &val, __func__);
+   }
+ 
+   return *property_ptr;
  }
  
  bool RNA_struct_idprops_check(StructRNA *srna)



More information about the Bf-blender-cvs mailing list