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-enginemeow-7.2.2
parent
fe0d481541
commit
632c287e9a
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue