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/llinventorylistitem.cpp | |
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/llinventorylistitem.cpp')
-rw-r--r-- | indra/newview/llinventorylistitem.cpp | 40 |
1 files changed, 26 insertions, 14 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) |