[Bf-blender-cvs] [f449b896881] master: Cleanup: Make `RNA_property_editable` logic clearer.
Bastien Montagne
noreply at git.blender.org
Tue Feb 22 15:27:01 CET 2022
Commit: f449b8968819da3669a5a8a87ac0f5822b785a15
Author: Bastien Montagne
Date: Tue Feb 22 15:18:08 2022 +0100
Branches: master
https://developer.blender.org/rBf449b8968819da3669a5a8a87ac0f5822b785a15
Cleanup: Make `RNA_property_editable` logic clearer.
Split code in smaller bits with early returns, instead of a giant single
set of checks.
No behavioral change expected here.
===================================================================
M source/blender/makesrna/intern/rna_access.c
===================================================================
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 6c3b46c4408..5a43fc2b053 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -1907,10 +1907,27 @@ bool RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop_orig)
PropertyRNA *prop = rna_ensure_property(prop_orig);
flag = prop->editable ? prop->editable(ptr, &dummy_info) : prop->flag;
- return (
- (flag & PROP_EDITABLE) && (flag & PROP_REGISTER) == 0 &&
- (!id || ((!ID_IS_LINKED(id) || (prop->flag & PROP_LIB_EXCEPTION)) &&
- (!ID_IS_OVERRIDE_LIBRARY(id) || RNA_property_overridable_get(ptr, prop_orig)))));
+ /* Early return if the property itself is not editable. */
+ if ((flag & PROP_EDITABLE) == 0 || (flag & PROP_REGISTER) != 0) {
+ return false;
+ }
+
+ /* If there is no owning ID, the property is editable at this point. */
+ if (id == NULL) {
+ return true;
+ }
+
+ /* Handle linked or liboverride ID cases. */
+ const bool is_linked_prop_exception = (prop->flag & PROP_LIB_EXCEPTION) != 0;
+ if (ID_IS_LINKED(id)) {
+ return is_linked_prop_exception;
+ }
+ if (ID_IS_OVERRIDE_LIBRARY(id)) {
+ return RNA_property_overridable_get(ptr, prop_orig);
+ }
+
+ /* At this point, property is owned by a local ID and therefore fully editable. */
+ return true;
}
bool RNA_property_editable_info(PointerRNA *ptr, PropertyRNA *prop, const char **r_info)
More information about the Bf-blender-cvs
mailing list