From f711c44b8dc8e10b37b387cefabb7236ae77decd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 30 Oct 2018 16:11:39 +1100 Subject: PyAPI: Support for 'None' string args from Python This is needed because some RNA functions differentiate a NULL 'char *' argument from an empty string. Previously a NULL argument could be passed when the C definition defined the default as NULL and the argument wasn't passed which is a fairly hidden way of handling things. Now strings use `PROP_NEVER_NULL` by default which can be cleared for function arguments that allow None -> NULL. --- source/blender/makesrna/intern/rna_define.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/makesrna/intern/rna_define.c') diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 42db80c83c0..6724315f376 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -1165,7 +1165,8 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier case PROP_STRING: { StringPropertyRNA *sprop = (StringPropertyRNA *)prop; - + /* By default don't allow NULL string args, callers may clear. */ + RNA_def_property_flag(prop, PROP_NEVER_NULL); sprop->defaultvalue = ""; break; } -- cgit v1.2.3