[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45020] trunk/blender/source/blender/ makesrna/intern/rna_access.c: py/ rna api - fix for an empty enum flag with no members being displayed as {}, now check for this case and display as set()

Campbell Barton ideasman42 at gmail.com
Tue Mar 20 08:52:44 CET 2012


Revision: 45020
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45020
Author:   campbellbarton
Date:     2012-03-20 07:52:39 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
py/rna api - fix for an empty enum flag with no members being displayed as {}, now check for this case and display as set()

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_access.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_access.c	2012-03-20 07:41:47 UTC (rev 45019)
+++ trunk/blender/source/blender/makesrna/intern/rna_access.c	2012-03-20 07:52:39 UTC (rev 45020)
@@ -4698,27 +4698,33 @@
 
 		if (RNA_property_flag(prop) & PROP_ENUM_FLAG) {
 			/* represent as a python set */
-			EnumPropertyItem *item = NULL;
-			int free;
+			if (val) {
+				EnumPropertyItem *item = NULL;
+				int free;
 
-			BLI_dynstr_append(dynstr, "{");
+				BLI_dynstr_append(dynstr, "{");
 
-			RNA_property_enum_items(C, ptr, prop, &item, NULL, &free);
-			if (item) {
-				short is_first = TRUE;
-				for (; item->identifier; item++) {
-					if (item->identifier[0] && item->value & val) {
-						BLI_dynstr_appendf(dynstr, is_first ? "'%s'" : ", '%s'", item->identifier);
-						is_first = FALSE;
+				RNA_property_enum_items(C, ptr, prop, &item, NULL, &free);
+				if (item) {
+					short is_first = TRUE;
+					for (; item->identifier; item++) {
+						if (item->identifier[0] && item->value & val) {
+							BLI_dynstr_appendf(dynstr, is_first ? "'%s'" : ", '%s'", item->identifier);
+							is_first = FALSE;
+						}
 					}
+
+					if (free) {
+						MEM_freeN(item);
+					}
 				}
 
-				if (free) {
-					MEM_freeN(item);
-				}
+				BLI_dynstr_append(dynstr, "}");
 			}
-
-			BLI_dynstr_append(dynstr, "}");
+			else {
+				/* annoying exception, don't confuse with dictionary syntax above: {} */
+				BLI_dynstr_append(dynstr, "set()");
+			}
 		}
 		else if (RNA_property_enum_identifier(C, ptr, prop, val, &identifier)) {
 			BLI_dynstr_appendf(dynstr, "'%s'", identifier);




More information about the Bf-blender-cvs mailing list