From 485ad8e645fe05de09035f7386a683116fd680b0 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sat, 26 Jan 2013 01:57:13 -0600 Subject: [PATCH] Reworked name loading for vivox speaker list. LLSpeaker now boost::signals2::trackable to avoid accessing after destruction. Opening new sessions via doubleclick on list(sessions managed by legacyname) or using the mute button(legacyname needed to exclude lindens) are both disabled until namecache lookup complete. --- indra/newview/llfloateractivespeakers.cpp | 25 +++++++++++++---------- indra/newview/llfloateractivespeakers.h | 6 +++++- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/indra/newview/llfloateractivespeakers.cpp b/indra/newview/llfloateractivespeakers.cpp index 5eb9afa32..449027382 100644 --- a/indra/newview/llfloateractivespeakers.cpp +++ b/indra/newview/llfloateractivespeakers.cpp @@ -70,8 +70,6 @@ const LLColor4 INACTIVE_COLOR(0.3f, 0.3f, 0.3f, 0.5f); const LLColor4 ACTIVE_COLOR(0.5f, 0.5f, 0.5f, 1.f); const F32 TYPING_ANIMATION_FPS = 2.5f; -static void on_avatar_name_lookup(const LLUUID&, const LLAvatarName& avatar_name, std::string& mDisplayName); - LLSpeaker::LLSpeaker(const LLUUID& id, const std::string& name, const ESpeakerType type) : mStatus(LLSpeaker::STATUS_TEXT_ONLY), mLastSpokeTime(0.f), @@ -84,7 +82,8 @@ LLSpeaker::LLSpeaker(const LLUUID& id, const std::string& name, const ESpeakerTy mType(type), mIsModerator(FALSE), mModeratorMutedVoice(FALSE), - mModeratorMutedText(FALSE) + mModeratorMutedText(FALSE), + mNameRequested(false) { // Make sure we also get the display name if SLIM or some other external // voice client is used and not whatever is provided. @@ -104,15 +103,14 @@ LLSpeaker::LLSpeaker(const LLUUID& id, const std::string& name, const ESpeakerTy void LLSpeaker::lookupName() { - LLAvatarNameCache::get(mID, boost::bind(&on_avatar_name_lookup, _1, _2, boost::ref(mDisplayName))); - - // Also set the legacy name. We will need it to initiate a new - // IM session. - gCacheName->getFullName(mID, mLegacyName); - mLegacyName = LLCacheName::cleanFullName(mLegacyName); + if(!mNameRequested) + { + mNameRequested = true; + LLAvatarNameCache::get(mID, boost::bind(&LLSpeaker::onNameCache, this, _2)); + } } -static void on_avatar_name_lookup(const LLUUID&, const LLAvatarName& avatar_name, std::string& mDisplayName) +void LLSpeaker::onNameCache(const LLAvatarName& avatar_name) { LLAvatarNameCache::getPNSName(avatar_name, mDisplayName); // [RLVa:KB] - Checked: 2009-07-10 (RLVa-1.0.0g) | Added: RLVa-1.0.0g @@ -120,6 +118,10 @@ static void on_avatar_name_lookup(const LLUUID&, const LLAvatarName& avatar_name if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) mDisplayName = RlvStrings::getAnonym(mDisplayName); // [/RLVa:KB] + + // Also set the legacy name. We will need it to initiate a new + // IM session. + mLegacyName = LLCacheName::cleanFullName(avatar_name.getLegacyName()); } LLSpeakerTextModerationEvent::LLSpeakerTextModerationEvent(LLSpeaker* source) @@ -616,6 +618,7 @@ void LLPanelActiveSpeakers::refreshSpeakers() && selected_speakerp->mType != LLSpeaker::SPEAKER_EXTERNAL // Ansariel: No, we don't want to mute Lindens with display names //&& !LLMuteList::getInstance()->isLinden(selected_speakerp->mDisplayName)); + && !selected_speakerp->mLegacyName.empty() && !LLMuteList::getInstance()->isLinden(selected_speakerp->mLegacyName)); } mVolumeSlider->setValue(gVoiceClient->getUserVolume(selected_id)); @@ -788,7 +791,7 @@ void LLPanelActiveSpeakers::onDoubleClickSpeaker(void* user_data) LLPointer speakerp = panelp->mSpeakerMgr->findSpeaker(speaker_id); - if (speaker_id != gAgent.getID() && speakerp.notNull()) + if (speaker_id != gAgent.getID() && speakerp.notNull() && !speakerp->mLegacyName.empty()) { // Changed for display name support //gIMMgr->addSession(speakerp->mDisplayName, IM_NOTHING_SPECIAL, speaker_id); diff --git a/indra/newview/llfloateractivespeakers.h b/indra/newview/llfloateractivespeakers.h index 757c00bc7..efad321cb 100644 --- a/indra/newview/llfloateractivespeakers.h +++ b/indra/newview/llfloateractivespeakers.h @@ -39,7 +39,9 @@ #include "llvoiceclient.h" #include "llframetimer.h" #include "llevent.h" + #include +#include class LLScrollListCtrl; class LLButton; @@ -52,7 +54,7 @@ class LLCheckBoxCtrl; // data for a given participant in a voice channel -class LLSpeaker : public LLRefCount, public LLOldEvents::LLObservable, public LLHandleProvider +class LLSpeaker : public LLRefCount, public LLOldEvents::LLObservable, public LLHandleProvider, public boost::signals2::trackable { public: typedef enum e_speaker_type @@ -76,6 +78,7 @@ public: LLSpeaker(const LLUUID& id, const std::string& name = LLStringUtil::null, const ESpeakerType type = SPEAKER_AGENT); ~LLSpeaker() {}; void lookupName(); + void onNameCache(const LLAvatarName& avatar_name); ESpeakerStatus mStatus; // current activity status in speech group F32 mLastSpokeTime; // timestamp when this speaker last spoke @@ -92,6 +95,7 @@ public: BOOL mModeratorMutedVoice; BOOL mModeratorMutedText; std::string mLegacyName; + bool mNameRequested; }; class LLSpeakerTextModerationEvent : public LLOldEvents::LLEvent