diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-07 06:40:44 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-07 06:40:44 +0300 |
commit | 0bd61227c246a488bd06b76fba213c44448379c7 (patch) | |
tree | a762ee442466760d8a8551b528b09a1952728242 /source/blender/editors/interface | |
parent | 4e11b6f0374226fc05519ce99229261ab703406e (diff) |
Tool System: display tooltip generation error
While this shouldn't ever happen there have been reports
of tooltip creation failure - keep this until the issue is resolved.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface_region_tooltip.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index e8a73eaf56d..c54ee1378e7 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -420,22 +420,32 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is tool_name); char *expr_result = NULL; + bool is_error = false; if (BPY_execute_string_as_string(C, expr_imports, expr, true, &expr_result)) { - if (!STREQ(expr_result, ".")) { - uiTooltipField *field = text_field_add( - data, &(uiTooltipFormat){ - .style = UI_TIP_STYLE_NORMAL, - .color_id = UI_TIP_LC_MAIN, - .is_pad = true, - }); - field->text = expr_result; - } - else { + if (STREQ(expr_result, ".")) { MEM_freeN(expr_result); + expr_result = NULL; } } else { - BLI_assert(0); + /* Note, this is an exceptional case, we could even remove it + * however there have been reports of tooltips failing, so keep it for now. */ + expr_result = BLI_strdup("Internal error!"); + is_error = true; + } + + if (expr_result != NULL) { + uiTooltipField *field = text_field_add( + data, &(uiTooltipFormat){ + .style = UI_TIP_STYLE_NORMAL, + .color_id = UI_TIP_LC_MAIN, + .is_pad = true, + }); + field->text = expr_result; + + if (UNLIKELY(is_error)) { + field->format.color_id = UI_TIP_LC_ALERT; + } } } |