Revision: 20285
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20285
Author:   campbellbarton
Date:     2009-05-20 07:35:53 +0200 (Wed, 20 May 2009)

Log Message:
-----------
fix for crash drawing the UI, normally this would cause a memory leak but for 
some reason it crashed with py2.6 and not 3.1.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/python/intern/bpy_rna.c

Modified: branches/blender2.5/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- branches/blender2.5/blender/source/blender/python/intern/bpy_rna.c  
2009-05-20 05:33:39 UTC (rev 20284)
+++ branches/blender2.5/blender/source/blender/python/intern/bpy_rna.c  
2009-05-20 05:35:53 UTC (rev 20285)
@@ -1843,10 +1843,20 @@
 
        py_class= RNA_struct_py_type_get(ptr->type);
        
-       args = PyTuple_New(1);
-       PyTuple_SET_ITEM(args, 0, pyrna_struct_CreatePyObject(ptr));
-       py_class_instance = PyObject_Call(py_class, args, NULL);
-       Py_DECREF(args);
+       item = pyrna_struct_CreatePyObject(ptr);
+       if(item == NULL) {
+               py_class_instance = NULL;
+       }
+       else if(item == Py_None) { /* probably wont ever happen but possible */
+               Py_DECREF(item);
+               py_class_instance = NULL;
+       }
+       else {
+               args = PyTuple_New(1);
+               PyTuple_SET_ITEM(args, 0, item);
+               py_class_instance = PyObject_Call(py_class, args, NULL);
+               Py_DECREF(args);
+       }
 
        if (py_class_instance) { /* Initializing the class worked, now run its 
invoke function */
                item= PyObject_GetAttrString(py_class, 
RNA_function_identifier(func));
@@ -1877,8 +1887,8 @@
 
                        ret = PyObject_Call(item, args, NULL);
 
-                       /* args is decref'd from item */
                        Py_DECREF(item);
+                       Py_DECREF(args);
                }
                else {
                        Py_DECREF(py_class_instance);


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to