From da23e0f925742045013fc09e75b962c65e1cda88 Mon Sep 17 00:00:00 2001
From: andreykproductengine <akleshchev@productengine.com>
Date: Tue, 13 Sep 2016 20:32:34 +0300
Subject: [PATCH] MAINT-6726 Fixed LLLineEditor menus staying in memory forever

---
 indra/llui/lllineeditor.cpp           | 15 +++++++++++----
 indra/llui/lllineeditor.h             |  4 +++-
 indra/llui/lltextbase.cpp             |  2 +-
 indra/newview/lllocationinputctrl.cpp |  2 +-
 4 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp
index 492c9315d13..c89e1dac1d1 100644
--- a/indra/llui/lllineeditor.cpp
+++ b/indra/llui/lllineeditor.cpp
@@ -2636,10 +2636,17 @@ void LLLineEditor::showContextMenu(S32 x, S32 y)
 
 void LLLineEditor::setContextMenu(LLContextMenu* new_context_menu)
 {
-	if (new_context_menu)
-		mContextMenuHandle = new_context_menu->getHandle();
-	else
-		mContextMenuHandle.markDead();
+    LLContextMenu* menu = static_cast<LLContextMenu*>(mContextMenuHandle.get());
+    if (menu)
+    {
+        menu->die();
+        mContextMenuHandle.markDead();
+    }
+
+    if (new_context_menu)
+    {
+        mContextMenuHandle = new_context_menu->getHandle();
+    }
 }
 
 void LLLineEditor::setFont(const LLFontGL* font)
diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h
index c6d472f59b7..ccbd305a168 100644
--- a/indra/llui/lllineeditor.h
+++ b/indra/llui/lllineeditor.h
@@ -272,7 +272,7 @@ class LLLineEditor
 
 	void			setReplaceNewlinesWithSpaces(BOOL replace);
 
-	void			setContextMenu(LLContextMenu* new_context_menu);
+	void			resetContextMenu() { setContextMenu(NULL); };
 
 private:
 	// private helper methods
@@ -308,6 +308,8 @@ class LLLineEditor
 	virtual S32		getPreeditFontSize() const;
 	virtual LLWString getPreeditString() const { return getWText(); }
 
+	void			setContextMenu(LLContextMenu* new_context_menu);
+
 protected:
 	LLUIString		mText;					// The string being edited.
 	std::string		mPrevText;				// Saved string for 'ESC' revert
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 7061d16dd40..20be7392867 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -1961,7 +1961,7 @@ void LLTextBase::createUrlContextMenu(S32 x, S32 y, const std::string &in_url)
     LLContextMenu* menu = static_cast<LLContextMenu*>(mPopupMenuHandle.get());
     if (menu)
     {
-        menu->updateParent(NULL);
+        menu->die();
         mPopupMenuHandle.markDead();
     }
 	llassert(LLMenuGL::sMenuContainer != NULL);
diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp
index 53b2ca2b74a..11bc1425f90 100644
--- a/indra/newview/lllocationinputctrl.cpp
+++ b/indra/newview/lllocationinputctrl.cpp
@@ -243,7 +243,7 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p)
 	params.commit_on_focus_lost(false);
 	params.follows.flags(FOLLOWS_ALL);
 	mTextEntry = LLUICtrlFactory::create<LLURLLineEditor>(params);
-	mTextEntry->setContextMenu(NULL);
+	mTextEntry->resetContextMenu();
 	addChild(mTextEntry);
 	// LLLineEditor is replaced with LLLocationLineEditor
 
-- 
GitLab