Fix T52213: Enum drivers no longer work
authorCampbell Barton <ideasman42@gmail.com>
Fri, 28 Jul 2017 16:39:16 +0000 (02:39 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 28 Jul 2017 16:39:16 +0000 (02:39 +1000)
Regression in D1812: PyDriver variables as Objects

Taking the Python representation is nice in general
but for enums it would convert them into strings,
breaking some existing drivers.

source/blender/python/intern/bpy_rna_driver.c

index b4c0de51c04766a5fc38f24bb7f501a77c3e0d04..1135ba121e35e081c53ce13c4e2accbae33e0fc9 100644 (file)
@@ -63,7 +63,15 @@ PyObject *pyrna_driver_get_variable_value(
                        }
                        else {
                                /* object & property */
-                               driver_arg = pyrna_prop_to_py(&ptr, prop);
+                               PropertyType type = RNA_property_type(prop);
+                               if (type == PROP_ENUM) {
+                                       /* Note that enum's are converted to strings by default,
+                                        * we want to avoid that, see: T52213 */
+                                       driver_arg = PyLong_FromLong(RNA_property_enum_get(&ptr, prop));
+                               }
+                               else {
+                                       driver_arg = pyrna_prop_to_py(&ptr, prop);
+                               }
                        }
                }
                else {