From f452c01915be011814d92dcc1a398f450b6ce9c2 Mon Sep 17 00:00:00 2001 From: richard Date: Thu, 17 Dec 2009 09:54:44 -0800 Subject: EXT-3087 - Crash when avatar icon truncated in interactive notifications reviewed by Mani --- indra/llui/lltextbase.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indra/llui/lltextbase.cpp') diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 1f120a1483..6c983fd92e 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -1138,6 +1138,8 @@ void LLTextBase::reflow(S32 start_index) line_height = llmax(line_height, segment_height); remaining_pixels -= segment_width; + // getNumChars() and getDimensions() should return consistent results + llassert_always(remaining_pixels >= 0); seg_offset += character_count; S32 last_segment_char_on_line = segment->getStart() + seg_offset; @@ -2464,6 +2466,12 @@ S32 LLNormalTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 lin { LLWString text = mEditor.getWText(); + LLUIImagePtr image = mStyle->getImage(); + if( image.notNull()) + { + num_pixels -= image->getWidth(); + } + // search for newline and if found, truncate there S32 last_char = mStart + segment_offset; for (; last_char != mEnd; ++last_char) -- cgit v1.2.3 From 9abe9bf5dffeade7adbae99b3d5f7c9030fba0e5 Mon Sep 17 00:00:00 2001 From: richard Date: Thu, 17 Dec 2009 11:44:01 -0800 Subject: clamp instead of assert when running out of room during reflow --- indra/llui/lltextbase.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/llui/lltextbase.cpp') diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 6c983fd92e..4426bf5ddd 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -1137,6 +1137,10 @@ void LLTextBase::reflow(S32 start_index) // grow line height as necessary based on reported height of this segment line_height = llmax(line_height, segment_height); remaining_pixels -= segment_width; + if (remaining_pixels < 0) + { + remaining_pixels = 0; + } // getNumChars() and getDimensions() should return consistent results llassert_always(remaining_pixels >= 0); -- cgit v1.2.3 From 49a037048ca733f0a84186e3cfb0f6f0b0b55df8 Mon Sep 17 00:00:00 2001 From: richard Date: Thu, 17 Dec 2009 11:44:37 -0800 Subject: oops, forgot to remove assert --- indra/llui/lltextbase.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/llui/lltextbase.cpp') diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 4426bf5ddd..cb0907a771 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -1139,11 +1139,10 @@ void LLTextBase::reflow(S32 start_index) remaining_pixels -= segment_width; if (remaining_pixels < 0) { + // getNumChars() and getDimensions() should return consistent results remaining_pixels = 0; } - // getNumChars() and getDimensions() should return consistent results - llassert_always(remaining_pixels >= 0); seg_offset += character_count; S32 last_segment_char_on_line = segment->getStart() + seg_offset; -- cgit v1.2.3