diff options
author | William Todd Stinson <stinson@lindenlab.com> | 2012-11-02 13:22:48 -0700 |
---|---|---|
committer | William Todd Stinson <stinson@lindenlab.com> | 2012-11-02 13:22:48 -0700 |
commit | 6e2b3527cc95b92bf136b65fd2ee344d4c879faa (patch) | |
tree | 5e4aa1dcce13240416b72ab869a9d8463e1dafc6 /indra/newview/llavatarlistitem.cpp | |
parent | b9116764a97dfdccf803315c8c3b0d29fa3ce654 (diff) |
CHUI-475: Ensuring that objects that query the avatar name cache with a callback store the connection and disconnect on object destruction. This should help resolve some of the heap corruption we are seeing.
Diffstat (limited to 'indra/newview/llavatarlistitem.cpp')
-rw-r--r-- | indra/newview/llavatarlistitem.cpp | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/indra/newview/llavatarlistitem.cpp b/indra/newview/llavatarlistitem.cpp index 7b5229b5e6..7ff1b39573 100644 --- a/indra/newview/llavatarlistitem.cpp +++ b/indra/newview/llavatarlistitem.cpp @@ -27,6 +27,8 @@ #include "llviewerprecompiledheaders.h" +#include <boost/signals2.hpp> + #include "llavataractions.h" #include "llavatarlistitem.h" @@ -59,7 +61,8 @@ LLAvatarListItem::Params::Params() LLAvatarListItem::LLAvatarListItem(bool not_from_ui_factory/* = true*/) -: LLPanel(), + : LLPanel(), + LLFriendObserver(), mAvatarIcon(NULL), mAvatarName(NULL), mLastInteractionTime(NULL), @@ -74,7 +77,8 @@ LLAvatarListItem::LLAvatarListItem(bool not_from_ui_factory/* = true*/) mShowInfoBtn(true), mShowProfileBtn(true), mShowPermissions(false), - mHovered(false) + mHovered(false), + mAvatarNameCacheConnection() { if (not_from_ui_factory) { @@ -87,7 +91,14 @@ LLAvatarListItem::LLAvatarListItem(bool not_from_ui_factory/* = true*/) LLAvatarListItem::~LLAvatarListItem() { if (mAvatarId.notNull()) + { LLAvatarTracker::instance().removeParticularFriendObserver(mAvatarId, this); + } + + if (mAvatarNameCacheConnection.connected()) + { + mAvatarNameCacheConnection.disconnect(); + } } BOOL LLAvatarListItem::postBuild() @@ -130,6 +141,19 @@ BOOL LLAvatarListItem::postBuild() return TRUE; } +void LLAvatarListItem::fetchAvatarName() +{ + if (mAvatarNameCacheConnection.connected()) + { + mAvatarNameCacheConnection.disconnect(); + } + + if (mAvatarId.notNull()) + { + mAvatarNameCacheConnection = LLAvatarNameCache::get(getAvatarId(), boost::bind(&LLAvatarListItem::onAvatarNameCache, this, _2)); + } +} + S32 LLAvatarListItem::notifyParent(const LLSD& info) { if (info.has("visibility_changed")) @@ -260,8 +284,7 @@ void LLAvatarListItem::setAvatarId(const LLUUID& id, const LLUUID& session_id, b mAvatarIcon->setValue(id); // Set avatar name. - LLAvatarNameCache::get(id, - boost::bind(&LLAvatarListItem::onAvatarNameCache, this, _2)); + fetchAvatarName(); } } @@ -414,8 +437,7 @@ std::string LLAvatarListItem::getAvatarToolTip() const void LLAvatarListItem::updateAvatarName() { - LLAvatarNameCache::get(getAvatarId(), - boost::bind(&LLAvatarListItem::onAvatarNameCache, this, _2)); + fetchAvatarName(); } //== PRIVATE SECITON ========================================================== |