diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-01-13 17:29:57 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-01-13 17:29:57 +0300 |
commit | e2054b291c35cfd9b4e020b584ec465007ecd189 (patch) | |
tree | 220ccdbf9d5d8cd9af7fe816a795dad529892fa1 /source/blender/makesrna/intern/makesrna.c | |
parent | d4fa68e448a1808c6ca5628840a8940aefe263b3 (diff) |
bugfix [#25588] Not work fcurve.keyframe_points.add
The problem was flag-enums were being treated as regular enums, a default value of 0 was using the first enum item, whereas with flag enums we want to be able to use 0 as a default value to specify all flags are off.
Diffstat (limited to 'source/blender/makesrna/intern/makesrna.c')
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index cf1b14d5e62..94b075c20c0 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -2023,7 +2023,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr switch(prop->type) { case PROP_ENUM: { EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop; - int i, defaultfound= 0; + int i, defaultfound= 0, totflag= 0; if(eprop->item) { fprintf(f, "static EnumPropertyItem rna_%s%s_%s_items[%d] = {\n\t", srna->identifier, strnest, prop->identifier, eprop->totitem+1); @@ -2035,16 +2035,31 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr rna_print_c_string(f, eprop->item[i].name); fprintf(f, ", "); rna_print_c_string(f, eprop->item[i].description); fprintf(f, "},\n\t"); - if(eprop->item[i].identifier[0]) - if(eprop->defaultvalue == eprop->item[i].value) - defaultfound= 1; + if(eprop->item[i].identifier[0]) { + if(prop->flag & PROP_ENUM_FLAG) { + totflag |= eprop->item[i].value; + } + else { + if(eprop->defaultvalue == eprop->item[i].value) { + defaultfound= 1; + } + } + } } fprintf(f, "{0, NULL, 0, NULL, NULL}\n};\n\n"); - if(!defaultfound) { - fprintf(stderr, "rna_generate_structs: %s%s.%s, enum default is not in items.\n", srna->identifier, errnest, prop->identifier); - DefRNA.error= 1; + if(prop->flag & PROP_ENUM_FLAG) { + if(eprop->defaultvalue & ~totflag) { + fprintf(stderr, "rna_generate_structs: %s%s.%s, enum default includes unused bits (%d).\n", srna->identifier, errnest, prop->identifier, eprop->defaultvalue & ~totflag); + DefRNA.error= 1; + } + } + else { + if(!defaultfound) { + fprintf(stderr, "rna_generate_structs: %s%s.%s, enum default is not in items.\n", srna->identifier, errnest, prop->identifier); + DefRNA.error= 1; + } } } else { |