Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-03-20 11:52:39 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-20 11:52:39 +0400
commitc5f15da34e1d9e3e16f6afac2cac521cb63006a9 (patch)
tree6f48895899c25047648aa090d8e15ba83764eac5 /source/blender/makesrna/intern/rna_access.c
parent3b9b53d8761155d8919465627914a789f482915b (diff)
py/rna api - fix for an empty enum flag with no members being displayed as {}, now check for this case and display as set()
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r--source/blender/makesrna/intern/rna_access.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 2a14b951ae3..f2a37dec5d5 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -4698,27 +4698,33 @@ char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
if (RNA_property_flag(prop) & PROP_ENUM_FLAG) {
/* represent as a python set */
- EnumPropertyItem *item = NULL;
- int free;
-
- 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;
+ if (val) {
+ EnumPropertyItem *item = NULL;
+ int free;
+
+ 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;
+ }
}
- }
- 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);