summaryrefslogtreecommitdiff
path: root/indra/llui/lltextbase.cpp
diff options
context:
space:
mode:
authorAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2026-03-16 21:59:56 +0200
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2026-03-17 22:47:23 +0200
commita5a6cfb995e9baed20980a67dfb89cacc6fe053c (patch)
tree1e420851cc4f1b46892e669cc0a19a28f5486a3e /indra/llui/lltextbase.cpp
parent75a98ba9aa932d76227d50e739ae4beb722a3cc6 (diff)
viewer-private#540 Fix freeze when opening large profiles #1
Diffstat (limited to 'indra/llui/lltextbase.cpp')
-rw-r--r--indra/llui/lltextbase.cpp41
1 files changed, 35 insertions, 6 deletions
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 24ae5c09e9..b53b5bd7a4 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -222,6 +222,7 @@ LLTextBase::LLTextBase(const LLTextBase::Params &p)
mTrustedContent(p.trusted_content),
mAlwaysShowIcons(p.always_show_icons),
mTrackEnd( p.track_end ),
+ mTrackValueChange(true),
mScrollIndex(-1),
mSelectionStart( 0 ),
mSelectionEnd( 0 ),
@@ -964,7 +965,10 @@ void LLTextBase::drawText()
S32 LLTextBase::insertStringNoUndo(S32 pos, const LLWString &wstr, LLTextBase::segment_vec_t* segments )
{
- beforeValueChange();
+ if (mTrackValueChange)
+ {
+ beforeValueChange();
+ }
S32 old_len = getLength(); // length() returns character length
S32 insert_len = static_cast<S32>(wstr.length());
@@ -1092,7 +1096,10 @@ S32 LLTextBase::insertStringNoUndo(S32 pos, const LLWString &wstr, LLTextBase::s
insert_len = getLength() - old_len;
}
- onValueChange(pos, pos + insert_len);
+ if (mTrackValueChange)
+ {
+ onValueChange(pos, pos + insert_len);
+ }
needsReflow(pos);
return insert_len;
@@ -1108,7 +1115,10 @@ S32 LLTextBase::removeStringNoUndo(S32 pos, S32 length)
// Clamp length to not go past the end of the text
length = std::min(length, text_length - pos);
- beforeValueChange();
+ if (mTrackValueChange)
+ {
+ beforeValueChange();
+ }
segment_set_t::iterator seg_iter = getSegIterContaining(pos);
while(seg_iter != mSegments.end())
{
@@ -1159,7 +1169,10 @@ S32 LLTextBase::removeStringNoUndo(S32 pos, S32 length)
// recreate default segment in case we erased everything
createDefaultSegment();
- onValueChange(pos, pos);
+ if (mTrackValueChange)
+ {
+ onValueChange(pos, pos);
+ }
needsReflow(pos);
return -length; // This will be wrong if someone calls removeStringNoUndo with an excessive length
@@ -1167,7 +1180,10 @@ S32 LLTextBase::removeStringNoUndo(S32 pos, S32 length)
S32 LLTextBase::overwriteCharNoUndo(S32 pos, llwchar wc)
{
- beforeValueChange();
+ if (mTrackValueChange)
+ {
+ beforeValueChange();
+ }
if (pos > (S32)getLength())
{
@@ -1175,7 +1191,10 @@ S32 LLTextBase::overwriteCharNoUndo(S32 pos, llwchar wc)
}
getViewModel()->getEditableDisplay()[pos] = wc;
- onValueChange(pos, pos + 1);
+ if (mTrackValueChange)
+ {
+ onValueChange(pos, pos + 1);
+ }
needsReflow(pos);
return 1;
@@ -2330,6 +2349,10 @@ void LLTextBase::createUrlContextMenu(S32 x, S32 y, const std::string &in_url)
void LLTextBase::setText(const LLStringExplicit &utf8str, const LLStyle::Params& input_params)
{
+ beforeValueChange();
+ // Can insert a lot of different segments, don't want to spam events.
+ mTrackValueChange = false;
+
// clear out the existing text and segments
getViewModel()->setDisplay(LLWStringUtil::null);
@@ -2350,6 +2373,7 @@ void LLTextBase::setText(const LLStringExplicit &utf8str, const LLStyle::Params&
startOfDoc();
}
+ mTrackValueChange = true;
onValueChange(0, getLength());
}
@@ -2553,6 +2577,10 @@ void LLTextBase::copyContents(const LLTextBase* source)
beforeValueChange();
deselect();
+ // Can insert a lot of different segments, don't want to spam events.
+ // Do one full length onValueChange() at the end of this function.
+ mTrackValueChange = false;
+
mSegments.clear();
for (const LLTextSegmentPtr& segp : source->mSegments)
{
@@ -2567,6 +2595,7 @@ void LLTextBase::copyContents(const LLTextBase* source)
getViewModel()->setDisplay(source->getViewModel()->getDisplay());
+ mTrackValueChange = true;
onValueChange(0, getLength());
needsReflow();
}