[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43614] trunk/blender/source/blender/ editors/interface/interface_layout.c: minor edit for operator error macro so it can return different values.

Campbell Barton ideasman42 at gmail.com
Sun Jan 22 20:52:50 CET 2012


Revision: 43614
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43614
Author:   campbellbarton
Date:     2012-01-22 19:52:41 +0000 (Sun, 22 Jan 2012)
Log Message:
-----------
minor edit for operator error macro so it can return different values.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface_layout.c

Modified: trunk/blender/source/blender/editors/interface/interface_layout.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_layout.c	2012-01-22 18:59:06 UTC (rev 43613)
+++ trunk/blender/source/blender/editors/interface/interface_layout.c	2012-01-22 19:52:41 UTC (rev 43614)
@@ -66,6 +66,14 @@
 #define EM_SEPR_X		6
 #define EM_SEPR_Y		6
 
+#define UI_OPERATOR_ERROR_RET(_ot, _opname, return_statement)                 \
+	if (ot == NULL) {                                                         \
+		ui_item_disabled(layout, _opname);                                    \
+		RNA_warning("'%s' unknown operator", _opname);                        \
+		return_statement;                                                     \
+	} (void)0                                                                 \
+
+
 /* uiLayoutRoot */
 
 typedef struct uiLayoutRoot {
@@ -690,14 +698,9 @@
 {
 	wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
 
-	if(ot) {
-		return uiItemFullO_ptr(layout, ot, name, icon, properties, context, flag);
-	}
-	else {
-		ui_item_disabled(layout, opname);
-		RNA_warning("unknown operator '%s'", opname);
-		return PointerRNA_NULL;
-	}
+	UI_OPERATOR_ERROR_RET(ot, opname, return PointerRNA_NULL);
+
+	return uiItemFullO_ptr(layout, ot, name, icon, properties, context, flag);
 }
 
 static const char *ui_menu_enumpropname(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int retval)
@@ -842,13 +845,6 @@
 	uiItemsFullEnumO(layout, opname, propname, NULL, layout->root->opcontext, 0);
 }
 
-#define UI_OPERATOR_ERROR_RET(_ot, _opname)                                   \
-	if (ot == NULL) {                                                         \
-		ui_item_disabled(layout, _opname);                                    \
-		RNA_warning("'%s' unknown operator", _opname);                        \
-		return;                                                               \
-	} (void)0
-
 /* for use in cases where we have */
 void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value)
 {
@@ -856,7 +852,7 @@
 	PointerRNA ptr;
 	PropertyRNA *prop;
 
-	UI_OPERATOR_ERROR_RET(ot, opname);
+	UI_OPERATOR_ERROR_RET(ot, opname, return);
 
 	WM_operator_properties_create_ptr(&ptr, ot);
 
@@ -887,7 +883,7 @@
 	EnumPropertyItem *item;
 	int value, free;
 
-	UI_OPERATOR_ERROR_RET(ot, opname);
+	UI_OPERATOR_ERROR_RET(ot, opname, return);
 
 	WM_operator_properties_create_ptr(&ptr, ot);
 	
@@ -925,7 +921,7 @@
 	wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
 	PointerRNA ptr;
 
-	UI_OPERATOR_ERROR_RET(ot, opname);
+	UI_OPERATOR_ERROR_RET(ot, opname, return);
 
 	WM_operator_properties_create_ptr(&ptr, ot);
 	RNA_boolean_set(&ptr, propname, value);
@@ -938,7 +934,7 @@
 	wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
 	PointerRNA ptr;
 
-	UI_OPERATOR_ERROR_RET(ot, opname);
+	UI_OPERATOR_ERROR_RET(ot, opname, return);
 
 	WM_operator_properties_create_ptr(&ptr, ot);
 	RNA_int_set(&ptr, propname, value);
@@ -951,7 +947,7 @@
 	wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
 	PointerRNA ptr;
 
-	UI_OPERATOR_ERROR_RET(ot, opname);
+	UI_OPERATOR_ERROR_RET(ot, opname, return);
 
 	WM_operator_properties_create_ptr(&ptr, ot);
 	RNA_float_set(&ptr, propname, value);
@@ -964,7 +960,7 @@
 	wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
 	PointerRNA ptr;
 
-	UI_OPERATOR_ERROR_RET(ot, opname);
+	UI_OPERATOR_ERROR_RET(ot, opname, return);
 
 	WM_operator_properties_create_ptr(&ptr, ot);
 	RNA_string_set(&ptr, propname, value);
@@ -1608,7 +1604,7 @@
 	wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
 	MenuItemLevel *lvl;
 
-	UI_OPERATOR_ERROR_RET(ot, opname);
+	UI_OPERATOR_ERROR_RET(ot, opname, return);
 
 	if(!ot->srna) {
 		ui_item_disabled(layout, opname);



More information about the Bf-blender-cvs mailing list