[Bf-blender-cvs] [59aa8d22efa] blender2.8: Cleanup: use flags instead of collection of bools to get RNA override status.

Bastien Montagne noreply at git.blender.org
Wed Mar 14 11:48:14 CET 2018


Commit: 59aa8d22efa2c7a1dff23211a1f63e2d5bdd0783
Author: Bastien Montagne
Date:   Wed Mar 14 11:47:35 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB59aa8d22efa2c7a1dff23211a1f63e2d5bdd0783

Cleanup: use flags instead of collection of bools to get RNA override status.

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

M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_ops.c
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_access.c

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

diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index a4eaf800801..d6385276b1a 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1221,11 +1221,9 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
 
 void ui_but_override_flag(uiBut *but)
 {
-	bool is_overridden;
+	const int override_status = RNA_property_override_status(&but->rnapoin, but->rnaprop, but->rnaindex);
 
-	RNA_property_override_status(&but->rnapoin, but->rnaprop, but->rnaindex, NULL, &is_overridden, NULL, NULL);
-
-	if (is_overridden) {
+	if (override_status & RNA_OVERRIDE_STATUS_OVERRIDDEN) {
 		but->flag |= UI_BUT_OVERRIDEN;
 	}
 	else {
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 3a01ff16297..b1dc30945c4 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -6819,11 +6819,11 @@ static bool ui_but_menu(bContext *C, uiBut *but)
 		const PropertySubType subtype = RNA_property_subtype(prop);
 		bool is_anim = RNA_property_animateable(ptr, prop);
 		bool is_editable = RNA_property_editable(ptr, prop);
-		bool is_overridable;
 		/*bool is_idprop = RNA_property_is_idprop(prop);*/ /* XXX does not work as expected, not strictly needed */
 		bool is_set = RNA_property_is_set(ptr, prop);
 
-		RNA_property_override_status(ptr, prop, -1, &is_overridable, NULL, NULL, NULL);
+		const int override_status = RNA_property_override_status(ptr, prop, -1);
+		const bool is_overridable = (override_status & RNA_OVERRIDE_STATUS_OVERRIDABLE) != 0;
 
 		/* second slower test, saved people finding keyframe items in menus when its not possible */
 		if (is_anim)
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 16525dfbc9e..ad4aaf59998 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -482,13 +482,12 @@ static int override_type_set_button_poll(bContext *C)
 	PointerRNA ptr;
 	PropertyRNA *prop;
 	int index;
-	bool is_overridable;
 
 	UI_context_active_but_prop_get(C, &ptr, &prop, &index);
 
-	RNA_property_override_status(&ptr, prop, index, &is_overridable, NULL, NULL, NULL);
+	const int override_status = RNA_property_override_status(&ptr, prop, index);
 
-	return (ptr.data && prop && is_overridable);
+	return (ptr.data && prop && (override_status & RNA_OVERRIDE_STATUS_OVERRIDABLE));
 }
 
 static int override_type_set_button_exec(bContext *C, wmOperator *op)
@@ -572,13 +571,12 @@ static int override_remove_button_poll(bContext *C)
 	PointerRNA ptr;
 	PropertyRNA *prop;
 	int index;
-	bool is_overridden;
 
 	UI_context_active_but_prop_get(C, &ptr, &prop, &index);
 
-	RNA_property_override_status(&ptr, prop, index, NULL, &is_overridden, NULL, NULL);
+	const int override_status = RNA_property_override_status(&ptr, prop, index);
 
-	return (ptr.data && ptr.id.data && prop && is_overridden);
+	return (ptr.data && ptr.id.data && prop && (override_status & RNA_OVERRIDE_STATUS_OVERRIDDEN));
 }
 
 static int override_remove_button_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 5e3cbeaa057..33f222b9755 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -1278,6 +1278,13 @@ typedef enum eRNAOverrideMatchResult {
 	RNA_OVERRIDE_MATCH_RESULT_RESTORED = 1 << 1,
 } eRNAOverrideMatchResult;
 
+typedef enum eRNAOverrideStatus {
+	RNA_OVERRIDE_STATUS_OVERRIDABLE = 1 << 0,  /* The property is overridable. */
+	RNA_OVERRIDE_STATUS_OVERRIDDEN = 1 << 1,  /* The property is overridden. */
+	RNA_OVERRIDE_STATUS_MANDATORY = 1 << 2,  /* Overriding this property is mandatory when creating an override. */
+	RNA_OVERRIDE_STATUS_LOCKED = 1 << 3,  /* The override status of this property is locked. */
+} eRNAOverrideStatus;
+
 bool RNA_struct_override_matches(
         struct PointerRNA *ptr_local, struct PointerRNA *ptr_reference, const char *root_path,
         struct IDOverrideStatic *override, const eRNAOverrideMatch flags,
@@ -1300,9 +1307,7 @@ struct IDOverrideStaticPropertyOperation *RNA_property_override_property_operati
         PointerRNA *ptr, PropertyRNA *prop, const short operation, const int index,
         const bool strict, bool *r_strict, bool *r_created);
 
-void RNA_property_override_status(
-        PointerRNA *ptr, PropertyRNA *prop, const int index,
-        bool *r_overridable, bool *r_overridden, bool *r_mandatory, bool *r_locked);
+int RNA_property_override_status(PointerRNA *ptr, PropertyRNA *prop, const int index);
 
 void        RNA_struct_state_owner_set(const char *name);
 const char *RNA_struct_state_owner_get(void);
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 0f47a461cda..ab293af6212 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -7678,29 +7678,30 @@ IDOverrideStaticPropertyOperation *RNA_property_override_property_operation_get(
 	return BKE_override_static_property_operation_get(op, operation, NULL, NULL, index, index, strict, r_strict, r_created);
 }
 
-void RNA_property_override_status(
-        PointerRNA *ptr, PropertyRNA *prop, const int index,
-        bool *r_overridable, bool *r_overridden, bool *r_mandatory, bool *r_locked)
+int RNA_property_override_status(PointerRNA *ptr, PropertyRNA *prop, const int index)
 {
-#define SET_RET(_name, _val) if (_name != NULL) *_name = (_val)
-
-	SET_RET(r_overridable, false);
-	SET_RET(r_overridden, false);
-	SET_RET(r_mandatory, false);
-	SET_RET(r_locked, false);
+	int override_status = 0;
 
 	if (!ptr || !prop || !ptr->id.data || !((ID *)ptr->id.data)->override_static) {
-		return;
+		return override_status;
 	}
 
-	SET_RET(r_overridable, (prop->flag & PROP_OVERRIDABLE_STATIC) && (prop->flag & PROP_EDITABLE));
+	if ((prop->flag & PROP_OVERRIDABLE_STATIC) && (prop->flag & PROP_EDITABLE)) {
+		override_status |= RNA_OVERRIDE_STATUS_OVERRIDABLE;
+	}
 
-	if (r_overridden || r_mandatory || r_locked) {
-		IDOverrideStaticPropertyOperation *opop = RNA_property_override_property_operation_find(ptr, prop, index, false, NULL);
-		SET_RET(r_overridden, opop != NULL);
-		SET_RET(r_mandatory, (opop->flag & IDOVERRIDESTATIC_FLAG_MANDATORY) != 0);
-		SET_RET(r_locked, (opop->flag & IDOVERRIDESTATIC_FLAG_LOCKED) != 0);
+	IDOverrideStaticPropertyOperation *opop = RNA_property_override_property_operation_find(ptr, prop, index, false, NULL);
+	if (opop != NULL) {
+		override_status |= RNA_OVERRIDE_STATUS_OVERRIDDEN;
+		if (opop->flag & IDOVERRIDESTATIC_FLAG_MANDATORY) {
+			override_status |= RNA_OVERRIDE_STATUS_MANDATORY;
+		}
+		if (opop->flag & IDOVERRIDESTATIC_FLAG_LOCKED) {
+			override_status |= RNA_OVERRIDE_STATUS_LOCKED;
+		}
 	}
+
+	return override_status;
 }



More information about the Bf-blender-cvs mailing list