fix for crash drawing the UI, normally this would cause a memory leak but for some...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 20 May 2009 05:35:53 +0000 (05:35 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 20 May 2009 05:35:53 +0000 (05:35 +0000)
source/blender/python/intern/bpy_rna.c

index d0e5d508325a52a7469946f5a0f88f76c6c24ac6..3274a2ba28426915ac63a337a7a7c8340e8f005d 100644 (file)
@@ -1843,10 +1843,20 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par
 
        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 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par
 
                        ret = PyObject_Call(item, args, NULL);
 
-                       /* args is decref'd from item */
                        Py_DECREF(item);
+                       Py_DECREF(args);
                }
                else {
                        Py_DECREF(py_class_instance);