From 12762053e5aff372a9f8d473c71aa81e805bb474 Mon Sep 17 00:00:00 2001 From: Martin Reddy Date: Tue, 22 Sep 2009 18:00:16 +0000 Subject: EXT-944 EXT-1026: converted the LLUrlRegistry::findUrl() method to work on an LLWString instead of a std::string, so that we don't have to worry about character offsets for variable-length-encoded UTF-8 strings. This was causing crashes whenever we would try to show a textbox with a URL and foreign characters (> 1 byte chars). Damn, I suck! --- indra/llui/lltextbox.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llui/lltextbox.cpp') diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index 810626268f..3cde42d75c 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -297,7 +297,7 @@ LLWString LLTextBox::getWrappedText(const LLStringExplicit& in_text, F32 max_wid // find the next Url in the text string LLUrlMatch match; - while ( LLUrlRegistry::instance().findUrl(wstring_to_utf8str(wtext), match)) + while ( LLUrlRegistry::instance().findUrl(wtext, match)) { S32 start = match.getStart(); S32 end = match.getEnd() + 1; @@ -573,7 +573,7 @@ void LLTextBox::updateDisplayTextAndSegments() LLWString text = mText.getWString(); // find the next Url in the text string - while ( LLUrlRegistry::instance().findUrl(wstring_to_utf8str(text), match, + while ( LLUrlRegistry::instance().findUrl(text, match, boost::bind(&LLTextBox::onUrlLabelUpdated, this, _1, _2)) ) { // work out the char offset for the start/end of the url -- cgit v1.2.3 From 47abd559082f6023dcdfadd2ec740195b1d07990 Mon Sep 17 00:00:00 2001 From: Martin Reddy Date: Wed, 23 Sep 2009 13:57:06 +0000 Subject: EXT-944 EXT-1026: reverting my previous fix for these crashes. This didn't work on Windows because wchar_t is 2 bytes on that platform, not 4 bytes (whereas llwchar is 4 bytes everywhere). Boost's regex methods need to work on wchar_t, but I believe that using a UTF-16 string would still be prone to crashing on Windows as UTF-16 is still a variable-length encoding. Besides, trying to compile a UTF-16 solution generates weird link errors. Instead, I'm going to fix this problem a different way. And I'm starting by reverting the previous attempt. Thanks Win32. --- indra/llui/lltextbox.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llui/lltextbox.cpp') diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index 3cde42d75c..810626268f 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -297,7 +297,7 @@ LLWString LLTextBox::getWrappedText(const LLStringExplicit& in_text, F32 max_wid // find the next Url in the text string LLUrlMatch match; - while ( LLUrlRegistry::instance().findUrl(wtext, match)) + while ( LLUrlRegistry::instance().findUrl(wstring_to_utf8str(wtext), match)) { S32 start = match.getStart(); S32 end = match.getEnd() + 1; @@ -573,7 +573,7 @@ void LLTextBox::updateDisplayTextAndSegments() LLWString text = mText.getWString(); // find the next Url in the text string - while ( LLUrlRegistry::instance().findUrl(text, match, + while ( LLUrlRegistry::instance().findUrl(wstring_to_utf8str(text), match, boost::bind(&LLTextBox::onUrlLabelUpdated, this, _1, _2)) ) { // work out the char offset for the start/end of the url -- cgit v1.2.3 From a0e44e3dd3e09d24ac2d329aa87f4bd34a59f301 Mon Sep 17 00:00:00 2001 From: Martin Reddy Date: Wed, 23 Sep 2009 14:56:02 +0000 Subject: EXT-944 EXT-1026: re-fixing these crashing bugs by making sure that we don't use character offsets when mixing utf8 and wide strings. Internal JIRAs: DEV-40127 DEV-39966. --- indra/llui/lltextbox.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'indra/llui/lltextbox.cpp') diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index 810626268f..9de474a4f5 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -299,8 +299,9 @@ LLWString LLTextBox::getWrappedText(const LLStringExplicit& in_text, F32 max_wid LLUrlMatch match; while ( LLUrlRegistry::instance().findUrl(wstring_to_utf8str(wtext), match)) { - S32 start = match.getStart(); - S32 end = match.getEnd() + 1; + LLWString wurl = utf8str_to_wstring(match.getUrl()); + S32 start = wtext.find(wurl); + S32 end = start + wurl.size(); // perform word wrap on the text before the Url final_wtext += wrapText(wtext.substr(0, start), hoffset, line_num, max_width); @@ -577,13 +578,17 @@ void LLTextBox::updateDisplayTextAndSegments() boost::bind(&LLTextBox::onUrlLabelUpdated, this, _1, _2)) ) { // work out the char offset for the start/end of the url + LLWString wurl = utf8str_to_wstring(match.getUrl()); + S32 url_start = text.find(wurl); + S32 url_end = url_start + wurl.size() - 1; + S32 seg_start = mDisplayText.size(); - S32 start = seg_start + match.getStart(); - end = start + match.getLabel().size(); + S32 start = seg_start + url_start; + S32 end = start + match.getLabel().size(); // create a segment for the text before the Url mSegments.insert(new LLNormalTextSegment(new LLStyle(), seg_start, start, *this)); - mDisplayText += text.substr(0, match.getStart()); + mDisplayText += text.substr(0, url_start); // create a segment for the Url text LLStyleSP html(new LLStyle); @@ -599,7 +604,7 @@ void LLTextBox::updateDisplayTextAndSegments() mDisplayText += utf8str_to_wstring(match.getLabel()); // move on to the rest of the text after the Url - text = text.substr(match.getEnd()+1, text.size() - match.getEnd()); + text = text.substr(url_end+1, text.size() - url_end); } // output a segment for the remaining text -- cgit v1.2.3 From afcdda2e361855e2a02eb39c8cec080019ac769f Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Wed, 23 Sep 2009 22:25:18 +0000 Subject: EXT-904 Build tools does not show tooltips on any checkbox EXT-877 There is no tooltip with a date for Time indicator in Nav bar EXT-860 Crosshairs and "Press ESC to..." warning are dislocated in mouselook mode when UI Size is not exactly set to 1.00 (Menu Me -> Preferences-> Graphics) EXT-783 Script editor inserts text twice when using the editors paste, or choosing LSL elements from the pull-down list. EXT-764 mis-location of cursor in edit script panel (fixed cursor width) EXT-658 Inventory window's "Fetched Items" needs spacing reviewed by James --- indra/llui/lltextbox.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'indra/llui/lltextbox.cpp') diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index 9de474a4f5..d6ae9e063e 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -161,7 +161,12 @@ BOOL LLTextBox::handleHover(S32 x, S32 y, MASK mask) BOOL LLTextBox::handleToolTip(S32 x, S32 y, std::string& msg, LLRect& sticky_rect_screen) { - return handleToolTipForUrl(this, x, y, msg, sticky_rect_screen); + if (handleToolTipForUrl(this, x, y, msg, sticky_rect_screen)) + { + return TRUE; + } + + return LLUICtrl::handleToolTip(x, y, msg, sticky_rect_screen); } void LLTextBox::setText(const LLStringExplicit& text) -- cgit v1.2.3 From 7b2737e0e14f815e69da7114dda693cdaea2c341 Mon Sep 17 00:00:00 2001 From: Martin Reddy Date: Thu, 24 Sep 2009 10:41:08 +0000 Subject: EXT-944 EXT-1026: cleaning up my quick fix for these issues. I've now added an explicit LLUrlRegistry::findUrl() method for LLWStrings. This deals with correcting the start/end range for the url appropriately. Now the API can be used without worrying about utf8/utf32 character offset issues. Internal JIRAs: DEV-40127 DEV-39966. --- indra/llui/lltextbox.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'indra/llui/lltextbox.cpp') diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index d6ae9e063e..132bef0296 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -302,11 +302,10 @@ LLWString LLTextBox::getWrappedText(const LLStringExplicit& in_text, F32 max_wid // find the next Url in the text string LLUrlMatch match; - while ( LLUrlRegistry::instance().findUrl(wstring_to_utf8str(wtext), match)) + while ( LLUrlRegistry::instance().findUrl(wtext, match)) { - LLWString wurl = utf8str_to_wstring(match.getUrl()); - S32 start = wtext.find(wurl); - S32 end = start + wurl.size(); + S32 start = match.getStart(); + S32 end = match.getEnd() + 1; // perform word wrap on the text before the Url final_wtext += wrapText(wtext.substr(0, start), hoffset, line_num, max_width); @@ -579,14 +578,14 @@ void LLTextBox::updateDisplayTextAndSegments() LLWString text = mText.getWString(); // find the next Url in the text string - while ( LLUrlRegistry::instance().findUrl(wstring_to_utf8str(text), match, + while ( LLUrlRegistry::instance().findUrl(text, match, boost::bind(&LLTextBox::onUrlLabelUpdated, this, _1, _2)) ) { // work out the char offset for the start/end of the url - LLWString wurl = utf8str_to_wstring(match.getUrl()); - S32 url_start = text.find(wurl); - S32 url_end = url_start + wurl.size() - 1; + S32 url_start = match.getStart(); + S32 url_end = match.getEnd(); + // and the char offset for the label in the display text S32 seg_start = mDisplayText.size(); S32 start = seg_start + url_start; S32 end = start + match.getLabel().size(); -- cgit v1.2.3