[Bf-blender-cvs] [118d86a] master: UI: avoid for divide by zero for icon buttons (no need to clip text)

Campbell Barton noreply at git.blender.org
Thu Feb 27 08:30:52 CET 2014


Commit: 118d86aa73f7113487fda5230a9f932001405312
Author: Campbell Barton
Date:   Thu Feb 27 18:29:10 2014 +1100
https://developer.blender.org/rB118d86aa73f7113487fda5230a9f932001405312

UI: avoid for divide by zero for icon buttons (no need to clip text)

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

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

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

diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 80e6cb9..b4aeef7 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -956,7 +956,7 @@ static void ui_text_clip_left(uiFontStyle *fstyle, uiBut *but, const rcti *rect)
 	but->ofs = 0;
 	but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr, sizeof(but->drawstr));
 
-	if (but->strwidth > okwidth) {
+	if ((okwidth > 0.0f) && (but->strwidth > okwidth)) {
 		float strwidth;
 		but->ofs = BLF_width_to_rstrlen(fstyle->uifont_id, but->drawstr,
 		                                sizeof(but->drawstr), okwidth, &strwidth);
@@ -1009,7 +1009,7 @@ static float ui_text_clip_middle_ex(uiFontStyle *fstyle, char *str, const float
 
 	strwidth = BLF_width(fstyle->uifont_id, str, max_len);
 
-	if (strwidth > okwidth) {
+	if ((okwidth > 0.0f) && (strwidth > okwidth)) {
 		/* utf8 ellipsis '...', some compilers complain */
 		const char sep[] = {0xe2, 0x80, 0xa6, 0x0};
 		const int sep_len = sizeof(sep) - 1;




More information about the Bf-blender-cvs mailing list