[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35767] trunk/blender/source/blender: new function RNA_warning(), replaces printf with function which may be called via python.

Campbell Barton ideasman42 at gmail.com
Fri Mar 25 05:36:11 CET 2011


Revision: 35767
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35767
Author:   campbellbarton
Date:     2011-03-25 04:36:10 +0000 (Fri, 25 Mar 2011)
Log Message:
-----------
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

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface.c
    trunk/blender/source/blender/editors/interface/interface_layout.c
    trunk/blender/source/blender/editors/interface/interface_templates.c
    trunk/blender/source/blender/makesrna/RNA_access.h
    trunk/blender/source/blender/makesrna/intern/rna_access.c
    trunk/blender/source/blender/python/generic/py_capi_utils.c
    trunk/blender/source/blender/python/generic/py_capi_utils.h

Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c	2011-03-25 04:06:43 UTC (rev 35766)
+++ trunk/blender/source/blender/editors/interface/interface.c	2011-03-25 04:36:10 UTC (rev 35767)
@@ -2546,7 +2546,7 @@
 		}
 	}
 	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;
 	}
 

Modified: trunk/blender/source/blender/editors/interface/interface_layout.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_layout.c	2011-03-25 04:06:43 UTC (rev 35766)
+++ trunk/blender/source/blender/editors/interface/interface_layout.c	2011-03-25 04:36:10 UTC (rev 35767)
@@ -609,15 +609,16 @@
 }
 
 /* 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 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 @@
 
 	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 @@
 		/* 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 @@
 		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 @@
 			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 @@
 
 	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 @@
 
 	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 @@
 
 	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 @@
 	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 @@
 
 	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 @@
 	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 @@
 
 
 	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 @@
 	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 @@
 
 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 @@
 	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;
 	}
 

Modified: trunk/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_templates.c	2011-03-25 04:06:43 UTC (rev 35766)
+++ trunk/blender/source/blender/editors/interface/interface_templates.c	2011-03-25 04:36:10 UTC (rev 35767)
@@ -240,7 +240,7 @@
 	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 @@
 	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 @@
 	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 @@
 	/* 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 @@
 
 	/* 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 @@
 	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 @@
 
 	/* 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 @@
 	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 @@
 	PointerRNA texture_ptr;
 
 	if(id && !ELEM4(GS(id->name), ID_MA, ID_TE, ID_WO, ID_LA)) {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list