diff options
author | Mike Antipov <mantipov@productengine.com> | 2010-06-22 11:57:29 +0300 |
---|---|---|
committer | Mike Antipov <mantipov@productengine.com> | 2010-06-22 11:57:29 +0300 |
commit | 632c287e9a03c3a447bdf1981a430cd4487b203b (patch) | |
tree | 7e9a14f1e0d7428195463bea5ac896933617841e /indra/newview | |
parent | fe0d481541a14630d9b40bcb774971a9995efdbd (diff) |
EXT-7928 FIXED replace member pointer to LLViewerInventoryItem with calling LLInventory::getItem()
Reason: access to deleted pointer to LLViewerInventoryItem in LLWearableItemsList::updateChangedItems.
Fix: replaced member pointer to LLViewerInventoryItem with its LLUUID.
Also improved a bit logic of the updateChangedItems() to avoid redundant iterations.
Reviewed by Vadim Savchuk and Neal Orman at https://codereview.productengine.com/secondlife/r/613/
--HG--
branch : product-engine
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llinventorylistitem.cpp | 40 | ||||
-rw-r--r-- | indra/newview/llinventorylistitem.h | 4 | ||||
-rw-r--r-- | indra/newview/llwearableitemslist.cpp | 11 |
3 files changed, 36 insertions, 19 deletions
diff --git a/indra/newview/llinventorylistitem.cpp b/indra/newview/llinventorylistitem.cpp index 18b6de77e2..c487aa10a7 100644 --- a/indra/newview/llinventorylistitem.cpp +++ b/indra/newview/llinventorylistitem.cpp @@ -42,6 +42,7 @@ #include "lltextutil.h" // newview +#include "llinventorymodel.h" #include "llviewerinventory.h" static LLWidgetNameRegistry::StaticRegistrar sRegisterPanelInventoryListItemBaseParams(&typeid(LLPanelInventoryListItemBase::Params), "inventory_list_item"); @@ -68,9 +69,10 @@ void LLPanelInventoryListItemBase::draw() { if (getNeedsRefresh()) { - if (mItem) + LLViewerInventoryItem* inv_item = getItem(); + if (inv_item) { - updateItem(mItem->getName()); + updateItem(inv_item->getName()); } setNeedsRefresh(false); } @@ -135,10 +137,11 @@ BOOL LLPanelInventoryListItemBase::postBuild() setIconCtrl(getChild<LLIconCtrl>("item_icon")); setTitleCtrl(getChild<LLTextBox>("item_name")); - if (mItem) + LLViewerInventoryItem* inv_item = getItem(); + if (inv_item) { - mIconImage = LLInventoryIcon::getIcon(mItem->getType(), mItem->getInventoryType(), mItem->getFlags(), FALSE); - updateItem(mItem->getName()); + mIconImage = LLInventoryIcon::getIcon(inv_item->getType(), inv_item->getInventoryType(), inv_item->getFlags(), FALSE); + updateItem(inv_item->getName()); } setNeedsRefresh(true); @@ -170,38 +173,47 @@ void LLPanelInventoryListItemBase::onMouseLeave(S32 x, S32 y, MASK mask) const std::string& LLPanelInventoryListItemBase::getItemName() const { - if (!mItem) + LLViewerInventoryItem* inv_item = getItem(); + if (NULL == inv_item) { return LLStringUtil::null; } - return mItem->getName(); + return inv_item->getName(); } LLAssetType::EType LLPanelInventoryListItemBase::getType() const { - if (!mItem) + LLViewerInventoryItem* inv_item = getItem(); + if (NULL == inv_item) { return LLAssetType::AT_NONE; } - return mItem->getType(); + return inv_item->getType(); } LLWearableType::EType LLPanelInventoryListItemBase::getWearableType() const { - if (!mItem) + LLViewerInventoryItem* inv_item = getItem(); + if (NULL == inv_item) { return LLWearableType::WT_NONE; } - return mItem->getWearableType(); + return inv_item->getWearableType(); } const std::string& LLPanelInventoryListItemBase::getDescription() const { - if (!mItem) + LLViewerInventoryItem* inv_item = getItem(); + if (NULL == inv_item) { return LLStringUtil::null; } - return mItem->getDescription(); + return inv_item->getDescription(); +} + +LLViewerInventoryItem* LLPanelInventoryListItemBase::getItem() const +{ + return gInventory.getItem(mInventoryItemUUID); } S32 LLPanelInventoryListItemBase::notify(const LLSD& info) @@ -234,7 +246,7 @@ S32 LLPanelInventoryListItemBase::notify(const LLSD& info) LLPanelInventoryListItemBase::LLPanelInventoryListItemBase(LLViewerInventoryItem* item) : LLPanel() -, mItem(item) +, mInventoryItemUUID(item ? item->getUUID() : LLUUID::null) , mIconCtrl(NULL) , mTitleCtrl(NULL) , mWidgetSpacing(WIDGET_SPACING) diff --git a/indra/newview/llinventorylistitem.h b/indra/newview/llinventorylistitem.h index 599431af3f..f29d92d51c 100644 --- a/indra/newview/llinventorylistitem.h +++ b/indra/newview/llinventorylistitem.h @@ -147,7 +147,7 @@ public: const std::string& getDescription() const; /** Get the associated inventory item */ - LLViewerInventoryItem* getItem() const { return mItem; } + LLViewerInventoryItem* getItem() const; virtual ~LLPanelInventoryListItemBase(){} @@ -200,7 +200,7 @@ protected: */ virtual BOOL handleToolTip( S32 x, S32 y, MASK mask); - LLViewerInventoryItem* mItem; + const LLUUID mInventoryItemUUID; private: diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp index 427a0dc34d..832d4a2fe6 100644 --- a/indra/newview/llwearableitemslist.cpp +++ b/indra/newview/llwearableitemslist.cpp @@ -117,7 +117,7 @@ void LLPanelWearableOutfitItem::updateItem(const std::string& name, { std::string search_label = name; - if (mItem && get_is_item_worn(mItem->getUUID())) + if (get_is_item_worn(mInventoryItemUUID)) { search_label += LLTrans::getString("worn"); item_state = IS_WORN; @@ -268,9 +268,10 @@ void LLPanelAttachmentListItem::updateItem(const std::string& name, { std::string title_joint; - if (mItem && isAgentAvatarValid() && gAgentAvatarp->isWearingAttachment(mItem->getLinkedUUID())) + LLViewerInventoryItem* inv_item = getItem(); + if (inv_item && isAgentAvatarValid() && gAgentAvatarp->isWearingAttachment(inv_item->getLinkedUUID())) { - std::string joint = LLTrans::getString(gAgentAvatarp->getAttachedPointName(mItem->getLinkedUUID())); + std::string joint = LLTrans::getString(gAgentAvatarp->getAttachedPointName(inv_item->getLinkedUUID())); title_joint = name + " (" + joint + ")"; } @@ -501,6 +502,9 @@ void LLWearableItemsList::updateList(const LLUUID& category_id) void LLWearableItemsList::updateChangedItems(const LLInventoryModel::changed_items_t& changed_items_uuids) { + // nothing to update + if (changed_items_uuids.empty()) return; + typedef std::vector<LLPanel*> item_panel_list_t; item_panel_list_t items; @@ -525,6 +529,7 @@ void LLWearableItemsList::updateChangedItems(const LLInventoryModel::changed_ite if (linked_uuid == *iter) { item->setNeedsRefresh(true); + break; } } } |