diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index c7f82dca0d..1b2d49ea36 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -4019,25 +4019,54 @@ void LLTearOffMenu::closeTearOff() } LLContextMenuBranch::LLContextMenuBranch(const LLContextMenuBranch::Params& p) -: LLMenuItemGL(p), - mBranch( p.branch()->getHandle() ) +: LLMenuItemGL(p) + //mBranch( p.branch()->getHandle() ) // Context menu memory leak fix by Rye Mutt { - mBranch.get()->hide(); - mBranch.get()->setParentMenuItem(this); + // Context menu memory leak fix by Rye Mutt + //mBranch.get()->hide(); + //mBranch.get()->setParentMenuItem(this); + // + LLContextMenu* branch = static_cast(p.branch); + if (branch) + { + mBranch = branch->getHandle(); + branch->hide(); + branch->setParentMenuItem(this); + } } +// Context menu memory leak fix by Rye Mutt +LLContextMenuBranch::~LLContextMenuBranch() +{ + if (mBranch.get()) + { + mBranch.get()->die(); + } +} +// + // called to rebuild the draw label void LLContextMenuBranch::buildDrawLabel( void ) { + // Context menu memory leak fix by Rye Mutt + auto menu = getBranch(); + if (menu) + // { // default enablement is this -- if any of the subitems are // enabled, this item is enabled. JC - U32 sub_count = mBranch.get()->getItemCount(); + // Context menu memory leak fix by Rye Mutt + //U32 sub_count = mBranch.get()->getItemCount(); + U32 sub_count = menu->getItemCount(); + // U32 i; BOOL any_enabled = FALSE; for (i = 0; i < sub_count; i++) { - LLMenuItemGL* item = mBranch.get()->getItem(i); + // Context menu memory leak fix by Rye Mutt + //LLMenuItemGL* item = mBranch.get()->getItem(i); + LLMenuItemGL* item = menu->getItem(i); + // item->buildDrawLabel(); if (item->getEnabled() && !item->getDrawTextDisabled() ) { @@ -4059,14 +4088,28 @@ void LLContextMenuBranch::buildDrawLabel( void ) void LLContextMenuBranch::showSubMenu() { - LLMenuItemGL* menu_item = mBranch.get()->getParentMenuItem(); - if (menu_item != NULL && menu_item->getVisible()) + // Context menu memory leak fix by Rye Mutt + //LLMenuItemGL* menu_item = mBranch.get()->getParentMenuItem(); + //if (menu_item != NULL && menu_item->getVisible()) + //{ + // S32 center_x; + // S32 center_y; + // localPointToScreen(getRect().getWidth(), getRect().getHeight() , ¢er_x, ¢er_y); + // mBranch.get()->show(center_x, center_y); + //} + auto menu = getBranch(); + if (menu) { - S32 center_x; - S32 center_y; - localPointToScreen(getRect().getWidth(), getRect().getHeight() , ¢er_x, ¢er_y); - mBranch.get()->show(center_x, center_y); + LLMenuItemGL* menu_item = menu->getParentMenuItem(); + if (menu_item != NULL && menu_item->getVisible()) + { + S32 center_x; + S32 center_y; + localPointToScreen(getRect().getWidth(), getRect().getHeight() , ¢er_x, ¢er_y); + menu->show(center_x, center_y); + } } + // } // onCommit() - do the primary funcationality of the menu item. @@ -4079,14 +4122,28 @@ void LLContextMenuBranch::setHighlight( BOOL highlight ) { if (highlight == getHighlight()) return; LLMenuItemGL::setHighlight(highlight); - if( highlight ) + // Context menu memory leak fix by Rye Mutt + //if( highlight ) + //{ + // showSubMenu(); + //} + //else + //{ + // mBranch.get()->hide(); + //} + auto menu = getBranch(); + if (menu) { - showSubMenu(); - } - else - { - mBranch.get()->hide(); + if (highlight) + { + showSubMenu(); + } + else + { + menu->hide(); + } } + // } diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index e86aea1ebf..e47dfd7523 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -744,8 +744,11 @@ public: LLContextMenuBranch(const Params&); - virtual ~LLContextMenuBranch() - {} + // Context menu memory leak fix by Rye Mutt + //virtual ~LLContextMenuBranch() + //{} + virtual ~LLContextMenuBranch(); + // // called to rebuild the draw label virtual void buildDrawLabel( void );