[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24224] trunk/blender/source/blender/ python/intern/bpy_operator_wrap.c: last commit broke running python operators

Campbell Barton ideasman42 at gmail.com
Mon Nov 2 01:20:07 CET 2009


Revision: 24224
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24224
Author:   campbellbarton
Date:     2009-11-02 01:20:07 +0100 (Mon, 02 Nov 2009)

Log Message:
-----------
last commit broke running python operators
note that you can still set rna properties like this.
 bpy.data.__dict__["var"] = 1
 print(bpy.data.var)

but this is only stored for the python objects lifetime and not actually attached to blenders data

Modified Paths:
--------------
    trunk/blender/source/blender/python/intern/bpy_operator_wrap.c

Modified: trunk/blender/source/blender/python/intern/bpy_operator_wrap.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_operator_wrap.c	2009-11-01 22:30:47 UTC (rev 24223)
+++ trunk/blender/source/blender/python/intern/bpy_operator_wrap.c	2009-11-02 00:20:07 UTC (rev 24224)
@@ -102,8 +102,8 @@
 	Py_DECREF(args);
 	
 	if (py_class_instance) { /* Initializing the class worked, now run its invoke function */
+		PyObject *class_dict= PyObject_GetAttrString(py_class_instance, "__dict__");
 		
-		
 		/* Assign instance attributes from operator properties */
 		if(op) {
 			const char *arg_name;
@@ -114,7 +114,7 @@
 				if (strcmp(arg_name, "rna_type")==0) continue;
 
 				item = pyrna_prop_to_py(op->ptr, prop);
-				PyObject_SetAttrString(py_class_instance, arg_name, item);
+				PyDict_SetItemString(class_dict, arg_name, item);
 				Py_DECREF(item);
 			}
 			RNA_STRUCT_END;
@@ -124,7 +124,7 @@
 		if(op) {
 			RNA_pointer_create(NULL, &RNA_Operator, op, &ptr_operator);
 			py_operator= pyrna_struct_CreatePyObject(&ptr_operator);
-			PyObject_SetAttrString(py_class_instance, "__operator__", py_operator);
+			PyDict_SetItemString(class_dict, "__operator__", py_operator);
 			Py_DECREF(py_operator);
 		}
 
@@ -158,6 +158,7 @@
 		
 		Py_DECREF(args);
 		Py_DECREF(item);
+		Py_DECREF(class_dict);
 	}
 	
 	if (ret == NULL) { /* covers py_class_instance failing too */
@@ -245,7 +246,7 @@
 void PYTHON_OT_wrapper(wmOperatorType *ot, void *userdata)
 {
 	PyObject *py_class = (PyObject *)userdata;
-	PyObject *props, *item;
+	PyObject *item;
 
 	/* identifiers */
 	item= PyObject_GetAttrString(py_class, PYOP_ATTR_IDNAME_BL);
@@ -325,7 +326,6 @@
 	
 	char *idname= NULL;
 	char idname_bl[OP_MAX_TYPENAME]; /* converted to blender syntax */
-	int i;
 
 	static struct BPY_class_attr_check pyop_class_attr_values[]= {
 		{PYOP_ATTR_IDNAME,		's', -1, OP_MAX_TYPENAME-3,	0}, /* -3 because a.b -> A_OT_b */





More information about the Bf-blender-cvs mailing list