Context menu memory leak fix by Rye Mutt
parent
e4d6a76486
commit
07deac24ea
|
|
@ -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() ) // <FS> Context menu memory leak fix by Rye Mutt
|
||||
{
|
||||
mBranch.get()->hide();
|
||||
mBranch.get()->setParentMenuItem(this);
|
||||
// <FS> Context menu memory leak fix by Rye Mutt
|
||||
//mBranch.get()->hide();
|
||||
//mBranch.get()->setParentMenuItem(this);
|
||||
// </FS>
|
||||
LLContextMenu* branch = static_cast<LLContextMenu*>(p.branch);
|
||||
if (branch)
|
||||
{
|
||||
mBranch = branch->getHandle();
|
||||
branch->hide();
|
||||
branch->setParentMenuItem(this);
|
||||
}
|
||||
}
|
||||
|
||||
// <FS> Context menu memory leak fix by Rye Mutt
|
||||
LLContextMenuBranch::~LLContextMenuBranch()
|
||||
{
|
||||
if (mBranch.get())
|
||||
{
|
||||
mBranch.get()->die();
|
||||
}
|
||||
}
|
||||
// </FS>
|
||||
|
||||
// called to rebuild the draw label
|
||||
void LLContextMenuBranch::buildDrawLabel( void )
|
||||
{
|
||||
// <FS> Context menu memory leak fix by Rye Mutt
|
||||
auto menu = getBranch();
|
||||
if (menu)
|
||||
// </FS>
|
||||
{
|
||||
// default enablement is this -- if any of the subitems are
|
||||
// enabled, this item is enabled. JC
|
||||
U32 sub_count = mBranch.get()->getItemCount();
|
||||
// <FS> Context menu memory leak fix by Rye Mutt
|
||||
//U32 sub_count = mBranch.get()->getItemCount();
|
||||
U32 sub_count = menu->getItemCount();
|
||||
// </FS>
|
||||
U32 i;
|
||||
BOOL any_enabled = FALSE;
|
||||
for (i = 0; i < sub_count; i++)
|
||||
{
|
||||
LLMenuItemGL* item = mBranch.get()->getItem(i);
|
||||
// <FS> Context menu memory leak fix by Rye Mutt
|
||||
//LLMenuItemGL* item = mBranch.get()->getItem(i);
|
||||
LLMenuItemGL* item = menu->getItem(i);
|
||||
// </FS>
|
||||
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())
|
||||
// <FS> 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);
|
||||
}
|
||||
}
|
||||
// </FS>
|
||||
}
|
||||
|
||||
// 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 )
|
||||
// <FS> 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();
|
||||
}
|
||||
}
|
||||
// </FS>
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -744,8 +744,11 @@ public:
|
|||
|
||||
LLContextMenuBranch(const Params&);
|
||||
|
||||
virtual ~LLContextMenuBranch()
|
||||
{}
|
||||
// <FS> Context menu memory leak fix by Rye Mutt
|
||||
//virtual ~LLContextMenuBranch()
|
||||
//{}
|
||||
virtual ~LLContextMenuBranch();
|
||||
// </FS>
|
||||
|
||||
// called to rebuild the draw label
|
||||
virtual void buildDrawLabel( void );
|
||||
|
|
|
|||
Loading…
Reference in New Issue