summaryrefslogtreecommitdiff
path: root/indra/llui/llmenugl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/llmenugl.cpp')
-rw-r--r--indra/llui/llmenugl.cpp58
1 files changed, 40 insertions, 18 deletions
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index 4264028338..5cb840fd61 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -4087,25 +4087,39 @@ void LLTearOffMenu::closeTearOff()
}
LLContextMenuBranch::LLContextMenuBranch(const LLContextMenuBranch::Params& p)
-: LLMenuItemGL(p),
- mBranch( p.branch()->getHandle() )
+: LLMenuItemGL(p)
{
- mBranch.get()->hide();
- mBranch.get()->setParentMenuItem(this);
+ LLContextMenu* branch = static_cast<LLContextMenu*>(p.branch);
+ if (branch)
+ {
+ mBranch = branch->getHandle();
+ branch->hide();
+ branch->setParentMenuItem(this);
+ }
+}
+
+LLContextMenuBranch::~LLContextMenuBranch()
+{
+ if (mBranch.get())
+ {
+ mBranch.get()->die();
+ }
}
// called to rebuild the draw label
void LLContextMenuBranch::buildDrawLabel( void )
{
+ 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();
+ U32 sub_count = menu->getItemCount();
U32 i;
BOOL any_enabled = FALSE;
for (i = 0; i < sub_count; i++)
{
- LLMenuItemGL* item = mBranch.get()->getItem(i);
+ LLMenuItemGL* item = menu->getItem(i);
item->buildDrawLabel();
if (item->getEnabled() && !item->getDrawTextDisabled() )
{
@@ -4127,13 +4141,17 @@ void LLContextMenuBranch::buildDrawLabel( void )
void LLContextMenuBranch::showSubMenu()
{
- LLMenuItemGL* menu_item = mBranch.get()->getParentMenuItem();
- if (menu_item != NULL && menu_item->getVisible())
+ auto menu = getBranch();
+ if(menu)
{
- S32 center_x;
- S32 center_y;
- localPointToScreen(getRect().getWidth(), getRect().getHeight() , &center_x, &center_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(), &center_x, &center_y);
+ menu->show(center_x, center_y);
+ }
}
}
@@ -4147,13 +4165,17 @@ void LLContextMenuBranch::setHighlight( BOOL highlight )
{
if (highlight == getHighlight()) return;
LLMenuItemGL::setHighlight(highlight);
- if( highlight )
- {
- showSubMenu();
- }
- else
+ auto menu = getBranch();
+ if (menu)
{
- mBranch.get()->hide();
+ if (highlight)
+ {
+ showSubMenu();
+ }
+ else
+ {
+ menu->hide();
+ }
}
}