Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-05-06 07:29:55 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-05-06 07:29:55 +0400
commitba5d18b41faa6cff6bfa1a8bb060b47dc4d61309 (patch)
tree2c6c704b7310a4146b9373f5bbfe3ed1c0e202a5
parent22c22d49617ac1f33037492e27c41f185618cffa (diff)
py/rna debugging option (defaults to off), which quickly exposes errors with RNA functions holding string pointers by making a temp copy of the string and freeing after the function is called.
-rw-r--r--source/blender/python/intern/bpy_rna.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 74af9761b98..8af0db6ee13 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -4243,6 +4243,14 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
PropertyRNA *pret_single= NULL;
void *retdata_single= NULL;
+ /* enable this so all strings are copied and freed after calling.
+ * this exposes bugs where the pointer to the string is held and re-used */
+// #define DEBUG_STRING_FREE
+
+#ifdef DEBUG_STRING_FREE
+ PyObject *string_free_ls= PyList_New(0);
+#endif
+
/* Should never happen but it does in rare cases */
BLI_assert(self_ptr != NULL);
@@ -4331,10 +4339,20 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
err= -1;
break;
}
- else /* PyDict_GetItemString wont raise an error */
+ else { /* PyDict_GetItemString wont raise an error */
continue;
+ }
}
+#ifdef DEBUG_STRING_FREE
+ if(item) {
+ if(PyUnicode_Check(item)) {
+ item= PyUnicode_FromString(_PyUnicode_AsString(item));
+ PyList_Append(string_free_ls, item);
+ Py_DECREF(item);
+ }
+ }
+#endif
err= pyrna_py_to_prop(&funcptr, parm, iter.data, item, "");
if(err!=0) {
@@ -4470,6 +4488,13 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
}
}
+
+#ifdef DEBUG_STRING_FREE
+ // if(PyList_Size(string_free_ls)) printf("%.200s.%.200s(): has %d strings\n", RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), (int)PyList_Size(string_free_ls));
+ Py_DECREF(string_free_ls);
+#undef DEBUG_STRING_FREE
+#endif
+
/* cleanup */
RNA_parameter_list_end(&iter);
RNA_parameter_list_free(&parms);