[Bf-blender-cvs] [0bd61227c24] blender2.8: Tool System: display tooltip generation error

Campbell Barton noreply at git.blender.org
Wed Nov 7 04:44:40 CET 2018


Commit: 0bd61227c246a488bd06b76fba213c44448379c7
Author: Campbell Barton
Date:   Wed Nov 7 14:40:44 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB0bd61227c246a488bd06b76fba213c44448379c7

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.

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

M	source/blender/editors/interface/interface_region_tooltip.c

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

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;
+			}
 		}
 	}



More information about the Bf-blender-cvs mailing list