[Bf-blender-cvs] [a11808a2482] blender2.8: Manipulator: allow py manipulators w/o properties

Campbell Barton noreply at git.blender.org
Mon Jul 17 05:10:47 CEST 2017


Commit: a11808a248200a7ee5a9fca0ae16581fee1c249b
Author: Campbell Barton
Date:   Mon Jul 17 12:29:37 2017 +1000
Branches: blender2.8
https://developer.blender.org/rBa11808a248200a7ee5a9fca0ae16581fee1c249b

Manipulator: allow py manipulators w/o properties

These could be used for manipulators that run operators.

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

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

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

diff --git a/source/blender/python/intern/bpy_manipulator_wrap.c b/source/blender/python/intern/bpy_manipulator_wrap.c
index 7d02c2963d7..db9fcdb377a 100644
--- a/source/blender/python/intern/bpy_manipulator_wrap.c
+++ b/source/blender/python/intern/bpy_manipulator_wrap.c
@@ -143,27 +143,32 @@ static void manipulator_properties_init(wmManipulatorType *wt)
 		 * get direct from the dict to avoid raising a load of attribute errors (yes this isnt ideal) - campbell */
 		PyObject *py_class_dict = py_class->tp_dict;
 		PyObject *bl_target_properties = PyDict_GetItem(py_class_dict, bpy_intern_str_bl_target_properties);
-		PyObject *bl_target_properties_fast;
 
-		if (!(bl_target_properties_fast = PySequence_Fast(bl_target_properties, "bl_target_properties sequence"))) {
-			/* PySequence_Fast sets the error */
-			PyErr_Print();
-			PyErr_Clear();
-			return;
-		}
-
-		const uint items_len = PySequence_Fast_GET_SIZE(bl_target_properties_fast);
-		PyObject **items = PySequence_Fast_ITEMS(bl_target_properties_fast);
-
-		for (uint i = 0; i < items_len; i++) {
-			if (!bpy_manipulatortype_target_property_def(wt, items[i])) {
+		/* Some widgets may only exist to activate operators. */
+		if (bl_target_properties != NULL) {
+			PyObject *bl_target_properties_fast;
+			if (!(bl_target_properties_fast = PySequence_Fast(
+			          bl_target_properties, "bl_target_properties sequence")))
+			{
+				/* PySequence_Fast sets the error */
 				PyErr_Print();
 				PyErr_Clear();
-				break;
+				return;
 			}
-		}
 
-		Py_DECREF(bl_target_properties_fast);
+			const uint items_len = PySequence_Fast_GET_SIZE(bl_target_properties_fast);
+			PyObject **items = PySequence_Fast_ITEMS(bl_target_properties_fast);
+
+			for (uint i = 0; i < items_len; i++) {
+				if (!bpy_manipulatortype_target_property_def(wt, items[i])) {
+					PyErr_Print();
+					PyErr_Clear();
+					break;
+				}
+			}
+
+			Py_DECREF(bl_target_properties_fast);
+		}
 	}
 }




More information about the Bf-blender-cvs mailing list