move debug flag into its own global var (G.debug), split up debug options.

--debug
  --debug-ffmpeg
  --debug-python
  --debug-events
  --debug-wm

This makes debug output easier to read - event debug prints would flood output too much before.

For convenience:
  --debug-all turns all debug flags on (works as --debug did before).

also removed some redundant whitespace in debug prints and prefix some prints with __func__ to give some context.
This commit is contained in:
2012-03-31 00:59:17 +00:00
parent ebb229110e
commit 5b88712ff9
98 changed files with 453 additions and 410 deletions

View File

@@ -166,24 +166,26 @@ static PyObject *make_app_info(void)
* they are not static */
PyDoc_STRVAR(bpy_app_debug_doc,
"Boolean, set when blender is running in debug mode (started with --debug)"
"Boolean, for debug info (started with --debug / --debug_* matching this attribute name)"
);
static PyObject *bpy_app_debug_get(PyObject *UNUSED(self), void *UNUSED(closure))
static PyObject *bpy_app_debug_get(PyObject *UNUSED(self), void *closure)
{
return PyBool_FromLong(G.f & G_DEBUG);
const int flag = GET_INT_FROM_POINTER(closure);
return PyBool_FromLong(G.debug & flag);
}
static int bpy_app_debug_set(PyObject *UNUSED(self), PyObject *value, void *UNUSED(closure))
static int bpy_app_debug_set(PyObject *UNUSED(self), PyObject *value, void *closure)
{
int param = PyObject_IsTrue(value);
const int flag = GET_INT_FROM_POINTER(closure);
const int param = PyObject_IsTrue(value);
if (param < 0) {
PyErr_SetString(PyExc_TypeError, "bpy.app.debug can only be True/False");
return -1;
}
if (param) G.f |= G_DEBUG;
else G.f &= ~G_DEBUG;
if (param) G.debug |= flag;
else G.debug &= ~flag;
return 0;
}
@@ -236,7 +238,12 @@ static PyObject *bpy_app_driver_dict_get(PyObject *UNUSED(self), void *UNUSED(cl
static PyGetSetDef bpy_app_getsets[] = {
{(char *)"debug", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, NULL},
{(char *)"debug", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG},
{(char *)"debug_ffmpeg", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_FFMPEG},
{(char *)"debug_python", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_PYTHON},
{(char *)"debug_events", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_EVENTS},
{(char *)"debug_wm", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_WM},
{(char *)"debug_value", bpy_app_debug_value_get, bpy_app_debug_value_set, (char *)bpy_app_debug_value_doc, NULL},
{(char *)"tempdir", bpy_app_tempdir_get, NULL, (char *)bpy_app_tempdir_doc, NULL},
{(char *)"driver_namespace", bpy_app_driver_dict_get, NULL, (char *)bpy_app_driver_dict_doc, NULL},

View File

@@ -696,7 +696,7 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
else printf("PyContext '%s' not found\n", member);
}
else {
if (G.f & G_DEBUG) {
if (G.debug & G_DEBUG_PYTHON) {
printf("PyContext '%s' found\n", member);
}
}

View File

@@ -6033,7 +6033,7 @@ static PyObject *pyrna_srna_ExternalType(StructRNA *srna)
newclass = NULL;
}
else {
if (G.f & G_DEBUG)
if (G.debug & G_DEBUG_PYTHON)
fprintf(stderr, "SRNA Subclassed: '%s'\n", idname);
}
}
@@ -7145,7 +7145,7 @@ static void bpy_class_free(void *pyob_ptr)
PyErr_Clear();
#if 0 /* needs further investigation, too annoying so quiet for now */
if (G.f & G_DEBUG) {
if (G.debug & G_DEBUG_PYTHON) {
if (self->ob_refcnt > 1) {
PyC_ObSpit("zombie class - ref should be 1", self);
}
@@ -7444,7 +7444,7 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla
}
/* should happen all the time but very slow */
if (G.f & G_DEBUG) {
if (G.debug & G_DEBUG_PYTHON) {
/* remove all properties using this class */
StructRNA *srna_iter;
PointerRNA ptr_rna;

View File

@@ -664,7 +664,7 @@ PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr,
len = RNA_property_multi_array_length(ptr, prop, arraydim);
if (index >= len || index < 0) {
/* this shouldn't happen because higher level funcs must check for invalid index */
if (G.f & G_DEBUG) printf("pyrna_py_from_array_index: invalid index %d for array with length=%d\n", index, len);
if (G.debug & G_DEBUG_PYTHON) printf("pyrna_py_from_array_index: invalid index %d for array with length=%d\n", index, len);
PyErr_SetString(PyExc_IndexError, "out of range");
return NULL;