diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-04-09 08:39:47 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-04-09 08:39:47 +0400 |
commit | 9a6a791ff0c9b32f66831f5e09d7c283ac309b95 (patch) | |
tree | 0777f6caf5134d5d3e3babf7757340cb06d83686 /source/blender/makesrna/intern/makesrna.c | |
parent | b7113002dbea417617e3ef655d42732ade16577e (diff) |
fix [#30865] Crash when browsing last operators in outliner (or by Python API)
Operator descriptions can be NULL pointers,
fix this by making use of PROP_NEVER_NULL flag, when its not set, generated string funcs will test for NULL.
Diffstat (limited to 'source/blender/makesrna/intern/makesrna.c')
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 02917f1bce8..87f00dc835d 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -539,6 +539,14 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr "BLI_strncpy" : "BLI_strncpy_utf8"; rna_print_data_get(f, dp); + + if (!(prop->flag & PROP_NEVER_NULL)) { + fprintf(f, " if (data->%s == NULL) {\n", dp->dnaname); + fprintf(f, " *value = '\\0';\n"); + fprintf(f, " return;\n"); + fprintf(f, " }\n"); + } + if (sprop->maxlength) fprintf(f, " %s(value, data->%s, %d);\n", string_copy_func, dp->dnaname, sprop->maxlength); else @@ -781,6 +789,13 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr "BLI_strncpy" : "BLI_strncpy_utf8"; rna_print_data_get(f, dp); + + if (!(prop->flag & PROP_NEVER_NULL)) { + fprintf(f, " if (data->%s == NULL) {\n", dp->dnaname); + fprintf(f, " return;\n"); + fprintf(f, " }\n"); + } + if (sprop->maxlength) fprintf(f, " %s(data->%s, value, %d);\n", string_copy_func, dp->dnaname, sprop->maxlength); else @@ -956,6 +971,9 @@ static char *rna_def_property_length_func(FILE *f, StructRNA *srna, PropertyRNA } else { rna_print_data_get(f, dp); + if (!(prop->flag & PROP_NEVER_NULL)) { + fprintf(f, " if (data->%s == NULL) return 0;\n", dp->dnaname); + } fprintf(f, " return strlen(data->%s);\n", dp->dnaname); } fprintf(f, "}\n\n"); |