From 9e4185bf75edbbf313735be56b1aaefcf0d31299 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Sun, 21 Jul 2024 20:10:21 -0400 Subject: Fix rare shutdown crash in gCacheName --- indra/llmessage/llcachename.cpp | 33 ++++++++++++++++----------------- indra/llmessage/llcachename.h | 7 ++++--- indra/newview/llfloateravatarpicker.cpp | 2 +- indra/newview/llinventorybridge.cpp | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 63ac46722a..64f660d0ce 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -53,7 +53,6 @@ const U32 PENDING_TIMEOUT_SECS = 5 * 60; // Globals LLCacheName* gCacheName = NULL; -std::map LLCacheName::sCacheName; /// --------------------------------------------------------------------------- /// class LLCacheNameEntry @@ -215,7 +214,7 @@ public: Impl(LLMessageSystem* msg); ~Impl(); - bool getName(const LLUUID& id, std::string& first, std::string& last); + bool getName(const LLUUID& id, std::string& first, std::string& last, std::map& default_names); boost::signals2::connection addPending(const LLUUID& id, const LLCacheNameCallback& callback); void addPending(const LLUUID& id, const LLHost& host); @@ -247,9 +246,9 @@ LLCacheName::LLCacheName(LLMessageSystem* msg) LLCacheName::LLCacheName(LLMessageSystem* msg, const LLHost& upstream_host) : impl(* new Impl(msg)) { - sCacheName["waiting"] = "(Loading...)"; - sCacheName["nobody"] = "(nobody)"; - sCacheName["none"] = "(none)"; + mCacheName["waiting"] = "(Loading...)"; + mCacheName["nobody"] = "(nobody)"; + mCacheName["none"] = "(none)"; setUpstream(upstream_host); } @@ -274,7 +273,7 @@ LLCacheName::Impl::Impl(LLMessageSystem* msg) LLCacheName::Impl::~Impl() { - for_each(mCache.begin(), mCache.end(), DeletePairedPointer()); + std::for_each(mCache.begin(), mCache.end(), DeletePairedPointer()); mCache.clear(); for_each(mReplyQueue.begin(), mReplyQueue.end(), DeletePointer()); mReplyQueue.clear(); @@ -402,11 +401,11 @@ void LLCacheName::exportFile(std::ostream& ostr) } -bool LLCacheName::Impl::getName(const LLUUID& id, std::string& first, std::string& last) +bool LLCacheName::Impl::getName(const LLUUID& id, std::string& first, std::string& last, std::map& default_names) { if(id.isNull()) { - first = sCacheName["nobody"]; + first = default_names["nobody"]; last.clear(); return true; } @@ -420,7 +419,7 @@ bool LLCacheName::Impl::getName(const LLUUID& id, std::string& first, std::strin } else { - first = sCacheName["waiting"]; + first = default_names["waiting"]; last.clear(); if (!isRequestPending(id)) { @@ -434,8 +433,8 @@ bool LLCacheName::Impl::getName(const LLUUID& id, std::string& first, std::strin // static void LLCacheName::localizeCacheName(std::string key, std::string value) { - if (key!="" && value!= "" ) - sCacheName[key]=value; + if (!key.empty() && !value.empty()) + mCacheName[key]=value; else LL_WARNS()<< " Error localizing cache key " << key << " To "<< value< sCacheName; + void localizeCacheName(std::string key, std::string value); + private: + std::map mCacheName; class Impl; Impl& impl; diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index 6087e6c0ee..08a54b7369 100644 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -300,7 +300,7 @@ void LLFloaterAvatarPicker::populateNearMe() if (!LLAvatarNameCache::get(av, &av_name)) { element["columns"][0]["column"] = "name"; - element["columns"][0]["value"] = LLCacheName::getDefaultName(); + element["columns"][0]["value"] = gCacheName->getDefaultName(); all_loaded = false; } else diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 33d0ac891d..bfa8e39b70 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -6289,7 +6289,7 @@ void LLCallingCardBridge::performAction(LLInventoryModel* model, std::string act if (item && (item->getCreatorUUID() != gAgent.getID()) && (!item->getCreatorUUID().isNull())) { - std::string callingcard_name = LLCacheName::getDefaultName(); + std::string callingcard_name = gCacheName->getDefaultName(); LLAvatarName av_name; if (LLAvatarNameCache::get(item->getCreatorUUID(), &av_name)) { -- cgit v1.2.3