From fb3df4790e27345a1e45f4a4675e756c1e551f21 Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Tue, 30 Oct 2012 15:59:42 -0700 Subject: CHUI-459: Creating a fetchAvatarName() method for the LLConversationItemParticipant class to allow the class to query for the avatar display name directly. Also, added a field to store the avatar name cache callback connection so that we can disconnect properly on object destruction to avoid a crash with the callback attempting to access recently freed memory. --- indra/newview/llconversationmodel.cpp | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'indra/newview/llconversationmodel.cpp') diff --git a/indra/newview/llconversationmodel.cpp b/indra/newview/llconversationmodel.cpp index 67a1aed675..33631a027b 100644 --- a/indra/newview/llconversationmodel.cpp +++ b/indra/newview/llconversationmodel.cpp @@ -369,7 +369,8 @@ LLConversationItemParticipant::LLConversationItemParticipant(std::string display LLConversationItem(display_name,uuid,root_view_model), mIsMuted(false), mIsModerator(false), - mDistToAgent(-1.0) + mDistToAgent(-1.0), + mAvatarNameCacheConnection() { mConvType = CONV_PARTICIPANT; } @@ -378,11 +379,38 @@ LLConversationItemParticipant::LLConversationItemParticipant(const LLUUID& uuid, LLConversationItem(uuid,root_view_model), mIsMuted(false), mIsModerator(false), - mDistToAgent(-1.0) + mDistToAgent(-1.0), + mAvatarNameCacheConnection() { mConvType = CONV_PARTICIPANT; } +LLConversationItemParticipant::~LLConversationItemParticipant() +{ + // Disconnect any previous avatar name cache connection to ensure + // that the callback method is not called after destruction + if (mAvatarNameCacheConnection.connected()) + { + mAvatarNameCacheConnection.disconnect(); + } +} + +void LLConversationItemParticipant::fetchAvatarName() +{ + // Disconnect any previous avatar name cache connection + if (mAvatarNameCacheConnection.connected()) + { + mAvatarNameCacheConnection.disconnect(); + } + + // Request the avatar name from the cache + llassert(getUUID().notNull()); + if (getUUID().notNull()) + { + mAvatarNameCacheConnection = LLAvatarNameCache::get(getUUID(), boost::bind(&LLConversationItemParticipant::onAvatarNameCache, this, _2)); + } +} + void LLConversationItemParticipant::buildContextMenu(LLMenuGL& menu, U32 flags) { menuentry_vec_t items; -- cgit v1.2.3