forked from bartvdbraak/blender
new function RNA_warning(), replaces printf with function which may be called via python.
Now this gives the line number of the scripts thats running, eg: uiItemFullO: unknown operator 'some.operator' /c/bin/2.56/scripts/startup/bl_ui/space_view3d_toolbar.py:73
This commit is contained in:
parent
16e736b7db
commit
a21f46b6d4
@ -2546,7 +2546,7 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("ui_def_but_rna: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
RNA_warning("ui_def_but_rna: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
str= propname;
|
||||
}
|
||||
|
||||
|
@ -609,15 +609,16 @@ static void ui_item_disabled(uiLayout *layout, const char *name)
|
||||
}
|
||||
|
||||
/* operator items */
|
||||
PointerRNA uiItemFullO(uiLayout *layout, const char *idname, const char *name, int icon, IDProperty *properties, int context, int flag)
|
||||
PointerRNA uiItemFullO(uiLayout *layout, const char *opname, const char *name, int icon, IDProperty *properties, int context, int flag)
|
||||
{
|
||||
uiBlock *block= layout->root->block;
|
||||
wmOperatorType *ot= WM_operatortype_find(idname, 0);
|
||||
wmOperatorType *ot= WM_operatortype_find(opname, 1);
|
||||
uiBut *but;
|
||||
int w;
|
||||
|
||||
if(!ot) {
|
||||
ui_item_disabled(layout, idname);
|
||||
ui_item_disabled(layout, opname);
|
||||
RNA_warning("uiItemFullO: unknown operator '%s'\n", opname);
|
||||
return PointerRNA_NULL;
|
||||
}
|
||||
|
||||
@ -713,7 +714,7 @@ void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int ico
|
||||
|
||||
void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname, IDProperty *properties, int context, int flag)
|
||||
{
|
||||
wmOperatorType *ot= WM_operatortype_find(opname, 0);
|
||||
wmOperatorType *ot= WM_operatortype_find(opname, 1);
|
||||
PointerRNA ptr;
|
||||
PropertyRNA *prop;
|
||||
uiBut *bt;
|
||||
@ -721,6 +722,7 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname
|
||||
|
||||
if(!ot || !ot->srna) {
|
||||
ui_item_disabled(layout, opname);
|
||||
RNA_warning("uiItemsFullEnumO: %s '%s'\n", ot ? "unknown operator" : "operator missing srna", opname);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -795,7 +797,7 @@ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char
|
||||
/* pass */
|
||||
}
|
||||
else {
|
||||
printf("uiItemEnumO_value: %s.%s not found.\n", RNA_struct_identifier(ptr.type), propname);
|
||||
RNA_warning("uiItemEnumO_value: %s.%s not found.\n", RNA_struct_identifier(ptr.type), propname);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -824,7 +826,7 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char
|
||||
RNA_property_enum_items(layout->root->block->evil_C, &ptr, prop, &item, NULL, &free);
|
||||
if(item==NULL || RNA_enum_value_from_id(item, value_str, &value)==0) {
|
||||
if(free) MEM_freeN(item);
|
||||
printf("uiItemEnumO_string: %s.%s, enum %s not found.\n", RNA_struct_identifier(ptr.type), propname, value_str);
|
||||
RNA_warning("uiItemEnumO_string: %s.%s, enum %s not found.\n", RNA_struct_identifier(ptr.type), propname, value_str);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -832,7 +834,7 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char
|
||||
MEM_freeN(item);
|
||||
}
|
||||
else {
|
||||
printf("uiItemEnumO_string: %s.%s not found.\n", RNA_struct_identifier(ptr.type), propname);
|
||||
RNA_warning("uiItemEnumO_string: %s.%s not found.\n", RNA_struct_identifier(ptr.type), propname);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1038,7 +1040,7 @@ void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, int flag,
|
||||
|
||||
if(!prop) {
|
||||
ui_item_disabled(layout, propname);
|
||||
printf("uiItemR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
RNA_warning("uiItemR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1051,7 +1053,7 @@ void uiItemEnumR(uiLayout *layout, const char *name, int icon, struct PointerRNA
|
||||
|
||||
if(!prop || RNA_property_type(prop) != PROP_ENUM) {
|
||||
ui_item_disabled(layout, propname);
|
||||
printf("uiItemEnumR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
RNA_warning("uiItemEnumR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1066,7 +1068,7 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr
|
||||
|
||||
if(!prop || RNA_property_type(prop) != PROP_ENUM) {
|
||||
ui_item_disabled(layout, propname);
|
||||
printf("uiItemEnumR_string: enum property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
RNA_warning("uiItemEnumR_string: enum property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1075,7 +1077,7 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr
|
||||
if(!RNA_enum_value_from_id(item, value, &ivalue)) {
|
||||
if(free) MEM_freeN(item);
|
||||
ui_item_disabled(layout, propname);
|
||||
printf("uiItemEnumR: enum property value not found: %s\n", value);
|
||||
RNA_warning("uiItemEnumR: enum property value not found: %s\n", value);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1100,10 +1102,15 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname
|
||||
|
||||
if(!prop) {
|
||||
ui_item_disabled(layout, propname);
|
||||
RNA_warning("uiItemsEnumR: enum property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
return;
|
||||
}
|
||||
|
||||
if(RNA_property_type(prop) == PROP_ENUM) {
|
||||
if(RNA_property_type(prop) != PROP_ENUM) {
|
||||
RNA_warning("uiItemsEnumR: not an enum property: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
EnumPropertyItem *item;
|
||||
int totitem, i, free;
|
||||
uiLayout *split= uiLayoutSplit(layout, 0, 0);
|
||||
@ -1288,13 +1295,13 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna
|
||||
prop= RNA_struct_find_property(ptr, propname);
|
||||
|
||||
if(!prop) {
|
||||
printf("uiItemPointerR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
RNA_warning("uiItemPointerR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
return;
|
||||
}
|
||||
|
||||
type= RNA_property_type(prop);
|
||||
if(!ELEM(type, PROP_POINTER, PROP_STRING)) {
|
||||
printf("uiItemPointerR: property %s must be a pointer or string.\n", propname);
|
||||
RNA_warning("uiItemPointerR: property %s must be a pointer or string.\n", propname);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1302,11 +1309,11 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna
|
||||
|
||||
|
||||
if(!searchprop) {
|
||||
printf("uiItemPointerR: search collection property not found: %s.%s\n", RNA_struct_identifier(ptr->type), searchpropname);
|
||||
RNA_warning("uiItemPointerR: search collection property not found: %s.%s\n", RNA_struct_identifier(ptr->type), searchpropname);
|
||||
return;
|
||||
}
|
||||
else if (RNA_property_type(searchprop) != PROP_COLLECTION) {
|
||||
printf("uiItemPointerR: search collection property is not a collection type: %s.%s\n", RNA_struct_identifier(ptr->type), searchpropname);
|
||||
RNA_warning("uiItemPointerR: search collection property is not a collection type: %s.%s\n", RNA_struct_identifier(ptr->type), searchpropname);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1391,7 +1398,7 @@ void uiItemM(uiLayout *layout, bContext *UNUSED(C), const char *menuname, const
|
||||
mt= WM_menutype_find(menuname, FALSE);
|
||||
|
||||
if(mt==NULL) {
|
||||
printf("uiItemM: not found %s\n", menuname);
|
||||
RNA_warning("uiItemM: not found %s\n", menuname);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1504,11 +1511,12 @@ static void menu_item_enum_opname_menu(bContext *UNUSED(C), uiLayout *layout, vo
|
||||
|
||||
void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, const char *name, int icon)
|
||||
{
|
||||
wmOperatorType *ot= WM_operatortype_find(opname, 0);
|
||||
wmOperatorType *ot= WM_operatortype_find(opname, 1);
|
||||
MenuItemLevel *lvl;
|
||||
|
||||
if(!ot || !ot->srna) {
|
||||
ui_item_disabled(layout, opname);
|
||||
RNA_warning("uiItemMenuEnumO: %s '%s'\n", ot ? "unknown operator" : "operator missing srna", name);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1541,6 +1549,7 @@ void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propn
|
||||
prop= RNA_struct_find_property(ptr, propname);
|
||||
if(!prop) {
|
||||
ui_item_disabled(layout, propname);
|
||||
RNA_warning("uiItemMenuEnumR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
|
||||
switch(event) {
|
||||
case UI_ID_BROWSE:
|
||||
case UI_ID_PIN:
|
||||
printf("warning, id event %d shouldnt come here\n", event);
|
||||
RNA_warning("warning, id event %d shouldnt come here\n", event);
|
||||
break;
|
||||
case UI_ID_OPEN:
|
||||
case UI_ID_ADD_NEW:
|
||||
@ -484,7 +484,7 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const
|
||||
prop= RNA_struct_find_property(ptr, propname);
|
||||
|
||||
if(!prop || RNA_property_type(prop) != PROP_POINTER) {
|
||||
printf("uiTemplateID: pointer property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
RNA_warning("uiTemplateID: pointer property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -545,11 +545,11 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, co
|
||||
propType= RNA_struct_find_property(ptr, proptypename);
|
||||
|
||||
if (!propID || RNA_property_type(propID) != PROP_POINTER) {
|
||||
printf("uiTemplateAnyID: pointer property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
RNA_warning("uiTemplateAnyID: pointer property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
return;
|
||||
}
|
||||
if (!propType || RNA_property_type(propType) != PROP_ENUM) {
|
||||
printf("uiTemplateAnyID: pointer-type property not found: %s.%s\n", RNA_struct_identifier(ptr->type), proptypename);
|
||||
RNA_warning("uiTemplateAnyID: pointer-type property not found: %s.%s\n", RNA_struct_identifier(ptr->type), proptypename);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -588,7 +588,7 @@ void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propna
|
||||
/* check that properties are valid */
|
||||
propPath= RNA_struct_find_property(ptr, propname);
|
||||
if (!propPath || RNA_property_type(propPath) != PROP_STRING) {
|
||||
printf("uiTemplatePathBuilder: path property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
RNA_warning("uiTemplatePathBuilder: path property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -830,7 +830,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
||||
|
||||
/* verify we have valid data */
|
||||
if(!RNA_struct_is_a(ptr->type, &RNA_Modifier)) {
|
||||
printf("uiTemplateModifier: expected modifier on object.\n");
|
||||
RNA_warning("uiTemplateModifier: expected modifier on object.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -838,7 +838,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
||||
md= ptr->data;
|
||||
|
||||
if(!ob || !(GS(ob->id.name) == ID_OB)) {
|
||||
printf("uiTemplateModifier: expected modifier on object.\n");
|
||||
RNA_warning("uiTemplateModifier: expected modifier on object.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1062,7 +1062,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
|
||||
|
||||
/* verify we have valid data */
|
||||
if(!RNA_struct_is_a(ptr->type, &RNA_Constraint)) {
|
||||
printf("uiTemplateConstraint: expected constraint on object.\n");
|
||||
RNA_warning("uiTemplateConstraint: expected constraint on object.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1070,7 +1070,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
|
||||
con= ptr->data;
|
||||
|
||||
if(!ob || !(GS(ob->id.name) == ID_OB)) {
|
||||
printf("uiTemplateConstraint: expected constraint on object.\n");
|
||||
RNA_warning("uiTemplateConstraint: expected constraint on object.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1116,7 +1116,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M
|
||||
PointerRNA texture_ptr;
|
||||
|
||||
if(id && !ELEM4(GS(id->name), ID_MA, ID_TE, ID_WO, ID_LA)) {
|
||||
printf("uiTemplatePreview: expected ID of type material, texture, lamp or world.\n");
|
||||
RNA_warning("uiTemplatePreview: expected ID of type material, texture, lamp or world.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1818,8 +1818,15 @@ void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propn
|
||||
PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
|
||||
PointerRNA cptr;
|
||||
|
||||
if(!prop || RNA_property_type(prop) != PROP_POINTER)
|
||||
if(!prop) {
|
||||
RNA_warning("uiTemplateCurveMapping: curve property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
return;
|
||||
}
|
||||
|
||||
if(RNA_property_type(prop) != PROP_POINTER) {
|
||||
RNA_warning("uiTemplateCurveMapping: curve is not a pointer: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
return;
|
||||
}
|
||||
|
||||
cptr= RNA_property_pointer_get(ptr, prop);
|
||||
if(!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_CurveMapping))
|
||||
@ -1847,7 +1854,7 @@ void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, const char *propnam
|
||||
float softmin, softmax, step, precision;
|
||||
|
||||
if (!prop) {
|
||||
printf("uiTemplateColorWheel: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
RNA_warning("uiTemplateColorWheel: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1917,7 +1924,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname,
|
||||
|
||||
prop= RNA_struct_find_property(ptr, propname);
|
||||
if (!prop) {
|
||||
printf("uiTemplateLayer: layers property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
RNA_warning("uiTemplateLayer: layers property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1934,7 +1941,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname,
|
||||
if(used_ptr && used_propname) {
|
||||
used_prop= RNA_struct_find_property(used_ptr, used_propname);
|
||||
if (!used_prop) {
|
||||
printf("uiTemplateLayer: used layers property not found: %s.%s\n", RNA_struct_identifier(ptr->type), used_propname);
|
||||
RNA_warning("uiTemplateLayer: used layers property not found: %s.%s\n", RNA_struct_identifier(ptr->type), used_propname);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2115,7 +2122,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
|
||||
pa= block->panel;
|
||||
|
||||
if(!pa) {
|
||||
printf("uiTemplateList: only works inside a panel.\n");
|
||||
RNA_warning("uiTemplateList: only works inside a panel.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2125,28 +2132,28 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
|
||||
if(ptr->data) {
|
||||
prop= RNA_struct_find_property(ptr, propname);
|
||||
if(!prop) {
|
||||
printf("uiTemplateList: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
RNA_warning("uiTemplateList: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
activeprop= RNA_struct_find_property(activeptr, activepropname);
|
||||
if(!activeprop) {
|
||||
printf("uiTemplateList: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), activepropname);
|
||||
RNA_warning("uiTemplateList: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), activepropname);
|
||||
return;
|
||||
}
|
||||
|
||||
if(prop) {
|
||||
type= RNA_property_type(prop);
|
||||
if(type != PROP_COLLECTION) {
|
||||
printf("uiTemplateList: expected collection property.\n");
|
||||
RNA_warning("uiTemplateList: expected collection property.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
activetype= RNA_property_type(activeprop);
|
||||
if(activetype != PROP_INT) {
|
||||
printf("uiTemplateList: expected integer property.\n");
|
||||
RNA_warning("uiTemplateList: expected integer property.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -955,6 +955,12 @@ int RNA_function_call_direct_va_lookup(struct bContext *C, struct ReportList *re
|
||||
short RNA_type_to_ID_code(StructRNA *type);
|
||||
StructRNA *ID_code_to_RNA_type(short idcode);
|
||||
|
||||
void RNA_warning(const char *format, ...)
|
||||
#ifdef __GNUC__
|
||||
__attribute__ ((format (printf, 1, 2)))
|
||||
#endif
|
||||
;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -62,6 +62,22 @@
|
||||
|
||||
#include "rna_internal.h"
|
||||
|
||||
void RNA_warning(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
vprintf(format, args);
|
||||
va_end(args);
|
||||
|
||||
#if WITH_PYTHON
|
||||
{
|
||||
extern void PyC_LineSpit(void);
|
||||
PyC_LineSpit();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
const PointerRNA PointerRNA_NULL= {{NULL}};
|
||||
|
||||
/* Init/Exit */
|
||||
|
@ -30,6 +30,8 @@
|
||||
|
||||
#include "py_capi_utils.h"
|
||||
|
||||
#define PYC_INTERPRETER_ACTIVE (((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current)) != NULL)
|
||||
|
||||
/* for debugging */
|
||||
void PyC_ObSpit(const char *name, PyObject *var) {
|
||||
fprintf(stderr, "<%s> : ", name);
|
||||
@ -51,9 +53,16 @@ void PyC_ObSpit(const char *name, PyObject *var) {
|
||||
}
|
||||
|
||||
void PyC_LineSpit(void) {
|
||||
|
||||
const char *filename;
|
||||
int lineno;
|
||||
|
||||
/* Note, allow calling from outside python (RNA) */
|
||||
if(!PYC_INTERPRETER_ACTIVE) {
|
||||
fprintf(stderr, "python line lookup failed, interpreter inactive\n");
|
||||
return;
|
||||
}
|
||||
|
||||
PyErr_Clear();
|
||||
PyC_FileAndNum(&filename, &lineno);
|
||||
|
||||
|
@ -47,4 +47,5 @@ void PyC_RunQuicky(const char *filepath, int n, ...);
|
||||
|
||||
void PyC_MainModule_Backup(PyObject **main_mod);
|
||||
void PyC_MainModule_Restore(PyObject *main_mod);
|
||||
|
||||
#endif // PY_CAPI_UTILS_H
|
||||
|
Loading…
Reference in New Issue
Block a user