Commit: f410b18832003a8cc95318b332762dbe4d5739c2
Author: Campbell Barton
Date:   Wed Jun 21 13:23:40 2017 +1000
Branches: custom-manipulators
https://developer.blender.org/rBf410b18832003a8cc95318b332762dbe4d5739c2

PyAPI: minor improvement to type check

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

M       source/blender/python/intern/bpy_rna.c

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

diff --git a/source/blender/python/intern/bpy_rna.c 
b/source/blender/python/intern/bpy_rna.c
index 8b122b24cd9..51e179fb317 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -1839,30 +1839,28 @@ static int pyrna_py_to_prop(
                                 * class mixing if this causes problems in the 
future it should be removed.
                                 */
                                if ((ptr_type == &RNA_AnyType) &&
-                                   (BPy_StructRNA_Check(value)) &&
-                                   (RNA_struct_is_a(((BPy_StructRNA 
*)value)->ptr.type, &RNA_Operator)))
+                                   (BPy_StructRNA_Check(value)))
                                {
-                                       value = PyObject_GetAttr(value, 
bpy_intern_str_properties);
-                                       value_new = value;
-                               }
-                               /* XXX, de-duplicate (abive) */
-                               else if ((ptr_type == &RNA_AnyType) &&
-                                        (BPy_StructRNA_Check(value)) &&
-                                   (RNA_struct_is_a(((BPy_StructRNA 
*)value)->ptr.type, &RNA_Manipulator)))
-                               {
-                                       value = PyObject_GetAttrString(value, 
"properties");
-                                       value_new = value;
+                                       const StructRNA *base_type =
+                                               
RNA_struct_base_child_of(((const BPy_StructRNA *)value)->ptr.type, NULL);
+                                       if (ELEM(base_type, &RNA_Operator, 
&RNA_Manipulator)) {
+                                               value = PyObject_GetAttr(value, 
bpy_intern_str_properties);
+                                               value_new = value;
+                                       }
                                }
 
-                               /* if property is an OperatorProperties pointer 
and value is a map,
+                               /* if property is an 
OperatorProperties/ManipulatorProperties pointer and value is a map,
                                 * forward back to pyrna_pydict_to_props */
-                               if (RNA_struct_is_a(ptr_type, 
&RNA_OperatorProperties) && PyDict_Check(value)) {
-                                       PointerRNA opptr = 
RNA_property_pointer_get(ptr, prop);
-                                       return pyrna_pydict_to_props(&opptr, 
value, false, error_prefix);
-                               }
-                               else if (RNA_struct_is_a(ptr_type, 
&RNA_ManipulatorProperties) && PyDict_Check(value)) {
-                                       PointerRNA opptr = 
RNA_property_pointer_get(ptr, prop);
-                                       return pyrna_pydict_to_props(&opptr, 
value, false, error_prefix);
+                               if (PyDict_Check(value)) {
+                                       const StructRNA *base_type = 
RNA_struct_base_child_of(ptr_type, NULL);
+                                       if (base_type == 
&RNA_OperatorProperties) {
+                                               PointerRNA opptr = 
RNA_property_pointer_get(ptr, prop);
+                                               return 
pyrna_pydict_to_props(&opptr, value, false, error_prefix);
+                                       }
+                                       else if (base_type == 
&RNA_ManipulatorProperties) {
+                                               PointerRNA opptr = 
RNA_property_pointer_get(ptr, prop);
+                                               return 
pyrna_pydict_to_props(&opptr, value, false, error_prefix);
+                                       }
                                }
 
                                /* another exception, allow to pass a 
collection as an RNA property */

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to