From 6be58f1de21c276018aac9575fad81aa17a63ed2 Mon Sep 17 00:00:00 2001 From: thickbrick Date: Mon, 4 Oct 2010 00:11:18 +0200 Subject: Don't leak SpellMenuBind structs when destroying LLLineEditor/LLTextEditor objects. --- linden/indra/llui/lllineeditor.cpp | 67 ++++++++++++++++---------------------- linden/indra/llui/lltexteditor.cpp | 67 ++++++++++++++++---------------------- 2 files changed, 56 insertions(+), 78 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp index b3da7fd..4581ec7 100644 --- a/linden/indra/llui/lllineeditor.cpp +++ b/linden/indra/llui/lllineeditor.cpp @@ -231,38 +231,22 @@ LLLineEditor::LLLineEditor(const std::string& name, const LLRect& rect, menu->appendSeparator("Transep"); LLMenuGL* translatemenu = new LLMenuGL("Translate To"); translatemenu->setCanTearOff(FALSE); - SpellMenuBind* t=new SpellMenuBind;t->origin=this;t->word="en"; - translatemenu->append(new LLMenuItemCallGL("English", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="da"; - translatemenu->append(new LLMenuItemCallGL("Danish", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="de"; - translatemenu->append(new LLMenuItemCallGL("Deutsch(German)", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="es"; - translatemenu->append(new LLMenuItemCallGL("Spanish", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="fr"; - translatemenu->append(new LLMenuItemCallGL("French", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="it"; - translatemenu->append(new LLMenuItemCallGL("Italian", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="hu"; - translatemenu->append(new LLMenuItemCallGL("Hungarian", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="nl"; - translatemenu->append(new LLMenuItemCallGL("Dutch", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="pl"; - translatemenu->append(new LLMenuItemCallGL("Polish", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="pt"; - translatemenu->append(new LLMenuItemCallGL("Portugese", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="ru"; - translatemenu->append(new LLMenuItemCallGL("Russian", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="tr"; - translatemenu->append(new LLMenuItemCallGL("Turkish", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="uk"; - translatemenu->append(new LLMenuItemCallGL("Ukrainian", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="zh"; - translatemenu->append(new LLMenuItemCallGL("Chinese", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="ja"; - translatemenu->append(new LLMenuItemCallGL("Japanese", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="ko"; - translatemenu->append(new LLMenuItemCallGL("Korean", context_translate, context_enable_translate, t)); + translatemenu->append(new LLMenuItemCallGL("en", "English", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("da", "Danish", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("de", "Deutsch(German)", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("es", "Spanish", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("fr", "French", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("it", "Italian", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("hu", "Hungarian", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("nl", "Dutch", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("pl", "Polish", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("pt", "Portugese", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("ru", "Russian", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("tr", "Turkish", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("uk", "Ukrainian", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("zh", "Chinese", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("ja", "Japanese", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("ko", "Korean", context_translate, context_enable_translate, this)); menu->appendMenu(translatemenu); menu->appendSeparator("Spelsep"); @@ -555,15 +539,20 @@ void LLLineEditor::spell_correct(void* data) BOOL LLLineEditor::context_enable_translate(void* data) { - SpellMenuBind* t = (SpellMenuBind*)data; - return (t && t->origin && t->origin->canTranslate()); + LLLineEditor* line = (LLLineEditor*)data; + return line && line->canTranslate(); } void LLLineEditor::context_translate(void * data) { - SpellMenuBind* t = (SpellMenuBind*)data; - LLLineEditor* line = t->origin; - const std::string &toLang = t->word;//LLTranslate::getTranslateLanguage(); + LLLineEditor* line = (LLLineEditor*)data; + LLMenuGL* menu = line ? (LLMenuGL*)(line->mPopupMenuHandle.get()) : NULL; + LLMenuGL* translate_menu = menu ? menu->getChildMenuByName("Translate To", TRUE) : NULL; + if (!translate_menu) + { + return; + } + const std::string to_lang = translate_menu->getHighlightedItem()->getName(); bool has_text = false; S32 start, length; @@ -584,8 +573,8 @@ void LLLineEditor::context_translate(void * data) if (has_text) { std::string to_translate = wstring_to_utf8str(line->getWText().substr(start, length)); - LLHTTPClient::ResponderPtr result = LineChatTranslationReceiver::build(toLang, line, start, length); - LLTranslate::translateMessage(result,"", toLang, to_translate); + LLHTTPClient::ResponderPtr result = LineChatTranslationReceiver::build(to_lang, line, start, length); + LLTranslate::translateMessage(result,"", to_lang, to_translate); } } diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp index 8dcb014..369eb1e 100644 --- a/linden/indra/llui/lltexteditor.cpp +++ b/linden/indra/llui/lltexteditor.cpp @@ -398,38 +398,22 @@ LLTextEditor::LLTextEditor( menu->appendSeparator("Transep"); LLMenuGL* translatemenu = new LLMenuGL("Translate To"); translatemenu->setCanTearOff(FALSE); - SpellMenuBind* t=new SpellMenuBind;t->origin=this;t->word="en"; - translatemenu->append(new LLMenuItemCallGL("English", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="da"; - translatemenu->append(new LLMenuItemCallGL("Danish", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="de"; - translatemenu->append(new LLMenuItemCallGL("Deutsch(German)", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="es"; - translatemenu->append(new LLMenuItemCallGL("Spanish", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="fr"; - translatemenu->append(new LLMenuItemCallGL("French", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="it"; - translatemenu->append(new LLMenuItemCallGL("Italian", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="hu"; - translatemenu->append(new LLMenuItemCallGL("Hungarian", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="nl"; - translatemenu->append(new LLMenuItemCallGL("Dutch", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="pl"; - translatemenu->append(new LLMenuItemCallGL("Polish", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="pt"; - translatemenu->append(new LLMenuItemCallGL("Portugese", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="ru"; - translatemenu->append(new LLMenuItemCallGL("Russian", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="tr"; - translatemenu->append(new LLMenuItemCallGL("Turkish", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="uk"; - translatemenu->append(new LLMenuItemCallGL("Ukrainian", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="zh"; - translatemenu->append(new LLMenuItemCallGL("Chinese", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="ja"; - translatemenu->append(new LLMenuItemCallGL("Japanese", context_translate, context_enable_translate, t)); - t=new SpellMenuBind;t->origin=this;t->word="ko"; - translatemenu->append(new LLMenuItemCallGL("Korean", context_translate, context_enable_translate, t)); + translatemenu->append(new LLMenuItemCallGL("en", "English", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("da", "Danish", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("de", "Deutsch(German)", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("es", "Spanish", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("fr", "French", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("it", "Italian", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("hu", "Hungarian", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("nl", "Dutch", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("pl", "Polish", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("pt", "Portugese", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("ru", "Russian", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("tr", "Turkish", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("uk", "Ukrainian", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("zh", "Chinese", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("ja", "Japanese", context_translate, context_enable_translate, this)); + translatemenu->append(new LLMenuItemCallGL("ko", "Korean", context_translate, context_enable_translate, this)); menu->appendMenu(translatemenu); menu->appendSeparator("Spelsep"); @@ -483,15 +467,20 @@ void LLTextEditor::context_copy(void* data) BOOL LLTextEditor::context_enable_translate(void * data) { - SpellMenuBind* t = (SpellMenuBind*)data; - return (t && t->origin && t->origin->canTranslate()); + LLTextEditor* editor = (LLTextEditor*)data; + return editor && editor->canTranslate(); } void LLTextEditor::context_translate(void * data) { - SpellMenuBind* t = (SpellMenuBind*)data; - LLTextEditor* line = t->origin; - const std::string &toLang = t->word;//LLTranslate::getTranslateLanguage(); + LLTextEditor* line = (LLTextEditor*)data; + LLMenuGL* menu = line ? (LLMenuGL*)(line->mPopupMenuHandle.get()) : NULL; + LLMenuGL* translate_menu = menu ? menu->getChildMenuByName("Translate To", TRUE) : NULL; + if (!translate_menu) + { + return; + } + const std::string to_lang = translate_menu->getHighlightedItem()->getName(); bool has_text = false; S32 start, length; @@ -512,8 +501,8 @@ void LLTextEditor::context_translate(void * data) if (has_text) { const std::string to_translate = wstring_to_utf8str(line->getWText().substr(start, length)); - LLHTTPClient::ResponderPtr result = TextChatTranslationReceiver::build(toLang, line, start, length); - LLTranslate::translateMessage(result,"", toLang, to_translate); + LLHTTPClient::ResponderPtr result = TextChatTranslationReceiver::build(to_lang, line, start, length); + LLTranslate::translateMessage(result,"", to_lang, to_translate); } } -- cgit v1.1 From b35201c19ee61841aaea77f41b044bc7f53996a3 Mon Sep 17 00:00:00 2001 From: thickbrick Date: Tue, 5 Oct 2010 19:51:23 +0200 Subject: Fix RED-603: Errors when loading local images Avoid bad offsets that would cause failure with this warning: "doRead: Error reading file from local cache" --- linden/indra/newview/lltexturecache.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/lltexturecache.cpp b/linden/indra/newview/lltexturecache.cpp index 46c125f..0c35b32 100644 --- a/linden/indra/newview/lltexturecache.cpp +++ b/linden/indra/newview/lltexturecache.cpp @@ -372,9 +372,10 @@ bool LLTextureCacheRemoteWorker::doRead() if (!done && (mState == LOCAL)) { llassert(local_size != 0); // we're assuming there is a non empty local file here... - if (!mDataSize || mDataSize > local_size) + llassert(mReadData == NULL); + if (!mDataSize || mDataSize > (local_size - mOffset)) { - mDataSize = local_size; + mDataSize = local_size - mOffset; } // Allocate read buffer mReadData = new U8[mDataSize]; -- cgit v1.1 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 From 32369bbd2728f34f1bcc9fb68a1a191e0b16c827 Mon Sep 17 00:00:00 2001 From: thickbrick Date: Fri, 8 Oct 2010 00:04:15 +0200 Subject: Fix bug #612: Option to highlight misspeld words doesn't persist between sessions. --- linden/indra/newview/lgghunspell_wrapper.cpp | 7 ++----- .../newview/skins/default/xui/en-us/panel_preferences_advanced.xml | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/lgghunspell_wrapper.cpp b/linden/indra/newview/lgghunspell_wrapper.cpp index aa4507c..9548c4f 100644 --- a/linden/indra/newview/lgghunspell_wrapper.cpp +++ b/linden/indra/newview/lgghunspell_wrapper.cpp @@ -472,7 +472,7 @@ static char * languageCodesraw[]={ lggHunSpell_Wrapper::lggHunSpell_Wrapper() { //languageCodes(begin(languageCodesraw), end(languageCodesraw)); - mSpellCheckHighlight = rebind_llcontrol("EmeraldSpellDisplay", &gSavedSettings, false); + mSpellCheckHighlight = rebind_llcontrol("EmeraldSpellDisplay", &gSavedSettings, true); } lggHunSpell_Wrapper::~lggHunSpell_Wrapper() @@ -963,8 +963,5 @@ void lggHunSpell_Wrapper::editCustomButton() void lggHunSpell_Wrapper::setSpellCheckHighlight(BOOL highlight) { - if (mSpellCheckHighlight) - { - *mSpellCheckHighlight = highlight; - } + gSavedSettings.setBOOL("EmeraldSpellDisplay", highlight); } diff --git a/linden/indra/newview/skins/default/xui/en-us/panel_preferences_advanced.xml b/linden/indra/newview/skins/default/xui/en-us/panel_preferences_advanced.xml index a0c9e28..c3ee726 100644 --- a/linden/indra/newview/skins/default/xui/en-us/panel_preferences_advanced.xml +++ b/linden/indra/newview/skins/default/xui/en-us/panel_preferences_advanced.xml @@ -139,7 +139,7 @@ name="EmeraldHelp_SpellCheck" tool_tip="Click here for help regarding the settings in this page." right="490" width="18"/> -- cgit v1.1