From 1eee67b68de88e1f2a7e0f1d55b3e993e819a419 Mon Sep 17 00:00:00 2001 From: thickbrick Date: Thu, 7 Oct 2010 18:20:33 +0200 Subject: Fix bug #611: Context menu spell checker suggestions broken. This fixes a confusion between word end position and word length, causing an empty spell checker suggestion list, or possibly crashes. I caused this bug in f5006e8a2f34afa390f0bbcf0f6af15218cf4105. Oops. --- linden/indra/llui/lllineeditor.cpp | 10 +++++----- linden/indra/llui/lltexteditor.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp index 4581ec7..e73b287 100644 --- a/linden/indra/llui/lllineeditor.cpp +++ b/linden/indra/llui/lllineeditor.cpp @@ -779,7 +779,7 @@ BOOL LLLineEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) //setCursorAtLocalPos( x); S32 wordStart = 0; - S32 wordEnd = 0; + S32 wordLen = 0; S32 pos = calculateCursorFromMouse(x); LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get(); @@ -808,11 +808,11 @@ BOOL LLLineEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) if (!mReadOnly && mSpellCheckable) { // search for word matches - bool is_word_part = getWordBoundriesAt(pos, &wordStart, &wordEnd); + bool is_word_part = getWordBoundriesAt(pos, &wordStart, &wordLen); if (is_word_part) { const LLWString& text = mText.getWString(); - std::string selectedWord(std::string(text.begin(), text.end()).substr(wordStart,wordEnd-wordStart)); + std::string selectedWord(std::string(text.begin(), text.end()).substr(wordStart,wordLen)); if (!glggHunSpell->isSpelledRight(selectedWord)) { @@ -824,7 +824,7 @@ BOOL LLLineEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) SpellMenuBind * tempStruct = new SpellMenuBind; tempStruct->origin = this; tempStruct->word = suggs[i]; - tempStruct->wordPositionEnd = wordEnd; + tempStruct->wordPositionEnd = wordStart + wordLen; tempStruct->wordPositionStart=wordStart; LLMenuItemCallGL * suggMenuItem = new LLMenuItemCallGL( tempStruct->word, spell_correct, NULL, tempStruct); @@ -836,7 +836,7 @@ BOOL LLLineEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) SpellMenuBind * tempStruct = new SpellMenuBind; tempStruct->origin = this; tempStruct->word = selectedWord; - tempStruct->wordPositionEnd = wordEnd; + tempStruct->wordPositionEnd = wordStart + wordLen; tempStruct->wordPositionStart=wordStart; LLMenuItemCallGL * suggMenuItem = new LLMenuItemCallGL( "Add Word", spell_add, NULL, tempStruct); diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp index 369eb1e..fdf8bcf 100644 --- a/linden/indra/llui/lltexteditor.cpp +++ b/linden/indra/llui/lltexteditor.cpp @@ -1502,7 +1502,7 @@ BOOL LLTextEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) //setCursorAtLocalPos( x, y, TRUE ); S32 wordStart = 0; - S32 wordEnd = 0; + S32 wordLen = 0; S32 pos = getCursorPosFromLocalCoord(x,y,TRUE); LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get(); @@ -1526,11 +1526,11 @@ BOOL LLTextEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) menu->setItemVisible("Spelsep", !mReadOnly && mSpellCheckable); if (!mReadOnly && mSpellCheckable) { - bool is_word_part = getWordBoundriesAt(pos, &wordStart, &wordEnd); + bool is_word_part = getWordBoundriesAt(pos, &wordStart, &wordLen); if (is_word_part) { const LLWString &text = mWText; - std::string selectedWord(std::string(text.begin(), text.end()).substr(wordStart,wordEnd-wordStart)); + std::string selectedWord(std::string(text.begin(), text.end()).substr(wordStart,wordLen)); if (!glggHunSpell->isSpelledRight(selectedWord)) { @@ -1542,7 +1542,7 @@ BOOL LLTextEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) SpellMenuBind * tempStruct = new SpellMenuBind; tempStruct->origin = this; tempStruct->word = suggs[i]; - tempStruct->wordPositionEnd = wordEnd; + tempStruct->wordPositionEnd = wordStart + wordLen; tempStruct->wordPositionStart=wordStart; tempStruct->wordY=y; LLMenuItemCallGL * suggMenuItem = new LLMenuItemCallGL( @@ -1554,7 +1554,7 @@ BOOL LLTextEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) SpellMenuBind * tempStruct = new SpellMenuBind; tempStruct->origin = this; tempStruct->word = selectedWord; - tempStruct->wordPositionEnd = wordEnd; + tempStruct->wordPositionEnd = wordStart + wordLen; tempStruct->wordPositionStart=wordStart; tempStruct->wordY=y; LLMenuItemCallGL * suggMenuItem = new LLMenuItemCallGL( -- cgit v1.1