[Bf-blender-cvs] [c2d37929b4a] master: Fix T69633: weird behavior of operator_menu_enum tooltips.

Alexander Gavrilov noreply at git.blender.org
Mon Sep 9 20:14:18 CEST 2019


Commit: c2d37929b4aaaef87bad1d2e90cc76d0c4765e8d
Author: Alexander Gavrilov
Date:   Mon Sep 9 21:12:47 2019 +0300
Branches: master
https://developer.blender.org/rBc2d37929b4aaaef87bad1d2e90cc76d0c4765e8d

Fix T69633: weird behavior of operator_menu_enum tooltips.

For operators with dynamic tooltips the tooltip calculation is
deferred until the moment it is actually shown for performance
reasons, with the tooltip field left blank for the time being.
Enum menu code shouldn't jump in and assign a tooltip either.

The menu button itself can't show a dynamic tooltip because it
does not actually call the operator, and has no reference to it.

As a side change, allow returning None from the python callback
as the most natural way to fall back to the default tooltip.

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

M	source/blender/editors/interface/interface_layout.c
M	source/blender/makesrna/intern/rna_wm_api.c

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

diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index e7b6282d2e6..6a707b56f36 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -1110,7 +1110,8 @@ void UI_context_active_but_prop_get_filebrowser(const bContext *C,
 static void ui_but_tip_from_enum_item(uiBut *but, const EnumPropertyItem *item)
 {
   if (but->tip == NULL || but->tip[0] == '\0') {
-    if (item->description && item->description[0]) {
+    if (item->description && item->description[0] &&
+        !(but->optype && but->optype->get_description)) {
       but->tip = item->description;
     }
   }
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index 650d410091e..b705f98a3de 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -963,6 +963,7 @@ void RNA_api_operator(StructRNA *srna)
   RNA_def_function_ui_description(func, "Compute a description string that depends on parameters");
   RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL);
   parm = RNA_def_string(func, "result", NULL, 4096, "result", "");
+  RNA_def_parameter_clear_flags(parm, PROP_NEVER_NULL, 0);
   RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
   RNA_def_function_output(func, parm);
   parm = RNA_def_pointer(func, "context", "Context", "", "");



More information about the Bf-blender-cvs mailing list