diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 3dd787089..0a927ee4a 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -70,7 +70,7 @@ using namespace LLOldEvents; // static -LLMenuHolderGL *LLMenuGL::sMenuContainer = NULL; +LLMenuHolderGL *LLMenuGL::sMenuContainer = nullptr; S32 MENU_BAR_HEIGHT = 0; S32 MENU_BAR_WIDTH = 0; @@ -258,7 +258,7 @@ BOOL LLMenuItemGL::handleRightMouseUp(S32 x, S32 y, MASK mask) // if not, it will be added to the list BOOL LLMenuItemGL::addToAcceleratorList(std::list *listp) { - LLKeyBinding *accelerator = NULL; + LLKeyBinding *accelerator = nullptr; if (mAcceleratorKey != KEY_NONE) { @@ -268,19 +268,37 @@ BOOL LLMenuItemGL::addToAcceleratorList(std::list *listp) accelerator = *list_it; if ((accelerator->mKey == mAcceleratorKey) && (accelerator->mMask == (mAcceleratorMask & MASK_NORMALKEYS))) { + + // *NOTE: get calling code to throw up warning or route + // warning messages back to app-provided output + // std::string warning; + // warning.append("Duplicate key binding <"); + // appendAcceleratorString( warning ); + // warning.append("> for menu items:\n "); + // warning.append(accelerator->mName); + // warning.append("\n "); + // warning.append(mLabel); + + // LL_WARNS() << warning << LL_ENDL; + // LLAlertDialog::modalAlert(warning); return FALSE; } } if (!accelerator) { - accelerator = new LLKeyBinding; - if (accelerator) + try { + accelerator = new LLKeyBinding; accelerator->mKey = mAcceleratorKey; accelerator->mMask = (mAcceleratorMask & MASK_NORMALKEYS); // accelerator->mName = mLabel; + listp->push_back(accelerator);//addData(accelerator); + } + catch (const std::bad_alloc& e) + { + LL_WARNS() << "Failed to allocate memory for keybinding with exception: " << e.what() << LL_ENDL; + return FALSE; } - listp->push_back(accelerator);//addData(accelerator); } } return TRUE; @@ -681,7 +699,7 @@ class LLMenuItemVerticalSeparatorGL public: LLMenuItemVerticalSeparatorGL( void ); - virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask) { return FALSE; } + BOOL handleMouseDown(S32 x, S32 y, MASK mask) override { return FALSE; } }; LLMenuItemVerticalSeparatorGL::LLMenuItemVerticalSeparatorGL( void ) @@ -733,7 +751,7 @@ LLFloater* LLMenuItemTearOffGL::getParentFloater() } } - return NULL; + return nullptr; } void LLMenuItemTearOffGL::onCommit() @@ -4873,7 +4891,7 @@ void LLContextMenu::hide() { mHoverItem->setHighlight( FALSE ); } - mHoverItem = NULL; + mHoverItem = nullptr; }