diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-07-29 21:19:57 +0300 |
---|---|---|
committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2024-08-09 22:55:08 +0300 |
commit | 048340ec1f2fd82a0fc877383d1476ec7c3c7a00 (patch) | |
tree | 556018ba0bcc1e062cb4b9520e7cd9ac3bf67e1e /indra | |
parent | 848d0cb27d4d37078c2f2d52bcb142a215d5cd26 (diff) |
viewer#2142 Crash at LLOutfitGalleryItem::setDefaultImage
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llinventorygallery.cpp | 104 | ||||
-rw-r--r-- | indra/newview/llinventorygallery.h | 1 | ||||
-rw-r--r-- | indra/newview/lloutfitgallery.cpp | 44 | ||||
-rw-r--r-- | indra/newview/lloutfitgallery.h | 3 |
4 files changed, 101 insertions, 51 deletions
diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index c69f797868..b99dbd9eb7 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -221,9 +221,10 @@ void LLInventoryGallery::setRootFolder(const LLUUID cat_id) for (const LLUUID& id : mSelectedItemIDs) { - if (mItemMap[id]) + LLInventoryGalleryItem* item = getItem(id); + if (item) { - mItemMap[id]->setSelected(false); + item->setSelected(false); } } @@ -348,7 +349,7 @@ void LLInventoryGallery::initGallery() mScrollPanel->addChild(mGalleryPanel); for (int i = 0; i < n; i++) { - addToGallery(mItemMap[cats[i]]); + addToGallery(getItem(cats[i])); } reArrangeRows(); mGalleryCreated = true; @@ -656,6 +657,16 @@ LLInventoryGalleryItem* LLInventoryGallery::buildGalleryItem(std::string name, L return gitem; } +LLInventoryGalleryItem* LLInventoryGallery::getItem(const LLUUID& id) const +{ + auto it = mItemMap.find(id); + if (it != mItemMap.end()) + { + return it->second; + } + return nullptr; +} + void LLInventoryGallery::buildGalleryPanel(int row_count) { LLPanel::Params params; @@ -1006,14 +1017,15 @@ void LLInventoryGallery::updateItemThumbnail(LLUUID item_id) thumbnail_id = getOutfitImageID(item_id); } - if (mItemMap[item_id]) + LLInventoryGalleryItem* item = getItem(item_id); + if (item) { - mItemMap[item_id]->setLoadImmediately(mLoadThumbnailsImmediately); - mItemMap[item_id]->setThumbnail(thumbnail_id); + item->setLoadImmediately(mLoadThumbnailsImmediately); + item->setThumbnail(thumbnail_id); - bool passes_filter = checkAgainstFilters(mItemMap[item_id], mFilterSubString); - if((mItemMap[item_id]->isHidden() && passes_filter) - || (!mItemMap[item_id]->isHidden() && !passes_filter)) + bool passes_filter = checkAgainstFilters(item, mFilterSubString); + if((item->isHidden() && passes_filter) + || (!item->isHidden() && !passes_filter)) { reArrangeRows(); } @@ -1169,7 +1181,7 @@ void LLInventoryGallery::moveUp(MASK mask) if (mInventoryGalleryMenu && mSelectedItemIDs.size() > 0 && mItemsAddedCount > 1) { - LLInventoryGalleryItem* item = mItemMap[mLastInteractedUUID]; + LLInventoryGalleryItem* item = getItem(mLastInteractedUUID); if (item) { if (mask == MASK_NONE || mask == MASK_CONTROL) @@ -1214,7 +1226,7 @@ void LLInventoryGallery::moveDown(MASK mask) if (mInventoryGalleryMenu && mSelectedItemIDs.size() > 0 && mItemsAddedCount > 1) { - LLInventoryGalleryItem* item = mItemMap[mLastInteractedUUID]; + LLInventoryGalleryItem* item = getItem(mLastInteractedUUID); if (item) { if (mask == MASK_NONE || mask == MASK_CONTROL) @@ -1259,11 +1271,7 @@ void LLInventoryGallery::moveLeft(MASK mask) if (mInventoryGalleryMenu && mSelectedItemIDs.size() > 0 && mItemsAddedCount > 1) { - LLInventoryGalleryItem* item = mItemMap[mLastInteractedUUID]; - if (mask == MASK_SHIFT) - { - item = mItemMap[mLastInteractedUUID]; - } + LLInventoryGalleryItem* item = getItem(mLastInteractedUUID); if (item) { // Might be better to get item from panel @@ -1307,7 +1315,7 @@ void LLInventoryGallery::moveRight(MASK mask) if (mInventoryGalleryMenu && mSelectedItemIDs.size() > 0 && mItemsAddedCount > 1) { - LLInventoryGalleryItem* item = mItemMap[mLastInteractedUUID]; + LLInventoryGalleryItem* item = getItem(mLastInteractedUUID); if (item) { S32 n = mItemIndexMap[item]; @@ -1373,8 +1381,8 @@ void LLInventoryGallery::toggleSelectionRangeFromLast(const LLUUID target) { return; } - LLInventoryGalleryItem* last_item = mItemMap[mLastInteractedUUID]; - LLInventoryGalleryItem* next_item = mItemMap[target]; + LLInventoryGalleryItem* last_item = getItem(mLastInteractedUUID); + LLInventoryGalleryItem* next_item = getItem(target); if (last_item && next_item) { S32 last_idx = mItemIndexMap[last_item]; @@ -1417,9 +1425,10 @@ void LLInventoryGallery::onFocusLost() for (const LLUUID& id : mSelectedItemIDs) { - if (mItemMap[id]) + LLInventoryGalleryItem* item = getItem(id); + if (item) { - mItemMap[id]->setSelected(false); + item->setSelected(false); } } } @@ -1435,9 +1444,10 @@ void LLInventoryGallery::onFocusReceived() LLInventoryGalleryItem* focus_item = NULL; for (const LLUUID& id : mSelectedItemIDs) { - if (mItemMap[id] && !mItemMap[id]->isHidden()) + LLInventoryGalleryItem* item = getItem(id); + if (item && !item->isHidden()) { - focus_item = mItemMap[id]; + focus_item = item; focus_item->setSelected(true); } } @@ -1478,9 +1488,10 @@ void LLInventoryGallery::changeItemSelection(const LLUUID& item_id, bool scroll_ { for (const LLUUID& id : mSelectedItemIDs) { - if (mItemMap[id]) + LLInventoryGalleryItem* item = getItem(id); + if (item) { - mItemMap[id]->setSelected(false); + item->setSelected(false); } } mSelectedItemIDs.clear(); @@ -1499,9 +1510,10 @@ void LLInventoryGallery::changeItemSelection(const LLUUID& item_id, bool scroll_ return; } - if (mItemMap[item_id]) + LLInventoryGalleryItem* item = getItem(item_id); + if (item) { - mItemMap[item_id]->setSelected(true); + item->setSelected(true); } mSelectedItemIDs.push_back(item_id); signalSelectionItemID(item_id); @@ -1527,9 +1539,10 @@ void LLInventoryGallery::addItemSelection(const LLUUID& item_id, bool scroll_to_ return; } - if (mItemMap[item_id]) + LLInventoryGalleryItem* item = getItem(item_id); + if (item) { - mItemMap[item_id]->setSelected(true); + item->setSelected(true); } mSelectedItemIDs.push_back(item_id); signalSelectionItemID(item_id); @@ -1552,18 +1565,20 @@ bool LLInventoryGallery::toggleItemSelection(const LLUUID& item_id, bool scroll_ selection_deque::iterator found = std::find(mSelectedItemIDs.begin(), mSelectedItemIDs.end(), item_id); if (found != mSelectedItemIDs.end()) { - if (mItemMap[item_id]) + LLInventoryGalleryItem* item = getItem(item_id); + if (item) { - mItemMap[item_id]->setSelected(false); + item->setSelected(false); } mSelectedItemIDs.erase(found); result = false; } else { - if (mItemMap[item_id]) + LLInventoryGalleryItem* item = getItem(item_id); + if (item) { - mItemMap[item_id]->setSelected(true); + item->setSelected(true); } mSelectedItemIDs.push_back(item_id); signalSelectionItemID(item_id); @@ -1580,7 +1595,7 @@ bool LLInventoryGallery::toggleItemSelection(const LLUUID& item_id, bool scroll_ void LLInventoryGallery::scrollToShowItem(const LLUUID& item_id) { - LLInventoryGalleryItem* item = mItemMap[item_id]; + LLInventoryGalleryItem* item = getItem(item_id); if(item) { const LLRect visible_content_rect = mScrollPanel->getVisibleContentRect(); @@ -1610,7 +1625,7 @@ LLInventoryGalleryItem* LLInventoryGallery::getFirstSelectedItem() if (mSelectedItemIDs.size() > 0) { selection_deque::iterator iter = mSelectedItemIDs.begin(); - return mItemMap[*iter]; + return getItem(*iter); } return NULL; } @@ -1768,9 +1783,10 @@ void LLInventoryGallery::paste() { for (const LLUUID& id : mSelectedItemIDs) { - if (mItemMap[id]) + LLInventoryGalleryItem* item = getItem(id); + if (item) { - mItemMap[id]->setSelected(false); + item->setSelected(false); } } mSelectedItemIDs.clear(); @@ -2108,9 +2124,10 @@ void LLInventoryGallery::pasteAsLink() { for (const LLUUID& id : mSelectedItemIDs) { - if (mItemMap[id]) + LLInventoryGalleryItem* item = getItem(id); + if (item) { - mItemMap[id]->setSelected(false); + item->setSelected(false); } } mSelectedItemIDs.clear(); @@ -2433,10 +2450,10 @@ void LLInventoryGallery::onGesturesChanged() void LLInventoryGallery::deselectItem(const LLUUID& category_id) { // Reset selection if the item is selected. - LLInventoryGalleryItem* item = mItemMap[category_id]; + LLInventoryGalleryItem* item = getItem(category_id); if (item && item->isSelected()) { - mItemMap[category_id]->setSelected(false); + item->setSelected(false); setFocus(true); // Todo: support multiselect // signalSelectionItemID(LLUUID::null); @@ -2453,9 +2470,10 @@ void LLInventoryGallery::clearSelection() { for (const LLUUID& id: mSelectedItemIDs) { - if (mItemMap[id]) + LLInventoryGalleryItem* item = getItem(id); + if (item) { - mItemMap[id]->setSelected(false); + item->setSelected(false); } } if (!mSelectedItemIDs.empty()) diff --git a/indra/newview/llinventorygallery.h b/indra/newview/llinventorygallery.h index afc7bdc9f8..59d08d19ed 100644 --- a/indra/newview/llinventorygallery.h +++ b/indra/newview/llinventorygallery.h @@ -228,6 +228,7 @@ private: void updateGalleryWidth(); LLInventoryGalleryItem* buildGalleryItem(std::string name, LLUUID item_id, LLAssetType::EType type, LLUUID thumbnail_id, LLInventoryType::EType inventory_type, U32 flags, time_t creation_date, bool is_link, bool is_worn); + LLInventoryGalleryItem* getItem(const LLUUID& id) const; void buildGalleryPanel(int row_count); void reshapeGalleryPanel(int row_count); diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 96be917019..22420e8896 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -128,7 +128,7 @@ void LLOutfitGallery::onOpen(const LLSD& info) mScrollPanel->addChild(mGalleryPanel); for (int i = 0; i < n; i++) { - addToGallery(mOutfitMap[cats[i]]); + addToGallery(getItem(cats[i])); } reArrangeRows(); mGalleryCreated = true; @@ -377,7 +377,7 @@ void LLOutfitGallery::onOutfitsRemovalConfirmation(const LLSD& notification, con void LLOutfitGallery::scrollToShowItem(const LLUUID& item_id) { - LLOutfitGalleryItem* item = mOutfitMap[item_id]; + LLOutfitGalleryItem* item = getItem(item_id); if (item) { const LLRect visible_content_rect = mScrollPanel->getVisibleContentRect(); @@ -524,6 +524,10 @@ LLPanel* LLOutfitGallery::addToRow(LLPanel* row_stack, LLOutfitGalleryItem* item void LLOutfitGallery::addToGallery(LLOutfitGalleryItem* item) { + if (!item) + { + return; + } if(item->isHidden()) { mHiddenItems.push_back(item); @@ -631,9 +635,19 @@ LLOutfitGalleryItem* LLOutfitGallery::buildGalleryItem(std::string name, LLUUID return gitem; } -LLOutfitGalleryItem* LLOutfitGallery::getSelectedItem() +LLOutfitGalleryItem* LLOutfitGallery::getSelectedItem() const +{ + return getItem(mSelectedOutfitUUID); +} + +LLOutfitGalleryItem* LLOutfitGallery::getItem(const LLUUID& id) const { - return mOutfitMap[mSelectedOutfitUUID]; + auto it = mOutfitMap.find(id); + if (it != mOutfitMap.end()) + { + return it->second; + } + return nullptr; } void LLOutfitGallery::buildGalleryPanel(int row_count) @@ -1264,7 +1278,15 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) } if (asset_id.notNull()) { - photo_loaded |= mOutfitMap[category_id]->setImageAssetId(asset_id); + LLOutfitGalleryItem* item = getItem(category_id); + if (item) + { + photo_loaded |= item->setImageAssetId(asset_id); + } + else + { + photo_loaded = true; + } // Rename links if (!mOutfitRenamePending.isNull() && mOutfitRenamePending.asString() == item_name) { @@ -1290,13 +1312,21 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) } if (!photo_loaded) { - mOutfitMap[category_id]->setDefaultImage(); + LLOutfitGalleryItem* item = getItem(category_id); + if (item) + { + item->setDefaultImage(); + } } } } else { - mOutfitMap[category_id]->setImageAssetId(asset_id); + LLOutfitGalleryItem* item = getItem(category_id); + if (item) + { + item->setImageAssetId(asset_id); + } } } diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index d921a7fe72..819d09dcf5 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -135,7 +135,8 @@ private: void updateGalleryWidth(); LLOutfitGalleryItem* buildGalleryItem(std::string name, LLUUID outfit_id); - LLOutfitGalleryItem* getSelectedItem(); + LLOutfitGalleryItem* getSelectedItem() const; + LLOutfitGalleryItem* getItem(const LLUUID& id) const; void onTextureSelectionChanged(LLInventoryItem* itemp); |