From 118d86aa73f7113487fda5230a9f932001405312 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 27 Feb 2014 18:29:10 +1100 Subject: UI: avoid for divide by zero for icon buttons (no need to clip text) --- source/blender/editors/interface/interface_widgets.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 80e6cb9c8a4..b4aeef7b01b 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; -- cgit v1.2.3