diff options
author | Alexander Gavriliuk <alexandrgproductengine@lindenlab.com> | 2024-03-08 13:25:43 +0100 |
---|---|---|
committer | Guru <alexandrgproductengine@lindenlab.com> | 2024-03-10 00:10:16 +0100 |
commit | 1781e2d17b777e32e9b51e5a901c1295db80a4d8 (patch) | |
tree | 720c3d9e2808b65fe58378022090bffbea91bbff /indra/llui/llviewmodel.cpp | |
parent | 636bf6cadec903d894c36db992f1ab17fb8e6796 (diff) |
viewer#944 Make 'Debug Unicode' feature available for all LLViews
Diffstat (limited to 'indra/llui/llviewmodel.cpp')
-rw-r--r-- | indra/llui/llviewmodel.cpp | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/indra/llui/llviewmodel.cpp b/indra/llui/llviewmodel.cpp index a400eb70c0..41082a2848 100644 --- a/indra/llui/llviewmodel.cpp +++ b/indra/llui/llviewmodel.cpp @@ -81,7 +81,7 @@ void LLTextViewModel::setValue(const LLSD& value) { // approximate LLSD storage usage LLViewModel::setValue(value); - mDisplay = utf8str_to_wstring(value.asString()); + mDisplay = utf8str_to_wstring(mStringValue = value.asString()); // mDisplay and mValue agree mUpdateFromDisplay = false; @@ -101,23 +101,34 @@ void LLTextViewModel::setDisplay(const LLWString& value) mUpdateFromDisplay = true; } -LLSD LLTextViewModel::getValue() const +inline void updateFromDisplayIfNeeded(const LLTextViewModel* model) { - // Has anyone called setDisplay() since the last setValue()? If so, have - // to convert mDisplay back to UTF8. - if (mUpdateFromDisplay) + // Has anyone called setDisplay() since the last setValue()? + // If so, have to convert mDisplay back to UTF8. + if (model->mUpdateFromDisplay) { - // The fact that we're lazily updating fields in this object should be - // transparent to clients, which is why this method is left - // conventionally const. Nor do we particularly want to make these - // members mutable. Just cast away constness in this one place. - LLTextViewModel* nthis = const_cast<LLTextViewModel*>(this); + // The fact that we're lazily updating fields + // in this object should be transparent to clients, + // which is why this method is left conventionally const. + // Nor do we particularly want to make these members mutable. + // Just cast away constness in this one place. + LLTextViewModel* nthis = const_cast<LLTextViewModel*>(model); nthis->mUpdateFromDisplay = false; - nthis->mValue = wstring_to_utf8str(mDisplay); + nthis->mValue = nthis->mStringValue = wstring_to_utf8str(model->mDisplay); } - return LLViewModel::getValue(); } +LLSD LLTextViewModel::getValue() const +{ + updateFromDisplayIfNeeded(this); + return mValue; +} + +const std::string& LLTextViewModel::getStringValue() const +{ + updateFromDisplayIfNeeded(this); + return mStringValue; +} //////////////////////////////////////////////////////////////////////////// |