From 9458470c79d6cbca28e23d6b732c76c41b0ccef1 Mon Sep 17 00:00:00 2001 From: Nicky Date: Sat, 4 Feb 2012 03:34:31 +0100 Subject: [PATCH] FIRE-4885; when pasting large amounts of text truncate the buffer first instead of doing it over and over in LLTextbase::insert*. --- indra/llui/lltexteditor.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 9132f5a49e..13657c3d49 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -1566,6 +1566,13 @@ void LLTextEditor::pasteHelper(bool is_primary) } } + // FIRE-4885; Truncate the text to mMaxTextByteLength. + // Can safely do this here, otherwise it would done in '::insert', which is bad for performance, as ::insert is called once per line. + // In theory text already in the editor should be taken into account too, but then text that would be overwriten would have to be considered aswell. + if ( wstring_utf8_length(clean_string) > mMaxTextByteLength ) + clean_string = utf8str_to_wstring( utf8str_truncate( wstring_to_utf8str(clean_string), mMaxTextByteLength ) ); + // + // Insert the new text into the existing text. //paste text with linebreaks.