[Bf-blender-cvs] [5234ced102e] master: RNA: support None text argument to UI functions

Campbell Barton noreply at git.blender.org
Tue Mar 12 06:32:06 CET 2019


Commit: 5234ced102e003d4239db82174dc90266d6f880a
Author: Campbell Barton
Date:   Tue Mar 12 16:27:17 2019 +1100
Branches: master
https://developer.blender.org/rB5234ced102e003d4239db82174dc90266d6f880a

RNA: support None text argument to UI functions

Without this there isn't a convenient way to write wrapper UI functions
that forward a text argument that optionally uses the default text.

===================================================================

M	source/blender/makesrna/intern/rna_ui_api.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index 973f92c6575..046e68a5738 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -452,8 +452,12 @@ static int rna_ui_get_enum_icon(bContext *C, PointerRNA *ptr, const char *propna
 
 static void api_ui_item_common_text(FunctionRNA *func)
 {
-	RNA_def_string(func, "text", NULL, 0, "", "Override automatic text of the item");
-	RNA_def_string(func, "text_ctxt", NULL, 0, "", "Override automatic translation context of the given text");
+	PropertyRNA *prop;
+
+	prop = RNA_def_string(func, "text", NULL, 0, "", "Override automatic text of the item");
+	RNA_def_property_clear_flag(prop, PROP_NEVER_NULL);
+	prop = RNA_def_string(func, "text_ctxt", NULL, 0, "", "Override automatic translation context of the given text");
+	RNA_def_property_clear_flag(prop, PROP_NEVER_NULL);
 	RNA_def_boolean(func, "translate", true, "", "Translate the given text, when UI translation is enabled");
 }



More information about the Bf-blender-cvs mailing list