From 7fd0e8c69e6dced4a770da4fac10c154eac5899f Mon Sep 17 00:00:00 2001
From: Richard Nelson <richard@lindenlab.com>
Date: Mon, 26 Sep 2011 18:51:43 -0700
Subject: [PATCH] fixed toolbar context menu deprecated pointless
 LLView::deleteViewByHandle

---
 indra/llui/llmenugl.cpp                        |  2 +-
 indra/llui/lltoolbar.cpp                       | 18 +++++++-----------
 indra/llui/lltoolbar.h                         | 11 +++++------
 indra/llui/lltoolbarview.cpp                   |  6 +++---
 indra/llui/llview.cpp                          |  7 -------
 indra/llui/llview.h                            |  1 -
 indra/newview/llfavoritesbar.cpp               |  4 ++--
 indra/newview/llfloatersnapshot.cpp            |  2 +-
 indra/newview/llfolderview.cpp                 |  4 ++--
 indra/newview/llgrouplist.cpp                  |  2 +-
 indra/newview/llpanelpeople.cpp                | 10 +++++-----
 indra/newview/llpanelteleporthistory.cpp       |  2 +-
 .../skins/default/xui/en/menu_toolbars.xml     |  4 ++--
 .../skins/default/xui/en/widgets/toolbar.xml   |  1 -
 14 files changed, 30 insertions(+), 44 deletions(-)

diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index 6cac841cdea..badba7a416c 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -947,7 +947,7 @@ LLMenuItemBranchGL::LLMenuItemBranchGL(const LLMenuItemBranchGL::Params& p)
 
 LLMenuItemBranchGL::~LLMenuItemBranchGL()
 {
-	LLView::deleteViewByHandle(mBranchHandle);
+	delete mBranchHandle.get();
 }
 
 // virtual
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index 278c04aef8e..bd45cf46567 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -116,12 +116,12 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p)
 
 LLToolBar::~LLToolBar()
 {
-	LLView::deleteViewByHandle(mPopupMenuHandle);
+	delete mPopupMenuHandle.get();
 }
 
-BOOL LLToolBar::postBuild()
+void LLToolBar::createContextMenu()
 {
-	if (!mReadOnly)
+	if (!mPopupMenuHandle.get())
 	{
 		LLUICtrl::CommitCallbackRegistry::Registrar& commit_reg = LLUICtrl::CommitCallbackRegistry::defaultRegistrar();
 		commit_reg.add("Toolbars.EnableSetting", boost::bind(&LLToolBar::onSettingEnable, this, _2));
@@ -129,11 +129,7 @@ BOOL LLToolBar::postBuild()
 		LLUICtrl::EnableCallbackRegistry::Registrar& enable_reg = LLUICtrl::EnableCallbackRegistry::defaultRegistrar();
 		enable_reg.add("Toolbars.CheckSetting", boost::bind(&LLToolBar::isSettingChecked, this, _2));
 
-		//
-		// Setup the context menu
-		//
-
-		LLMenuGL* menu = LLUICtrlFactory::instance().createFromFile<LLMenuGL>("menu_toolbars.xml", LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance());
+		LLContextMenu* menu = LLUICtrlFactory::instance().createFromFile<LLContextMenu>("menu_toolbars.xml", LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance());
 
 		if (menu)
 		{
@@ -146,8 +142,6 @@ BOOL LLToolBar::postBuild()
 			llwarns << "Unable to load toolbars context menu." << llendl;
 		}
 	}
-
-	return TRUE;
 }
 
 void LLToolBar::initFromParams(const LLToolBar::Params& p)
@@ -278,10 +272,12 @@ BOOL LLToolBar::handleRightMouseDown(S32 x, S32 y, MASK mask)
 
 	if (handle_it_here)
 	{
-		LLMenuGL * menu = (LLMenuGL *) mPopupMenuHandle.get();
+		createContextMenu();
+		LLContextMenu * menu = (LLContextMenu *) mPopupMenuHandle.get();
 
 		if (menu)
 		{
+			menu->show(x, y);
 			LLMenuGL::showPopup(this, menu, x, y);
 		}
 	}
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index f7562b29d24..657e9283193 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -119,8 +119,8 @@ class LLToolBar
 
 	// virtuals
 	void draw();
-	BOOL postBuild();
 	void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
+	BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
 
 	bool addCommand(const LLCommandId& commandId);
 	bool hasCommand(const LLCommandId& commandId) const;
@@ -133,13 +133,12 @@ class LLToolBar
 
 	void initFromParams(const Params&);
 
-	BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
-	BOOL isSettingChecked(const LLSD& userdata);
-	void onSettingEnable(const LLSD& userdata);
-
 private:
+	void createContextMenu();
 	void updateLayoutAsNeeded();
 	void resizeButtonsInRow(std::vector<LLToolBarButton*>& buttons_in_row, S32 max_row_girth);
+	BOOL isSettingChecked(const LLSD& userdata);
+	void onSettingEnable(const LLSD& userdata);
 
 	const bool						mReadOnly;
 
@@ -164,7 +163,7 @@ class LLToolBar
 
 	LLToolBarButton::Params			mButtonParams[LLToolBarEnums::BTNTYPE_COUNT];
 
-	LLHandle<LLView>				mPopupMenuHandle;
+	LLHandle<class LLContextMenu>			mPopupMenuHandle;
 };
 
 
diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp
index 21d3785c822..6ae10fbf1dc 100644
--- a/indra/llui/lltoolbarview.cpp
+++ b/indra/llui/lltoolbarview.cpp
@@ -90,9 +90,9 @@ void LLToolBarView::draw()
 	
 	LLRect bottom_rect, left_rect, right_rect;
 
-	if (mToolbarBottom) bottom_rect = mToolbarBottom->getRect();
-	if (mToolbarLeft)   left_rect   = mToolbarLeft->getRect();
-	if (mToolbarRight)  right_rect  = mToolbarRight->getRect();
+	if (mToolbarBottom) mToolbarBottom->localRectToOtherView(mToolbarBottom->getLocalRect(), &bottom_rect, this);
+	if (mToolbarLeft)   mToolbarLeft->localRectToOtherView(mToolbarLeft->getLocalRect(), &left_rect, this);
+	if (mToolbarRight)  mToolbarRight->localRectToOtherView(mToolbarRight->getLocalRect(), &right_rect, this);
 	
 	
 	if ((old_width != getRect().getWidth()) || (old_height != getRect().getHeight()))
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index 60452b9ae4d..e10c2f0d1e2 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -1826,13 +1826,6 @@ LLView* LLView::findNextSibling(LLView* child)
 	return (next_it != mChildList.end()) ? *next_it : NULL;
 }
 
-void LLView::deleteViewByHandle(LLHandle<LLView> handle)
-{
-	LLView* viewp = handle.get();
-
-	delete viewp;
-}
-
 
 LLCoordGL getNeededTranslation(const LLRect& input, const LLRect& constraint, BOOL allow_partial_outside)
 {
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index 594a5eec6be..7a1b2e4ba04 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -482,7 +482,6 @@ class LLView : public LLMouseHandler, public LLMortician, public LLFocusableElem
 	// return query for iterating over focus roots in tab order
 	static const LLCtrlQuery & getFocusRootsQuery();
 
-	static void deleteViewByHandle(LLHandle<LLView> handle);
 	static LLWindow*	getWindow(void) { return LLUI::sWindow; }
 
 	// Set up params after XML load before calling new(),
diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp
index 0b17d64eb07..836c580ea89 100644
--- a/indra/newview/llfavoritesbar.cpp
+++ b/indra/newview/llfavoritesbar.cpp
@@ -403,8 +403,8 @@ LLFavoritesBarCtrl::~LLFavoritesBarCtrl()
 {
 	gInventory.removeObserver(this);
 
-	LLView::deleteViewByHandle(mOverflowMenuHandle);
-	LLView::deleteViewByHandle(mContextMenuHandle);
+	delete mOverflowMenuHandle.get();
+	delete mContextMenuHandle.get();
 }
 
 BOOL LLFavoritesBarCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp
index 00dc7b16275..9d020517d84 100644
--- a/indra/newview/llfloatersnapshot.cpp
+++ b/indra/newview/llfloatersnapshot.cpp
@@ -2112,7 +2112,7 @@ LLFloaterSnapshot::LLFloaterSnapshot(const LLSD& key)
 // Destroys the object
 LLFloaterSnapshot::~LLFloaterSnapshot()
 {
-	LLView::deleteViewByHandle(impl.mPreviewHandle);
+	delete impl.mPreviewHandle.get();
 
 	//unfreeze everything else
 	gSavedSettings.setBOOL("FreezeTime", FALSE);
diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp
index 9ba5f827e25..6ec2598e447 100644
--- a/indra/newview/llfolderview.cpp
+++ b/indra/newview/llfolderview.cpp
@@ -299,7 +299,7 @@ LLFolderView::~LLFolderView( void )
 	mAutoOpenItems.removeAllNodes();
 	gIdleCallbacks.deleteFunction(idle, this);
 
-	LLView::deleteViewByHandle(mPopupMenuHandle);
+	delete mPopupMenuHandle.get();
 
 	mAutoOpenItems.removeAllNodes();
 	clearSelection();
@@ -1969,7 +1969,7 @@ BOOL LLFolderView::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
 void LLFolderView::deleteAllChildren()
 {
 	closeRenamer();
-	LLView::deleteViewByHandle(mPopupMenuHandle);
+	delete mPopupMenuHandle.get();
 	mPopupMenuHandle = LLHandle<LLView>();
 	mScrollContainer = NULL;
 	mRenameItem = NULL;
diff --git a/indra/newview/llgrouplist.cpp b/indra/newview/llgrouplist.cpp
index c3e6e1c2dca..f7ed1116cbd 100644
--- a/indra/newview/llgrouplist.cpp
+++ b/indra/newview/llgrouplist.cpp
@@ -95,7 +95,7 @@ LLGroupList::LLGroupList(const Params& p)
 LLGroupList::~LLGroupList()
 {
 	gAgent.removeListener(this);
-	LLView::deleteViewByHandle(mContextMenuHandle);
+	delete mContextMenuHandle.get();
 }
 
 // virtual
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index e3a7b749ea6..177aa4f5c81 100644
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -526,11 +526,11 @@ LLPanelPeople::~LLPanelPeople()
 		LLVoiceClient::getInstance()->removeObserver(this);
 	}
 
-	LLView::deleteViewByHandle(mGroupPlusMenuHandle);
-	LLView::deleteViewByHandle(mNearbyViewSortMenuHandle);
-	LLView::deleteViewByHandle(mFriendsViewSortMenuHandle);
-	LLView::deleteViewByHandle(mGroupsViewSortMenuHandle);
-	LLView::deleteViewByHandle(mRecentViewSortMenuHandle);
+	delete mGroupPlusMenuHandle.get();
+	delete mNearbyViewSortMenuHandle.get();
+	delete mFriendsViewSortMenuHandle.get();
+	delete mGroupsViewSortMenuHandle.get();
+	delete mRecentViewSortMenuHandle.get();
 
 }
 
diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp
index 9b35e78134a..dfa8c75493f 100644
--- a/indra/newview/llpanelteleporthistory.cpp
+++ b/indra/newview/llpanelteleporthistory.cpp
@@ -388,7 +388,7 @@ LLTeleportHistoryPanel::LLTeleportHistoryPanel()
 LLTeleportHistoryPanel::~LLTeleportHistoryPanel()
 {
 	LLTeleportHistoryFlatItemStorage::instance().purge();
-	LLView::deleteViewByHandle(mGearMenuHandle);
+	delete mGearMenuHandle.get();
 }
 
 BOOL LLTeleportHistoryPanel::postBuild()
diff --git a/indra/newview/skins/default/xui/en/menu_toolbars.xml b/indra/newview/skins/default/xui/en/menu_toolbars.xml
index b3ecd3dcb67..de13fec6701 100644
--- a/indra/newview/skins/default/xui/en/menu_toolbars.xml
+++ b/indra/newview/skins/default/xui/en/menu_toolbars.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-<menu bottom="825"
+<context_menu
       layout="topleft"
       name="Toolbars Popup"
       visible="false">
@@ -26,4 +26,4 @@
     <on_check function="Toolbars.CheckSetting"
               parameter="icons_only" />
   </menu_item_check>
-</menu>
+</context_menu>
diff --git a/indra/newview/skins/default/xui/en/widgets/toolbar.xml b/indra/newview/skins/default/xui/en/widgets/toolbar.xml
index 95ccc6e92c5..29b5d022997 100644
--- a/indra/newview/skins/default/xui/en/widgets/toolbar.xml
+++ b/indra/newview/skins/default/xui/en/widgets/toolbar.xml
@@ -7,7 +7,6 @@
          pad_between="5"
          mouse_opaque="false"
          read_only="false">
-
   <button_panel name="button_panel"
                 bg_opaque_image="Rounded_Rect"
                 background_visible="true"
-- 
GitLab