diff options
| author | James Cook <james@lindenlab.com> | 2010-04-27 13:54:40 -0700 | 
|---|---|---|
| committer | James Cook <james@lindenlab.com> | 2010-04-27 13:54:40 -0700 | 
| commit | 56f5a6909d8a665531e3f6ede380cad57e313728 (patch) | |
| tree | ff8ec9b0441a800336030f207e41fc2bc703a7a3 | |
| parent | 6d239f7cfae65e6c8354d9f94061e81e82112a44 (diff) | |
Menu item to disable display names for testing works again
Start up cache in not-running state on viewer.  Set cache running when
idle() is called.  Explicitly refresh name tags when toggled.
Reviewed with Simon
| -rw-r--r-- | indra/llmessage/llavatarnamecache.cpp | 50 | ||||
| -rw-r--r-- | indra/llmessage/llavatarnamecache.h | 13 | ||||
| -rw-r--r-- | indra/newview/llappviewer.cpp | 11 | ||||
| -rw-r--r-- | indra/newview/llstartup.cpp | 4 | ||||
| -rw-r--r-- | indra/newview/llviewermenu.cpp | 2 | 
5 files changed, 51 insertions, 29 deletions
diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 5acecd1dcb..85775f19da 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -44,9 +44,13 @@  namespace LLAvatarNameCache  { -	// Will be turned on and off based on service availability, sometimes -	// in the middle of a session. +	// Manual override for display names - can disable even if the region +	// supports it.  	bool sUseDisplayNames = true; + +	// Cache starts in a paused state until we can determine if the +	// current region supports display names. +	bool sRunning = false;  	// Base lookup URL for name service.  	// On simulator, loaded from indra.xml @@ -318,8 +322,9 @@ void LLAvatarNameCache::requestNamesViaLegacy()  	// JAMESDEBUG TODO  } -void LLAvatarNameCache::initClass() +void LLAvatarNameCache::initClass(bool running)  { +	sRunning = running;  }  void LLAvatarNameCache::cleanupClass() @@ -375,8 +380,16 @@ void LLAvatarNameCache::setNameLookupURL(const std::string& name_lookup_url)  	sNameLookupURL = name_lookup_url;  } +bool LLAvatarNameCache::hasNameLookupURL() +{ +	return !sNameLookupURL.empty(); +} +  void LLAvatarNameCache::idle()  { +	// By convention, start running at first idle() call +	sRunning = true; +  	// 100 ms is the threshold for "user speed" operations, so we can  	// stall for about that long to batch up requests.  	const F32 SECS_BETWEEN_REQUESTS = 0.1f; @@ -405,7 +418,6 @@ void LLAvatarNameCache::idle()  	{  		// ...fall back to legacy name cache system  		requestNamesViaLegacy(); -		llwarns << "JAMESDEBUG legacy lookup call" << llendl;  	}  	// Move requests from Ask queue to Pending queue @@ -451,11 +463,15 @@ void LLAvatarNameCache::eraseExpired()  bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name)  { -	std::map<LLUUID,LLAvatarName>::iterator it = sCache.find(agent_id); -	if (it != sCache.end()) +	if (sRunning)  	{ -		*av_name = it->second; -		return true; +		// ...only do immediate lookups when cache is running +		std::map<LLUUID,LLAvatarName>::iterator it = sCache.find(agent_id); +		if (it != sCache.end()) +		{ +			*av_name = it->second; +			return true; +		}  	}  	if (!isRequestPending(agent_id)) @@ -468,14 +484,18 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name)  void LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot)  { -	std::map<LLUUID,LLAvatarName>::iterator it = sCache.find(agent_id); -	if (it != sCache.end()) +	if (sRunning)  	{ -		// ...name already exists in cache, fire callback now -		callback_signal_t signal; -		signal.connect(slot); -		signal(agent_id, it->second); -		return; +		// ...only do immediate lookups when cache is running +		std::map<LLUUID,LLAvatarName>::iterator it = sCache.find(agent_id); +		if (it != sCache.end()) +		{ +			// ...name already exists in cache, fire callback now +			callback_signal_t signal; +			signal.connect(slot); +			signal(agent_id, it->second); +			return; +		}  	}  	// schedule a request diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index 68a6c28b7b..26cecc5ab5 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -42,7 +42,10 @@ class LLUUID;  namespace LLAvatarNameCache  { -	void initClass(); +	// Until the cache is set running, immediate lookups will fail and +	// async lookups will be queued.  This allows us to block requests +	// until we know if the first region supports display names. +	void initClass(bool running);  	void cleanupClass();  	void importFile(std::istream& istr); @@ -52,6 +55,10 @@ namespace LLAvatarNameCache  	// If empty, name cache will fall back to using legacy name  	// lookup system  	void setNameLookupURL(const std::string& name_lookup_url); + +	// Do we have a valid lookup URL, hence are we trying to use the +	// new display name lookup system? +	bool hasNameLookupURL();  	// Periodically makes a batch request for display names not already in  	// cache.  Call once per frame. @@ -71,9 +78,7 @@ namespace LLAvatarNameCache  	// If name information is in cache, callback will be called immediately.  	void get(const LLUUID& agent_id, callback_slot_t slot); -	// JAMESDEBUG TODO: collapse this with setNameLookupUrl? -	// Not all grids support display names.  If display names are disabled, -	// fall back to old name lookup system. +	// Allow display names to be explicitly disabled for testing.  	void setUseDisplayNames(bool use);  	bool useDisplayNames(); diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 3b236676f1..5df6776fa7 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -3916,6 +3916,7 @@ void LLAppViewer::idleNameCache()  	// granted to neighbor regions before the main agent gets there.  Can't  	// do it in the move-into-region code because cap not guaranteed to be  	// granted yet, for example on teleport. +	bool had_capability = LLAvatarNameCache::hasNameLookupURL();  	std::string name_lookup_url;  	name_lookup_url.reserve(128); // avoid a memory allocation below  	name_lookup_url = region->getCapability("GetDisplayNames"); @@ -3941,19 +3942,11 @@ void LLAppViewer::idleNameCache()  	}  	// Error recovery - did we change state? -	if (LLAvatarNameCache::useDisplayNames() && !have_capability) +	if (had_capability != have_capability)  	{ -		// ...we just lost the capability, turn names off -		LLAvatarNameCache::setUseDisplayNames(false);  		// name tags are persistant on screen, so make sure they refresh  		LLVOAvatar::invalidateNameTags();  	} -	else if (!LLAvatarNameCache::useDisplayNames() && have_capability) -	{ -		// ...we just gained the capability, turn names on -		LLAvatarNameCache::setUseDisplayNames(true); -		LLVOAvatar::invalidateNameTags(); -	}  	LLAvatarNameCache::idle();  } diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 7531853008..2baaf0f58f 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -2771,7 +2771,9 @@ void LLStartUp::initNameCache()  	// Load stored cache if possible  	LLAppViewer::instance()->loadNameCache(); -	LLAvatarNameCache::initClass(); +	// Start cache in not-running state until we figure out if we have +	// capabilities for display name lookup +	LLAvatarNameCache::initClass(false);  }  void LLStartUp::cleanupNameCache() diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index adf71878f5..9fe16b5253 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -7597,6 +7597,8 @@ void toggle_display_names()  {  	bool use = LLAvatarNameCache::useDisplayNames();  	LLAvatarNameCache::setUseDisplayNames(!use); + +	LLVOAvatar::invalidateNameTags();  }  void show_navbar_context_menu(LLView* ctrl, S32 x, S32 y)  | 
