From 001621dfc21942a6ae0075ca3eef31720f42477b Mon Sep 17 00:00:00 2001 From: Stinson Linden <stinson@lindenlab.com> Date: Mon, 5 May 2014 23:24:34 +0100 Subject: [PATCH] MAINT-4009: Patching a small memory leak for when menu items were being created before the viewer window initialization had created the menu holder. Also, added llasserts in other cases when referencing the menu holder to ensure the holder is non-null. --- indra/llui/llfolderview.cpp | 1 + indra/llui/lllineeditor.cpp | 1 + indra/llui/llmenubutton.cpp | 1 + indra/llui/llscrolllistctrl.cpp | 1 + indra/llui/lltextbase.cpp | 1 + indra/llui/lltexteditor.cpp | 1 + indra/llui/lltoolbar.cpp | 1 + indra/newview/llchiclet.cpp | 1 + indra/newview/lllistcontextmenu.cpp | 1 + indra/newview/llmediactrl.cpp | 7 +++++++ indra/newview/llmediactrl.h | 2 ++ indra/newview/llpaneloutfitedit.cpp | 2 ++ indra/newview/llpanelteleporthistory.cpp | 2 ++ indra/newview/llviewerwindow.cpp | 6 +++++- 14 files changed, 27 insertions(+), 1 deletion(-) diff --git a/indra/llui/llfolderview.cpp b/indra/llui/llfolderview.cpp index 53f2e15ed0a..2ec7ed861f9 100755 --- a/indra/llui/llfolderview.cpp +++ b/indra/llui/llfolderview.cpp @@ -231,6 +231,7 @@ LLFolderView::LLFolderView(const Params& p) // make the popup menu available + llassert(LLMenuGL::sMenuContainer != NULL); LLMenuGL* menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>(p.options_menu, LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance()); if (!menu) { diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index d410a2de339..b09c9277828 100755 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -192,6 +192,7 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p) setPrevalidateInput(p.prevalidate_input_callback()); setPrevalidate(p.prevalidate_callback()); + llassert(LLMenuGL::sMenuContainer != NULL); LLContextMenu* menu = LLUICtrlFactory::instance().createFromFile<LLContextMenu> ("menu_text_editor.xml", LLMenuGL::sMenuContainer, diff --git a/indra/llui/llmenubutton.cpp b/indra/llui/llmenubutton.cpp index 0609cd8b423..303afcda151 100755 --- a/indra/llui/llmenubutton.cpp +++ b/indra/llui/llmenubutton.cpp @@ -93,6 +93,7 @@ void LLMenuButton::setMenu(const std::string& menu_filename, EMenuPosition posit return; } + llassert(LLMenuGL::sMenuContainer != NULL); LLToggleableMenu* menu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>(menu_filename, LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance()); if (!menu) { diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 3708071e11a..5f72ee3ac63 100755 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -1815,6 +1815,7 @@ BOOL LLScrollListCtrl::handleRightMouseDown(S32 x, S32 y, MASK mask) // create the context menu from the XUI file and display it std::string menu_name = is_group ? "menu_url_group.xml" : "menu_url_agent.xml"; delete mPopupMenu; + llassert(LLMenuGL::sMenuContainer != NULL); mPopupMenu = LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu>( menu_name, LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance()); if (mPopupMenu) diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 62edbadb077..30e6c6248e4 100755 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -1955,6 +1955,7 @@ void LLTextBase::createUrlContextMenu(S32 x, S32 y, const std::string &in_url) // create and return the context menu from the XUI file delete mPopupMenu; + llassert(LLMenuGL::sMenuContainer != NULL); mPopupMenu = LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu>(xui_file, LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance()); if (mIsFriendSignal) diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 494666df8ab..517142bf17d 100755 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -2031,6 +2031,7 @@ void LLTextEditor::showContextMenu(S32 x, S32 y) { if (!mContextMenu) { + llassert(LLMenuGL::sMenuContainer != NULL); mContextMenu = LLUICtrlFactory::instance().createFromFile<LLContextMenu>("menu_text_editor.xml", LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance()); diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index f9bdd87087a..abc2b6e9cac 100755 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -148,6 +148,7 @@ void LLToolBar::createContextMenu() enable_reg.add("Toolbars.CheckSetting", boost::bind(&LLToolBar::isSettingChecked, this, _2)); // Create the context menu + llassert(LLMenuGL::sMenuContainer != NULL); LLContextMenu* menu = LLUICtrlFactory::instance().createFromFile<LLContextMenu>("menu_toolbars.xml", LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance()); if (menu) diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp index b1dce42dfd6..c0823182c04 100755 --- a/indra/newview/llchiclet.cpp +++ b/indra/newview/llchiclet.cpp @@ -204,6 +204,7 @@ void LLNotificationChiclet::createMenu() enable_registrar.add("NotificationWellChicletMenu.EnableItem", boost::bind(&LLNotificationChiclet::enableMenuItem, this, _2)); + llassert(LLMenuGL::sMenuContainer != NULL); mContextMenu = LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu> ("menu_notification_well_button.xml", LLMenuGL::sMenuContainer, diff --git a/indra/newview/lllistcontextmenu.cpp b/indra/newview/lllistcontextmenu.cpp index a624c9fb879..6bda8b1d0d9 100755 --- a/indra/newview/lllistcontextmenu.cpp +++ b/indra/newview/lllistcontextmenu.cpp @@ -110,6 +110,7 @@ void LLListContextMenu::handleMultiple(functor_t functor, const uuid_vec_t& ids) // static LLContextMenu* LLListContextMenu::createFromFile(const std::string& filename) { + llassert(LLMenuGL::sMenuContainer != NULL); return LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu>( filename, LLContextMenu::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance()); } diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp index 323445afa6d..90d4dd093b9 100755 --- a/indra/newview/llmediactrl.cpp +++ b/indra/newview/llmediactrl.cpp @@ -390,6 +390,8 @@ BOOL LLMediaCtrl::postBuild () LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registar; registar.add("Open.WebInspector", boost::bind(&LLMediaCtrl::onOpenWebInspector, this)); + // stinson 05/05/2014 : cannot assert on the menu container being NULL because it will be during the processing of main_view.xml + // llassert(LLMenuGL::sMenuContainer != NULL); mContextMenu = LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu>( "menu_media_ctrl.xml", LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance()); setVisibleCallback(boost::bind(&LLMediaCtrl::onVisibilityChanged, this, _2)); @@ -1117,3 +1119,8 @@ void LLMediaCtrl::setTrustedContent(bool trusted) mMediaSource->setTrustedBrowser(trusted); } } + +void LLMediaCtrl::updateContextMenuParent(LLView* pNewParent) +{ + mContextMenu->updateParent(pNewParent); +} diff --git a/indra/newview/llmediactrl.h b/indra/newview/llmediactrl.h index 5978a7a344e..b07eb356aec 100755 --- a/indra/newview/llmediactrl.h +++ b/indra/newview/llmediactrl.h @@ -168,6 +168,8 @@ class LLMediaCtrl : LLUUID getTextureID() {return mMediaTextureID;} + void updateContextMenuParent(LLView* pNewParent); + protected: void convertInputCoords(S32& x, S32& y); diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp index e48aa889378..158038c4f70 100755 --- a/indra/newview/llpaneloutfitedit.cpp +++ b/indra/newview/llpaneloutfitedit.cpp @@ -159,6 +159,7 @@ class LLPanelOutfitEditGearMenu registrar.add("Wearable.Create", boost::bind(onCreate, _2)); + llassert(LLMenuGL::sMenuContainer != NULL); LLToggleableMenu* menu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>( "menu_cof_gear.xml", LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance()); llassert(menu); @@ -228,6 +229,7 @@ class LLAddWearablesGearMenu : public LLInitClass<LLAddWearablesGearMenu> enable_registrar.add("AddWearable.Gear.Check", boost::bind(onCheck, flat_list_handle, inventory_panel_handle, _2)); enable_registrar.add("AddWearable.Gear.Visible", boost::bind(onVisible, inventory_panel_handle, _2)); + llassert(LLMenuGL::sMenuContainer != NULL); LLToggleableMenu* menu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>( "menu_add_wearable_gear.xml", LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance()); diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp index 8fddd9523f8..652d2be6f61 100755 --- a/indra/newview/llpanelteleporthistory.cpp +++ b/indra/newview/llpanelteleporthistory.cpp @@ -341,6 +341,7 @@ LLContextMenu* LLTeleportHistoryPanel::ContextMenu::createMenu() registrar.add("TeleportHistory.CopyToClipboard",boost::bind(&LLTeleportHistoryPanel::ContextMenu::onCopyToClipboard, this)); // create the context menu from the XUI + llassert(LLMenuGL::sMenuContainer != NULL); return LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu>( "menu_teleport_history_item.xml", LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance()); } @@ -935,6 +936,7 @@ void LLTeleportHistoryPanel::onAccordionTabRightClick(LLView *view, S32 x, S32 y registrar.add("TeleportHistory.TabClose", boost::bind(&LLTeleportHistoryPanel::onAccordionTabClose, this, tab)); // create the context menu from the XUI + llassert(LLMenuGL::sMenuContainer != NULL); mAccordionTabMenu = LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu>( "menu_teleport_history_tab.xml", LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance()); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 3dad782715d..621baee0e69 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -1910,9 +1910,13 @@ void LLViewerWindow::initBase() setProgressCancelButtonVisible(FALSE); gMenuHolder = getRootView()->getChild<LLViewerMenuHolderGL>("Menu Holder"); - LLMenuGL::sMenuContainer = gMenuHolder; + // stinson 05/05/2014 : the panel_progress.xml references a LLMediaCtrl(<web_browser></web_browser>) class + // which creates some menu items. However, because the Menu Holder is not initialized then, we need to + // update the parent for the menu items so they will be properly cleaned up. + LLMediaCtrl* mediaCtrl = getRootView()->findChild<LLMediaCtrl>("login_media_panel"); + mediaCtrl->updateContextMenuParent(LLMenuGL::sMenuContainer); } void LLViewerWindow::initWorldUI() -- GitLab