From 9e73d04811f65006198297f527d38f1c6262bdce Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 2 Sep 2016 19:20:31 +0300 Subject: MAINT-6461 crash due to invalid menu pointer during visibility change --- indra/llui/llfloater.cpp | 15 +++---------- indra/newview/llpanelmaininventory.cpp | 39 +++++++++++++++++++++++----------- indra/newview/llpanelmaininventory.h | 2 +- 3 files changed, 31 insertions(+), 25 deletions(-) (limited to 'indra') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 93ee1ceee3..4f664a1ccc 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -2318,19 +2318,10 @@ void LLFloaterView::reshape(S32 width, S32 height, BOOL called_from_parent) void LLFloaterView::restoreAll() { // make sure all subwindows aren't minimized - for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) + child_list_t child_list = *(getChildList()); + for (child_list_const_iter_t child_it = child_list.begin(); child_it != child_list.end(); ++child_it) { - LLFloater* floaterp = NULL; - try - { - floaterp = dynamic_cast(*child_it); - } - catch (std::exception e) // See MAINT-6511 - { - LL_WARNS() << "Caught exception: " << e.what() << LL_ENDL; - continue; - } - + LLFloater* floaterp = dynamic_cast(*child_it); if (floaterp) { floaterp->setMinimized(FALSE); diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index c779ba5cdd..eb40616a9c 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -106,7 +106,7 @@ LLPanelMainInventory::LLPanelMainInventory(const LLPanel::Params& p) mSavedFolderState(NULL), mFilterText(""), mMenuGearDefault(NULL), - mMenuAdd(NULL), + mMenuAddHandle(), mNeedUploadCost(true) { // Menu Callbacks (non contex menus) @@ -200,10 +200,15 @@ BOOL LLPanelMainInventory::postBuild() // *TODO:Get the cost info from the server const std::string upload_cost("10"); - mMenuAdd->getChild("Upload Image")->setLabelArg("[COST]", upload_cost); - mMenuAdd->getChild("Upload Sound")->setLabelArg("[COST]", upload_cost); - mMenuAdd->getChild("Upload Animation")->setLabelArg("[COST]", upload_cost); - mMenuAdd->getChild("Bulk Upload")->setLabelArg("[COST]", upload_cost); + + LLMenuGL* menu = (LLMenuGL*)mMenuAddHandle.get(); + if (menu) + { + menu->getChild("Upload Image")->setLabelArg("[COST]", upload_cost); + menu->getChild("Upload Sound")->setLabelArg("[COST]", upload_cost); + menu->getChild("Upload Animation")->setLabelArg("[COST]", upload_cost); + menu->getChild("Bulk Upload")->setLabelArg("[COST]", upload_cost); + } // Trigger callback for focus received so we can deselect items in inbox/outbox LLFocusableElement::setFocusReceivedCallback(boost::bind(&LLPanelMainInventory::onFocusReceived, this)); @@ -983,7 +988,8 @@ void LLPanelMainInventory::initListCommandsHandlers() mEnableCallbackRegistrar.add("Inventory.GearDefault.Enable", boost::bind(&LLPanelMainInventory::isActionEnabled, this, _2)); mMenuGearDefault = LLUICtrlFactory::getInstance()->createFromFile("menu_inventory_gear_default.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); mGearMenuButton->setMenu(mMenuGearDefault); - mMenuAdd = LLUICtrlFactory::getInstance()->createFromFile("menu_inventory_add.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); + LLMenuGL* menu = LLUICtrlFactory::getInstance()->createFromFile("menu_inventory_add.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); + mMenuAddHandle = menu->getHandle(); // Update the trash button when selected item(s) get worn or taken off. LLOutfitObserver::instance().addCOFChangedCallback(boost::bind(&LLPanelMainInventory::updateListCommands, this)); @@ -1001,11 +1007,15 @@ void LLPanelMainInventory::onAddButtonClick() // Gray out the "New Folder" option when the Recent tab is active as new folders will not be displayed // unless "Always show folders" is checked in the filter options. bool recent_active = ("Recent Items" == mActivePanel->getName()); - mMenuAdd->getChild("New Folder")->setEnabled(!recent_active); + LLMenuGL* menu = (LLMenuGL*)mMenuAddHandle.get(); + if (menu) + { + menu->getChild("New Folder")->setEnabled(!recent_active); - setUploadCostIfNeeded(); + setUploadCostIfNeeded(); - showActionMenu(mMenuAdd,"add_btn"); + showActionMenu(menu,"add_btn"); + } } void LLPanelMainInventory::showActionMenu(LLMenuGL* menu, std::string spawning_view_name) @@ -1156,7 +1166,11 @@ void LLPanelMainInventory::onVisibilityChange( BOOL new_visibility ) { if(!new_visibility) { - mMenuAdd->setVisible(FALSE); + LLMenuGL* menu = (LLMenuGL*)mMenuAddHandle.get(); + if (menu) + { + menu->setVisible(FALSE); + } getActivePanel()->getRootFolder()->finishRenamingItem(); } } @@ -1289,9 +1303,10 @@ void LLPanelMainInventory::setUploadCostIfNeeded() // have two instances of Inventory panel at the moment(and two instances of context menu), // call to gMenuHolder->childSetLabelArg() sets upload cost only for one of the instances. - if(mNeedUploadCost && mMenuAdd) + LLMenuGL* menu = (LLMenuGL*)mMenuAddHandle.get(); + if(mNeedUploadCost && menu) { - LLMenuItemBranchGL* upload_menu = mMenuAdd->findChild("upload"); + LLMenuItemBranchGL* upload_menu = menu->findChild("upload"); if(upload_menu) { S32 upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); diff --git a/indra/newview/llpanelmaininventory.h b/indra/newview/llpanelmaininventory.h index 290e2e5f47..efa18b42c1 100644 --- a/indra/newview/llpanelmaininventory.h +++ b/indra/newview/llpanelmaininventory.h @@ -156,8 +156,8 @@ protected: private: LLDragAndDropButton* mTrashButton; LLToggleableMenu* mMenuGearDefault; - LLMenuGL* mMenuAdd; LLMenuButton* mGearMenuButton; + LLHandle mMenuAddHandle; bool mNeedUploadCost; // List Commands // -- cgit v1.2.3