diff --git a/.hgtags b/.hgtags
index a700aa94eadc9c53b27be76cf9843c8dfe166500..0e0898afb022e96841dc06bcc2577e034ef87124 100644
--- a/.hgtags
+++ b/.hgtags
@@ -43,3 +43,11 @@ dc6483491b4af559060bccaef8e9045a303212dd 2.4.0-beta1
 25bd6007e3d2fc15db9326ed4b18a24a5969a46a 2.4.0-beta2
 1ed382c6a08ba3850b6ce9061bc551ddece0ea07 2.4.0-release
 a82e5b1e22c7f90e3c7977d146b80588f004ed0d 2.5.0-start
+76f586a8e22b1abe6b2339758c8ac0fa718975de 76f586a8e22b
+76f586a8e22b1abe6b2339758c8ac0fa718975de 76f586a8e22b
+0000000000000000000000000000000000000000 76f586a8e22b
+0000000000000000000000000000000000000000 76f586a8e22b
+345b17e7cf630db77e840b4fe3451bd476d750a3 76f586a8e22b
+345b17e7cf630db77e840b4fe3451bd476d750a3 2.5.0-beta1
+345b17e7cf630db77e840b4fe3451bd476d750a3 76f586a8e22b
+0000000000000000000000000000000000000000 76f586a8e22b
diff --git a/BuildParams b/BuildParams
index 0a4271f7a8bba336d155de09405b4e341d3c08dd..8e036ab56bdf18b1c5415fcbd9d3f1cdc65e1dc7 100644
--- a/BuildParams
+++ b/BuildParams
@@ -26,6 +26,7 @@ viewer-development.show_changes_since = last_sprint
 
 # Build Settings
 viewer-development_coverity.coverity_product = viewer
+viewer-development_coverity.run_tests = false
 viewer-development.build_debug_release_separately = true
 
 # Notifications - to configure email notices, add a setting like this:
diff --git a/build.sh b/build.sh
index cd1d9df6f3e32c7d3784f580a73e125919c3d55d..1c28f5a25596fe6dba76c0e8bca5a08bbee18191 100755
--- a/build.sh
+++ b/build.sh
@@ -66,7 +66,8 @@ pre_build()
     -DRELEASE_CRASH_REPORTING:BOOL=ON \
     -DLOCALIZESETUP:BOOL=ON \
     -DPACKAGE:BOOL=ON \
-    -DCMAKE_VERBOSE_MAKEFILE:BOOL=TRUE
+    -DCMAKE_VERBOSE_MAKEFILE:BOOL=TRUE \
+    -DLL_TESTS:BOOL="$run_tests"
   end_section "Pre$variant"
 }
 
diff --git a/doc/contributions.txt b/doc/contributions.txt
index 361560a0ede667d1ed2f95fa89f1ed65ddcb3483..4e91bbdd3623bb36dab4859c9a004048e8085bbd 100644
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -72,6 +72,7 @@ Aleric Inglewood
 	VWR-10837
 	VWR-12691
 	VWR-12984
+	VWR-13040
 	VWR-13996
 	VWR-14426
 	VWR-24247
@@ -79,6 +80,12 @@ Aleric Inglewood
 	VWR-24252
 	VWR-24254
 	VWR-24261
+	VWR-24315
+	VWR-24317
+	VWR-24320
+    VWR-24321
+ 	VWR-24354
+	VWR-24519
 	SNOW-84
 	SNOW-477
 	SNOW-744
@@ -374,9 +381,12 @@ Jonathan Yap
 	STORM-723
 	STORM-726
 	STORM-737
+	STORM-869
 	STORM-785
 	STORM-812
 	VWR-17801
+	VWR-24347
+	STORM-844
 Kage Pixel
 	VWR-11
 Ken March
@@ -758,6 +768,7 @@ Twisted Laws
 	SNOW-352
 	STORM-466
 	STORM-467
+	STORM-844
 Vadim Bigbear
 	VWR-2681
 Vector Hastings
diff --git a/indra/cmake/Copy3rdPartyLibs.cmake b/indra/cmake/Copy3rdPartyLibs.cmake
index 176ae9787e5523abcc07c89b1465b6a9d25b3f4c..1b08c3fd2ed359c0be4ee14e6ad8dd55674c5f38 100644
--- a/indra/cmake/Copy3rdPartyLibs.cmake
+++ b/indra/cmake/Copy3rdPartyLibs.cmake
@@ -66,6 +66,7 @@ if(WINDOWS)
 if (MSVC80)
     FIND_PATH(debug_msvc8_redist_path msvcr80d.dll
         PATHS
+		${MSVC_DEBUG_REDIST_PATH}
          [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup\\VC;ProductDir]/redist/Debug_NonRedist/x86/Microsoft.VC80.DebugCRT
         NO_DEFAULT_PATH
         NO_DEFAULT_PATH
@@ -90,6 +91,7 @@ if (MSVC80)
 
     FIND_PATH(release_msvc8_redist_path msvcr80.dll
         PATHS
+		${MSVC_REDIST_PATH}
          [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup\\VC;ProductDir]/redist/x86/Microsoft.VC80.CRT
         NO_DEFAULT_PATH
         NO_DEFAULT_PATH
diff --git a/indra/llcommon/llavatarname.cpp b/indra/llcommon/llavatarname.cpp
index b1ec9e9875fde02adad2c946446f460086ae6cfb..ad1845d387a29614ad5956fba454dcdccd9aa236 100644
--- a/indra/llcommon/llavatarname.cpp
+++ b/indra/llcommon/llavatarname.cpp
@@ -48,7 +48,7 @@ LLAvatarName::LLAvatarName()
 	mLegacyFirstName(),
 	mLegacyLastName(),
 	mIsDisplayNameDefault(false),
-	mIsDummy(false),
+	mIsTemporaryName(false),
 	mExpires(F64_MAX),
 	mNextUpdate(0.0)
 { }
diff --git a/indra/llcommon/llavatarname.h b/indra/llcommon/llavatarname.h
index 145aeccd35c1a4e6a738f4b2b5a00d6283e2c91e..ba258d6d52420788bf5256905bff53f2295426a2 100644
--- a/indra/llcommon/llavatarname.h
+++ b/indra/llcommon/llavatarname.h
@@ -79,7 +79,7 @@ class LL_COMMON_API LLAvatarName
 	// Under error conditions, we may insert "dummy" records with
 	// names like "???" into caches as placeholders.  These can be
 	// shown in UI, but are not serialized.
-	bool mIsDummy;
+	bool mIsTemporaryName;
 
 	// Names can change, so need to keep track of when name was
 	// last checked.
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index b46a99e03034160b3598e24427f3072f1f8fc692..39211bf7fa5158f1ccce04111f67a3d3159fd1c6 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -274,11 +274,11 @@ LLImageRaw::LLImageRaw(U8 *data, U16 width, U16 height, S8 components)
 	++sRawImageCount;
 }
 
-LLImageRaw::LLImageRaw(const std::string& filename, bool j2c_lowest_mip_only)
-	: LLImageBase()
-{
-	createFromFile(filename, j2c_lowest_mip_only);
-}
+//LLImageRaw::LLImageRaw(const std::string& filename, bool j2c_lowest_mip_only)
+//	: LLImageBase()
+//{
+//	createFromFile(filename, j2c_lowest_mip_only);
+//}
 
 LLImageRaw::~LLImageRaw()
 {
@@ -1178,7 +1178,7 @@ file_extensions[] =
 	{ "png", IMG_CODEC_PNG }
 };
 #define NUM_FILE_EXTENSIONS LL_ARRAY_SIZE(file_extensions)
-
+#if 0
 static std::string find_file(std::string &name, S8 *codec)
 {
 	std::string tname;
@@ -1196,7 +1196,7 @@ static std::string find_file(std::string &name, S8 *codec)
 	}
 	return std::string("");
 }
-
+#endif
 EImageCodec LLImageBase::getCodecFromExtension(const std::string& exten)
 {
 	for (int i=0; i<(int)(NUM_FILE_EXTENSIONS); i++)
@@ -1206,7 +1206,7 @@ EImageCodec LLImageBase::getCodecFromExtension(const std::string& exten)
 	}
 	return IMG_CODEC_INVALID;
 }
-
+#if 0
 bool LLImageRaw::createFromFile(const std::string &filename, bool j2c_lowest_mip_only)
 {
 	std::string name = filename;
@@ -1313,7 +1313,7 @@ bool LLImageRaw::createFromFile(const std::string &filename, bool j2c_lowest_mip
 
 	return true;
 }
-
+#endif
 //---------------------------------------------------------------------------
 // LLImageFormatted
 //---------------------------------------------------------------------------
diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h
index bca7e915fac8d9f469f6566b46540ba0fbf1f351..825b9aab1a49cefd54b092e05d869d00b15a32b7 100644
--- a/indra/llimage/llimage.h
+++ b/indra/llimage/llimage.h
@@ -164,7 +164,7 @@ class LLImageRaw : public LLImageBase
 	LLImageRaw(U16 width, U16 height, S8 components);
 	LLImageRaw(U8 *data, U16 width, U16 height, S8 components);
 	// Construct using createFromFile (used by tools)
-	LLImageRaw(const std::string& filename, bool j2c_lowest_mip_only = false);
+	//LLImageRaw(const std::string& filename, bool j2c_lowest_mip_only = false);
 
 	/*virtual*/ void deleteData();
 	/*virtual*/ U8* allocateData(S32 size = -1);
@@ -226,7 +226,7 @@ class LLImageRaw : public LLImageBase
 
 protected:
 	// Create an image from a local file (generally used in tools)
-	bool createFromFile(const std::string& filename, bool j2c_lowest_mip_only = false);
+	//bool createFromFile(const std::string& filename, bool j2c_lowest_mip_only = false);
 
 	void copyLineScaled( U8* in, U8* out, S32 in_pixel_len, S32 out_pixel_len, S32 in_pixel_step, S32 out_pixel_step );
 	void compositeRowScaled4onto3( U8* in, U8* out, S32 in_pixel_len, S32 out_pixel_len );
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 14e1ca8d43681ddb7ea7057a89cdb19fa80b88ad..71b92962fb0fc93a20f8a51dcdcf47eead89d9d4 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -4406,19 +4406,54 @@ std::ostream& operator<<(std::ostream &s, const LLVolume *volumep)
 
 BOOL LLVolumeFace::create(LLVolume* volume, BOOL partial_build)
 {
+	BOOL ret = FALSE ;
 	if (mTypeMask & CAP_MASK)
 	{
-		return createCap(volume, partial_build);
+		ret = createCap(volume, partial_build);
 	}
 	else if ((mTypeMask & END_MASK) || (mTypeMask & SIDE_MASK))
 	{
-		return createSide(volume, partial_build);
+		ret = createSide(volume, partial_build);
 	}
 	else
 	{
 		llerrs << "Unknown/uninitialized face type!" << llendl;
-		return FALSE;
 	}
+
+	//update the range of the texture coordinates
+	if(ret)
+	{
+		mTexCoordExtents[0].setVec(1.f, 1.f) ;
+		mTexCoordExtents[1].setVec(0.f, 0.f) ;
+
+		U32 end = mVertices.size() ;
+		for(U32 i = 0 ; i < end ; i++)
+		{
+			if(mTexCoordExtents[0].mV[0] > mVertices[i].mTexCoord.mV[0])
+			{
+				mTexCoordExtents[0].mV[0] = mVertices[i].mTexCoord.mV[0] ;
+			}
+			if(mTexCoordExtents[1].mV[0] < mVertices[i].mTexCoord.mV[0])
+			{
+				mTexCoordExtents[1].mV[0] = mVertices[i].mTexCoord.mV[0] ;
+			}
+
+			if(mTexCoordExtents[0].mV[1] > mVertices[i].mTexCoord.mV[1])
+			{
+				mTexCoordExtents[0].mV[1] = mVertices[i].mTexCoord.mV[1] ;
+			}
+			if(mTexCoordExtents[1].mV[1] < mVertices[i].mTexCoord.mV[1])
+			{
+				mTexCoordExtents[1].mV[1] = mVertices[i].mTexCoord.mV[1] ;
+			}			
+		}
+		mTexCoordExtents[0].mV[0] = llmax(0.f, mTexCoordExtents[0].mV[0]) ;
+		mTexCoordExtents[0].mV[1] = llmax(0.f, mTexCoordExtents[0].mV[1]) ;
+		mTexCoordExtents[1].mV[0] = llmin(1.f, mTexCoordExtents[1].mV[0]) ;
+		mTexCoordExtents[1].mV[1] = llmin(1.f, mTexCoordExtents[1].mV[1]) ;
+	}
+
+	return ret ;
 }
 
 void	LerpPlanarVertex(LLVolumeFace::VertexData& v0,
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index d48a79ee46aa4206868fa69f83445dbf2aec69db..28b9895ff39ce3f3e347590ff7873a8512d779d5 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -831,6 +831,7 @@ class LLVolumeFace
 	S32 mNumT;
 
 	LLVector3 mExtents[2]; //minimum and maximum point of face
+	LLVector2 mTexCoordExtents[2]; //minimum and maximum of texture coordinates of the face.
 
 	std::vector<VertexData> mVertices;
 	std::vector<U16>	mIndices;
diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp
index 03c28eb2a56bae5c34059273f637ec3a76fe4a79..767001b6337ad05a358914ef3406331aa3effa4a 100644
--- a/indra/llmessage/llavatarnamecache.cpp
+++ b/indra/llmessage/llavatarnamecache.cpp
@@ -81,8 +81,11 @@ namespace LLAvatarNameCache
 	// only need per-frame timing resolution
 	LLFrameTimer sRequestTimer;
 
-	// Periodically clean out expired entries from the cache
-	//LLFrameTimer sEraseExpiredTimer;
+    /// Maximum time an unrefreshed cache entry is allowed
+    const F64 MAX_UNREFRESHED_TIME = 20.0 * 60.0;
+
+    /// Time when unrefreshed cached names were checked last
+    static F64 sLastExpireCheck;
 
 	//-----------------------------------------------------------------------
 	// Internal methods
@@ -99,8 +102,9 @@ namespace LLAvatarNameCache
 
 	// Legacy name system callback
 	void legacyNameCallback(const LLUUID& agent_id,
-		const std::string& full_name,
-		bool is_group);
+							const std::string& full_name,
+							bool is_group
+							);
 
 	void requestNamesViaLegacy();
 
@@ -117,7 +121,7 @@ namespace LLAvatarNameCache
 	bool isRequestPending(const LLUUID& agent_id);
 
 	// Erase expired names from cache
-	void eraseExpired();
+	void eraseUnrefreshed();
 
 	bool expirationFromCacheControl(LLSD headers, F64 *expires);
 }
@@ -187,6 +191,7 @@ class LLAvatarNameResponder : public LLHTTPClient::Responder
 	{
 		// Pull expiration out of headers if available
 		F64 expires = LLAvatarNameCache::nameExpirationFromHeaders(mHeaders);
+		F64 now = LLFrameTimer::getTotalSeconds();
 
 		LLSD agents = content["agents"];
 		LLSD::array_const_iterator it = agents.beginArray();
@@ -207,84 +212,91 @@ class LLAvatarNameResponder : public LLHTTPClient::Responder
 				av_name.mDisplayName = av_name.mUsername;
 			}
 
+			LL_DEBUGS("AvNameCache") << "LLAvatarNameResponder::result for " << agent_id << " "
+									 << "user '" << av_name.mUsername << "' "
+									 << "display '" << av_name.mDisplayName << "' "
+									 << "expires in " << expires - now << " seconds"
+									 << LL_ENDL;
+			
 			// cache it and fire signals
 			LLAvatarNameCache::processName(agent_id, av_name, true);
 		}
 
 		// Same logic as error response case
 		LLSD unresolved_agents = content["bad_ids"];
-		if (unresolved_agents.size() > 0)
+		S32  num_unresolved = unresolved_agents.size();
+		if (num_unresolved > 0)
 		{
-			const std::string DUMMY_NAME("\?\?\?");
-			LLAvatarName av_name;
-			av_name.mUsername = DUMMY_NAME;
-			av_name.mDisplayName = DUMMY_NAME;
-			av_name.mIsDisplayNameDefault = false;
-			av_name.mIsDummy = true;
-			av_name.mExpires = expires;
-
+            LL_WARNS("AvNameCache") << "LLAvatarNameResponder::result " << num_unresolved << " unresolved ids; "
+                                    << "expires in " << expires - now << " seconds"
+                                    << LL_ENDL;
 			it = unresolved_agents.beginArray();
 			for ( ; it != unresolved_agents.endArray(); ++it)
 			{
 				const LLUUID& agent_id = *it;
-				// cache it and fire signals
-				LLAvatarNameCache::processName(agent_id, av_name, true);
+
+				LL_WARNS("AvNameCache") << "LLAvatarNameResponder::result "
+                                        << "failed id " << agent_id
+                                        << LL_ENDL;
+
+                LLAvatarNameCache::handleAgentError(agent_id);
 			}
 		}
-	}
+        LL_DEBUGS("AvNameCache") << "LLAvatarNameResponder::result " 
+                                 << LLAvatarNameCache::sCache.size() << " cached names"
+                                 << LL_ENDL;
+    }
 
 	/*virtual*/ void error(U32 status, const std::string& reason)
 	{
 		// If there's an error, it might be caused by PeopleApi,
 		// or when loading textures on startup and using a very slow 
-		// network, this query may time out. Fallback to the legacy
-		// cache. 
-
-		llwarns << "LLAvatarNameResponder error " << status << " " << reason << llendl;
+		// network, this query may time out.
+		// What we should do depends on whether or not we have a cached name
+		LL_WARNS("AvNameCache") << "LLAvatarNameResponder::error " << status << " " << reason
+								<< LL_ENDL;
 
-		// Add dummy records for all agent IDs in this request
+		// Add dummy records for any agent IDs in this request that we do not have cached already
 		std::vector<LLUUID>::const_iterator it = mAgentIDs.begin();
 		for ( ; it != mAgentIDs.end(); ++it)
 		{
 			const LLUUID& agent_id = *it;
-			gCacheName->get(agent_id, false,  // legacy compatibility
-						boost::bind(&LLAvatarNameCache::legacyNameCallback,
-						_1, _2, _3));
-		}
-	}
-
-	// Return time to retry a request that generated an error, based on
-	// error type and headers.  Return value is seconds-since-epoch.
-	F64 errorRetryTimestamp(S32 status)
-	{
-		F64 now = LLFrameTimer::getTotalSeconds();
-
-		// Retry-After takes priority
-		LLSD retry_after = mHeaders["retry-after"];
-		if (retry_after.isDefined())
-		{
-			// We only support the delta-seconds type
-			S32 delta_seconds = retry_after.asInteger();
-			if (delta_seconds > 0)
-			{
-				// ...valid delta-seconds
-				return now + F64(delta_seconds);
-			}
+			LLAvatarNameCache::handleAgentError(agent_id);
 		}
-
-		// If no Retry-After, look for Cache-Control max-age
-		F64 expires = 0.0;
-		if (LLAvatarNameCache::expirationFromCacheControl(mHeaders, &expires))
-		{
-			return expires;
-		}
-
-		// No information in header, make a guess
-		const F64 DEFAULT_DELAY = 120.0; // 2 mintues
-		return now + DEFAULT_DELAY;
 	}
 };
 
+// Provide some fallback for agents that return errors
+void LLAvatarNameCache::handleAgentError(const LLUUID& agent_id)
+{
+	std::map<LLUUID,LLAvatarName>::iterator existing = sCache.find(agent_id);
+	if (existing == sCache.end())
+    {
+        // there is no existing cache entry, so make a temporary name from legacy
+        LL_WARNS("AvNameCache") << "LLAvatarNameCache get legacy for agent "
+                                << agent_id << LL_ENDL;
+        gCacheName->get(agent_id, false,  // legacy compatibility
+                        boost::bind(&LLAvatarNameCache::legacyNameCallback,
+                                    _1, _2, _3));
+    }
+	else
+    {
+        // we have a chached (but probably expired) entry - since that would have
+        // been returned by the get method, there is no need to signal anyone
+
+        // Clear this agent from the pending list
+        LLAvatarNameCache::sPendingQueue.erase(agent_id);
+
+        const LLAvatarName& av_name = existing->second;
+        LL_DEBUGS("AvNameCache") << "LLAvatarNameCache use cache for agent "
+                                 << agent_id 
+                                 << "user '" << av_name.mUsername << "' "
+                                 << "display '" << av_name.mDisplayName << "' "
+                                 << "expires in " << av_name.mExpires - LLFrameTimer::getTotalSeconds() << " seconds"
+                                 << LL_ENDL;
+    }
+}
+
 void LLAvatarNameCache::processName(const LLUUID& agent_id,
 									const LLAvatarName& av_name,
 									bool add_to_cache)
@@ -326,6 +338,7 @@ void LLAvatarNameCache::requestNamesViaCapability()
 	std::vector<LLUUID> agent_ids;
 	agent_ids.reserve(128);
 	
+	U32 ids = 0;
 	ask_queue_t::const_iterator it = sAskQueue.begin();
 	for ( ; it != sAskQueue.end(); ++it)
 	{
@@ -336,11 +349,13 @@ void LLAvatarNameCache::requestNamesViaCapability()
 			// ...starting new request
 			url += sNameLookupURL;
 			url += "?ids=";
+			ids = 1;
 		}
 		else
 		{
 			// ...continuing existing request
 			url += "&ids=";
+			ids++;
 		}
 		url += agent_id.asString();
 		agent_ids.push_back(agent_id);
@@ -350,8 +365,10 @@ void LLAvatarNameCache::requestNamesViaCapability()
 
 		if (url.size() > NAME_URL_SEND_THRESHOLD)
 		{
-			//llinfos << "requestNames " << url << llendl;
-			LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids));//, LLSD(), 10.0f);
+			LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaCapability first "
+									 << ids << " ids"
+									 << LL_ENDL;
+			LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids));
 			url.clear();
 			agent_ids.clear();
 		}
@@ -359,8 +376,10 @@ void LLAvatarNameCache::requestNamesViaCapability()
 
 	if (!url.empty())
 	{
-		//llinfos << "requestNames " << url << llendl;
-		LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids));//, LLSD(), 10.0f);
+		LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaCapability all "
+								 << ids << " ids"
+								 << LL_ENDL;
+		LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids));
 		url.clear();
 		agent_ids.clear();
 	}
@@ -376,6 +395,11 @@ void LLAvatarNameCache::legacyNameCallback(const LLUUID& agent_id,
 	// Construct a dummy record for this name.  By convention, SLID is blank
 	// Never expires, but not written to disk, so lasts until end of session.
 	LLAvatarName av_name;
+	LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::legacyNameCallback "
+							 << "agent " << agent_id << " "
+							 << "full name '" << full_name << "'"
+							 << ( is_group ? " [group]" : "" )
+							 << LL_ENDL;
 	buildLegacyName(full_name, &av_name);
 
 	// Don't add to cache, the data already exists in the legacy name system
@@ -397,6 +421,8 @@ void LLAvatarNameCache::requestNamesViaLegacy()
 		// invoked below.  This should never happen in practice.
 		sPendingQueue[agent_id] = now;
 
+		LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaLegacy agent " << agent_id << LL_ENDL;
+
 		gCacheName->get(agent_id, false,  // legacy compatibility
 			boost::bind(&LLAvatarNameCache::legacyNameCallback,
 				_1, _2, _3));
@@ -435,21 +461,24 @@ void LLAvatarNameCache::importFile(std::istream& istr)
 		av_name.fromLLSD( it->second );
 		sCache[agent_id] = av_name;
 	}
-	// entries may have expired since we last ran the viewer, just
-	// clean them out now
-	eraseExpired();
-	llinfos << "loaded " << sCache.size() << llendl;
+    LL_INFOS("AvNameCache") << "loaded " << sCache.size() << LL_ENDL;
+
+	// Some entries may have expired since the cache was stored,
+    // but they will be flushed in the first call to eraseUnrefreshed
+    // from LLAvatarNameResponder::idle
 }
 
 void LLAvatarNameCache::exportFile(std::ostream& ostr)
 {
 	LLSD agents;
+	F64 max_unrefreshed = LLFrameTimer::getTotalSeconds() - MAX_UNREFRESHED_TIME;
 	cache_t::const_iterator it = sCache.begin();
 	for ( ; it != sCache.end(); ++it)
 	{
 		const LLUUID& agent_id = it->first;
 		const LLAvatarName& av_name = it->second;
-		if (!av_name.mIsDummy)
+		// Do not write temporary or expired entries to the stored cache
+		if (!av_name.mIsTemporaryName && av_name.mExpires >= max_unrefreshed)
 		{
 			// key must be a string
 			agents[agent_id.asString()] = av_name.asLLSD();
@@ -484,62 +513,63 @@ void LLAvatarNameCache::idle()
 	//	return;
 	//}
 
-	// Must be large relative to above
-
-	// No longer deleting expired entries, just re-requesting in the get
-	// this way first synchronous get call on an expired entry won't return
-	// legacy name.  LF
-
-	//const F32 ERASE_EXPIRED_TIMEOUT = 60.f; // seconds
-	//if (sEraseExpiredTimer.checkExpirationAndReset(ERASE_EXPIRED_TIMEOUT))
-	//{
-	//	eraseExpired();
-	//}
-
-	if (sAskQueue.empty())
+	if (!sAskQueue.empty())
 	{
-		return;
+        if (useDisplayNames())
+        {
+            requestNamesViaCapability();
+        }
+        else
+        {
+            // ...fall back to legacy name cache system
+            requestNamesViaLegacy();
+        }
 	}
 
-	if (useDisplayNames())
-	{
-		requestNamesViaCapability();
-	}
-	else
-	{
-		// ...fall back to legacy name cache system
-		requestNamesViaLegacy();
-	}
+    // erase anything that has not been refreshed for more than MAX_UNREFRESHED_TIME
+    eraseUnrefreshed();
 }
 
 bool LLAvatarNameCache::isRequestPending(const LLUUID& agent_id)
 {
+	bool isPending = false;
 	const F64 PENDING_TIMEOUT_SECS = 5.0 * 60.0;
-	F64 now = LLFrameTimer::getTotalSeconds();
-	F64 expire_time = now - PENDING_TIMEOUT_SECS;
 
 	pending_queue_t::const_iterator it = sPendingQueue.find(agent_id);
 	if (it != sPendingQueue.end())
 	{
-		bool request_expired = (it->second < expire_time);
-		return !request_expired;
+		// in the list of requests in flight, retry if too old
+		F64 expire_time = LLFrameTimer::getTotalSeconds() - PENDING_TIMEOUT_SECS;
+		isPending = (it->second > expire_time);
 	}
-	return false;
+	return isPending;
 }
 
-void LLAvatarNameCache::eraseExpired()
+void LLAvatarNameCache::eraseUnrefreshed()
 {
 	F64 now = LLFrameTimer::getTotalSeconds();
-	cache_t::iterator it = sCache.begin();
-	while (it != sCache.end())
-	{
-		cache_t::iterator cur = it;
-		++it;
-		const LLAvatarName& av_name = cur->second;
-		if (av_name.mExpires < now)
-		{
-			sCache.erase(cur);
-		}
+	F64 max_unrefreshed = now - MAX_UNREFRESHED_TIME;
+
+    if (!sLastExpireCheck || sLastExpireCheck < max_unrefreshed)
+    {
+        sLastExpireCheck = now;
+        cache_t::iterator it = sCache.begin();
+        while (it != sCache.end())
+        {
+            cache_t::iterator cur = it;
+            ++it;
+            const LLAvatarName& av_name = cur->second;
+            if (av_name.mExpires < max_unrefreshed)
+            {
+                const LLUUID& agent_id = it->first;
+                LL_DEBUGS("AvNameCache") << agent_id 
+                                         << " user '" << av_name.mUsername << "' "
+                                         << "expired " << now - av_name.mExpires << " secs ago"
+                                         << LL_ENDL;
+                sCache.erase(cur);
+            }
+        }
+        LL_INFOS("AvNameCache") << sCache.size() << " cached avatar names" << LL_ENDL;
 	}
 }
 
@@ -550,8 +580,11 @@ void LLAvatarNameCache::buildLegacyName(const std::string& full_name,
 	av_name->mUsername = "";
 	av_name->mDisplayName = full_name;
 	av_name->mIsDisplayNameDefault = true;
-	av_name->mIsDummy = true;
-	av_name->mExpires = F64_MAX;
+	av_name->mIsTemporaryName = true;
+	av_name->mExpires = F64_MAX; // not used because these are not cached
+	LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::buildLegacyName "
+							 << full_name
+							 << LL_ENDL;
 }
 
 // fills in av_name if it has it in the cache, even if expired (can check expiry time)
@@ -574,6 +607,9 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name)
 				{
 					if (!isRequestPending(agent_id))
 					{
+						LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::get "
+												 << "refresh agent " << agent_id
+												 << LL_ENDL;
 						sAskQueue.insert(agent_id);
 					}
 				}
@@ -595,6 +631,9 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name)
 
 	if (!isRequestPending(agent_id))
 	{
+		LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::get "
+								 << "queue request for agent " << agent_id
+								 << LL_ENDL;
 		sAskQueue.insert(agent_id);
 	}
 
@@ -627,7 +666,6 @@ void LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot)
 				{
 					// ...name already exists in cache, fire callback now
 					fireSignal(agent_id, slot, av_name);
-
 					return;
 				}
 			}
@@ -723,6 +761,9 @@ F64 LLAvatarNameCache::nameExpirationFromHeaders(LLSD headers)
 
 bool LLAvatarNameCache::expirationFromCacheControl(LLSD headers, F64 *expires)
 {
+	bool fromCacheControl = false;
+	F64 now = LLFrameTimer::getTotalSeconds();
+
 	// Allow the header to override the default
 	LLSD cache_control_header = headers["cache-control"];
 	if (cache_control_header.isDefined())
@@ -731,12 +772,16 @@ bool LLAvatarNameCache::expirationFromCacheControl(LLSD headers, F64 *expires)
 		std::string cache_control = cache_control_header.asString();
 		if (max_age_from_cache_control(cache_control, &max_age))
 		{
-			F64 now = LLFrameTimer::getTotalSeconds();
 			*expires = now + (F64)max_age;
-			return true;
+			fromCacheControl = true;
 		}
 	}
-	return false;
+	LL_DEBUGS("AvNameCache")
+		<< ( fromCacheControl ? "expires based on cache control " : "default expiration " )
+		<< "in " << *expires - now << " seconds"
+		<< LL_ENDL;
+	
+	return fromCacheControl;
 }
 
 
diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h
index 8f21ace96a5ae5774e8105a51a292bb7a1ad3318..59c1329ffa5db3ac04a0775434a0a928f7bf2981 100644
--- a/indra/llmessage/llavatarnamecache.h
+++ b/indra/llmessage/llavatarnamecache.h
@@ -82,6 +82,9 @@ namespace LLAvatarNameCache
 
 	void erase(const LLUUID& agent_id);
 
+    /// Provide some fallback for agents that return errors
+	void handleAgentError(const LLUUID& agent_id);
+
 	// Force a re-fetch of the most recent data, but keep the current
 	// data in cache
 	void fetch(const LLUUID& agent_id);
diff --git a/indra/llmessage/llcircuit.cpp b/indra/llmessage/llcircuit.cpp
index 3ba2dfb104a975b3bbef5fb8fcea11ac4e712484..e0410906fb6d6ae974eaabba31902bd6058814d5 100644
--- a/indra/llmessage/llcircuit.cpp
+++ b/indra/llmessage/llcircuit.cpp
@@ -87,6 +87,7 @@ LLCircuitData::LLCircuitData(const LLHost &host, TPACKETID in_id,
 	mPingDelayAveraged((F32)INITIAL_PING_VALUE_MSEC), 
 	mUnackedPacketCount(0),
 	mUnackedPacketBytes(0),
+	mLastPacketInTime(0.0),
 	mLocalEndPointID(),
 	mPacketsOut(0),
 	mPacketsIn(0), 
@@ -667,6 +668,8 @@ void LLCircuitData::checkPacketInID(TPACKETID id, BOOL receive_resent)
 		mHighestPacketID = llmax(mHighestPacketID, id);
 	}
 
+	// Save packet arrival time
+	mLastPacketInTime = LLMessageSystem::getMessageTimeSeconds();
 
 	// Have we received anything on this circuit yet?
 	if (0 == mPacketsIn)
diff --git a/indra/llmessage/llcircuit.h b/indra/llmessage/llcircuit.h
index 874c0c0beea8ca53e2b67276bbe2db9463f3470d..d1c400c6a2491a278772f1c8559b0904650fa2db 100644
--- a/indra/llmessage/llcircuit.h
+++ b/indra/llmessage/llcircuit.h
@@ -122,7 +122,7 @@ class LLCircuitData
 	U32			getPacketsLost() const;
 	TPACKETID	getPacketOutID() const;
 	BOOL		getTrusted() const;
-	F32 getAgeInSeconds() const;
+	F32			getAgeInSeconds() const;
 	S32			getUnackedPacketCount() const	{ return mUnackedPacketCount; }
 	S32			getUnackedPacketBytes() const	{ return mUnackedPacketBytes; }
 	F64         getNextPingSendTime() const { return mNextPingSendTime; }
@@ -130,6 +130,7 @@ class LLCircuitData
                     { return mOutOfOrderRate.meanValue(scale); }
     U32         getLastPacketGap() const { return mLastPacketGap; }
     LLHost      getHost() const { return mHost; }
+	F64			getLastPacketInTime() const		{ return mLastPacketInTime;	}
 
 	LLThrottleGroup &getThrottleGroup()		{	return mThrottles; }
 
@@ -248,6 +249,7 @@ class LLCircuitData
 	S32										mUnackedPacketCount;
 	S32										mUnackedPacketBytes;
 
+	F64										mLastPacketInTime;		// Time of last packet arrival
 
 	LLUUID									mLocalEndPointID;
 
diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp
index 3c1d031ff5d8b72d46d1233c63446b9c88a7cc23..861bde5c89285bceae0bb9e730a233ab353ae812 100644
--- a/indra/llprimitive/lltextureentry.cpp
+++ b/indra/llprimitive/lltextureentry.cpp
@@ -403,7 +403,7 @@ S32 LLTextureEntry::setOffsetT(F32 t)
 
 S32 LLTextureEntry::setRotation(F32 theta)
 {
-	if (mRotation != theta)
+	if (mRotation != theta && llfinite(theta))
 	{
 		mRotation = theta;
 		return TEM_CHANGE_TEXTURE;
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 65940cb0671927e00db801963b8be315c4c73424..e8e98211f1c1db2e2380bfa848712946f5be6afc 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -1063,16 +1063,6 @@ BOOL LLImageGL::setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_
 {
 	if (gGL.getTexUnit(0)->bind(this, false, true))
 	{
-		if(gGLManager.mDebugGPU)
-		{
-			llinfos << "Calling glCopyTexSubImage2D(...)" << llendl ;
-			checkTexSize(true) ;
-			llcallstacks << fb_x << " : " << fb_y << " : " << x_pos << " : " << y_pos << " : " << width << " : " << height <<
-				" : " << (S32)mComponents << llcallstacksendl ;
-
-			log_glerror() ;
-		}
-
 		glCopyTexSubImage2D(GL_TEXTURE_2D, 0, fb_x, fb_y, x_pos, y_pos, width, height);
 		mGLTextureCreated = true;
 		stop_glerror();
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp
index cd0f0e36b0509d5d40bc311b4d5f8c2be8589ac7..cc9edfcdeabbc92c1cc05a05962608cf5adf5b86 100644
--- a/indra/llui/llnotifications.cpp
+++ b/indra/llui/llnotifications.cpp
@@ -1367,7 +1367,6 @@ LLNotifications::TemplateNames LLNotifications::getTemplateNames() const
 typedef std::map<std::string, std::string> StringMap;
 void replaceSubstitutionStrings(LLXMLNodePtr node, StringMap& replacements)
 {
-	//llwarns << "replaceSubstitutionStrings" << llendl;
 	// walk the list of attributes looking for replacements
 	for (LLXMLAttribList::iterator it=node->mAttributes.begin();
 		 it != node->mAttributes.end(); ++it)
@@ -1381,13 +1380,12 @@ void replaceSubstitutionStrings(LLXMLNodePtr node, StringMap& replacements)
 			if (found != replacements.end())
 			{
 				replacement = found->second;
-				//llwarns << "replaceSubstituionStrings: value: " << value << " repl: " << replacement << llendl;
-
+				lldebugs << "replaceSubstitutionStrings: value: \"" << value << "\" repl: \"" << replacement << "\"." << llendl;
 				it->second->setValue(replacement);
 			}
 			else
 			{
-				llwarns << "replaceSubstituionStrings FAILURE: value: " << value << " repl: " << replacement << llendl;
+				llwarns << "replaceSubstitutionStrings FAILURE: could not find replacement \"" << value << "\"." << llendl;
 			}
 		}
 	}
diff --git a/indra/llvfs/lldir.cpp b/indra/llvfs/lldir.cpp
index 64556bcb4c34dcacd2b48f391dbfebf0eb528421..cb898e385f91b84a9d027eebce9923240526d92e 100644
--- a/indra/llvfs/lldir.cpp
+++ b/indra/llvfs/lldir.cpp
@@ -101,10 +101,18 @@ S32 LLDir::deleteFilesInDir(const std::string &dirname, const std::string &mask)
 		{
 			if (0 != LLFile::remove(fullpath))
 			{
+				retry_count++;
 				result = errno;
 				llwarns << "Problem removing " << fullpath << " - errorcode: "
 						<< result << " attempt " << retry_count << llendl;
-				ms_sleep(1000);
+
+				if(retry_count >= 5)
+				{
+					llwarns << "Failed to remove " << fullpath << llendl ;
+					return count ;
+				}
+
+				ms_sleep(100);
 			}
 			else
 			{
@@ -113,8 +121,7 @@ S32 LLDir::deleteFilesInDir(const std::string &dirname, const std::string &mask)
 					llwarns << "Successfully removed " << fullpath << llendl;
 				}
 				break;
-			}
-			retry_count++;
+			}			
 		}
 		count++;
 	}
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 5d2342e92568471d4bbd2aec66de721f9c15c73a..af6beacdfa9a69e6f2bc3858dde7a6ff7f8b9cee 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -1718,6 +1718,17 @@ set(ARTWORK_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH
 if (LINUX)
   set(product SecondLife-${ARCH}-${viewer_VERSION})
 
+  # These are the generated targets that are copied to package/
+  set(COPY_INPUT_DEPENDENCIES
+	${VIEWER_BINARY_NAME}
+	linux-crash-logger
+	linux-updater
+	SLPlugin
+	media_plugin_webkit
+	media_plugin_gstreamer010
+	llcommon
+	)
+
   add_custom_command(
       OUTPUT ${product}.tar.bz2
       COMMAND ${PYTHON_EXECUTABLE}
@@ -1735,18 +1746,11 @@ if (LINUX)
         --login_channel=${VIEWER_LOGIN_CHANNEL}
         --source=${CMAKE_CURRENT_SOURCE_DIR}
         --touch=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/.${product}.touched
-      DEPENDS ${VIEWER_BINARY_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py
+      DEPENDS
+        ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py
+        ${COPY_INPUT_DEPENDENCIES}
       )
 
-  add_dependencies(${VIEWER_BINARY_NAME} SLPlugin media_plugin_gstreamer010 media_plugin_webkit)
-
-  if (PACKAGE)
-    add_custom_target(package ALL DEPENDS ${product}.tar.bz2)
-    add_dependencies(package linux-crash-logger-target)
-    add_dependencies(package linux-updater-target)
-    check_message_template(package)
-  endif (PACKAGE)
-
   add_custom_command(
     OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/.${product}.copy_touched
     COMMAND ${PYTHON_EXECUTABLE}
@@ -1766,9 +1770,15 @@ if (LINUX)
       ${COPY_INPUT_DEPENDENCIES}
     COMMENT "Performing viewer_manifest copy"
     )
-    
+
   add_custom_target(copy_l_viewer_manifest ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/.${product}.copy_touched) 
-  add_dependencies(copy_l_viewer_manifest "${VIEWER_BINARY_NAME}" linux-crash-logger-target linux-updater-target)
+
+  if (PACKAGE)
+    add_custom_target(package ALL DEPENDS ${product}.tar.bz2)
+    # Make sure we don't run two instances of viewer_manifest.py at the same time.
+    add_dependencies(package copy_l_viewer_manifest)
+    check_message_template(package)
+  endif (PACKAGE)
 endif (LINUX)
 
 if (DARWIN)
diff --git a/indra/newview/app_settings/lindenlab.pem b/indra/newview/app_settings/lindenlab.pem
index cf88d0e04799bf09835f2c78959e9e8bce3d75f9..eddae0426def81a5524850381d29b865bf87b22e 100644
--- a/indra/newview/app_settings/lindenlab.pem
+++ b/indra/newview/app_settings/lindenlab.pem
@@ -24,4 +24,74 @@ xA39CIJ65Zozs28Eg1aV9/Y+Of7TnWhW+U3J3/wD/GghaAGiKK6vMn9gJBIdBX/9
 e6ef37VGyiOEFFjnUIbuk0RWty0orN76q/lI/xjCi15XSA/VSq2j4vmnwfZcPTDu
 glmQ1A==
 -----END CERTIFICATE-----
-
+-----BEGIN CERTIFICATE-----
+MIIEkDCCA3igAwIBAgICTSUwDQYJKoZIhvcNAQEFBQAwQDELMAkGA1UEBhMCVVMx
+FzAVBgNVBAoTDkdlb1RydXN0LCBJbmMuMRgwFgYDVQQDEw9HZW9UcnVzdCBTU0wg
+Q0EwHhcNMTAxMjIwMTkxMTI2WhcNMTIwMjIxMTI1NDAzWjCBnzEpMCcGA1UEBRMg
+UkMteW9jbXIwdXRmRTdOMVBlaHJHQXdqL0lNc2hJZS0xCzAJBgNVBAYTAlVTMRMw
+EQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4gRnJhbmNpc2NvMR0wGwYD
+VQQKExRMaW5kZW4gUmVzZWFyY2ggSW5jLjEZMBcGA1UEAwwQKi5zZWNvbmRsaWZl
+LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAN/VCCu1SZ5x4vNp
+XZZ8r3lzqeLwjxVZfMSQCKM4lV5DFbqiZMMBto4Y/ib7i0audzuTDnImCLsfzlTu
+7iZLoJNy42/43Rq4xtaDZ7joxALFmzXUKEipgHiTTbAbLQNCS4wPXts3tScODVZY
+/mhlmXdlLuGxJbqoyOEP6NEQbgXWDCKDERnAEG/FJBVHKyBfg3abrrIuQNwYCKCS
+2OZ5Z5MveGmY4tSKUOOi/c0vV9HsanQn/ymybZjxR5Kmb1CvQr7VVtbpR1MhlGkc
+sfJz1NFIFxdXkUggIny+XSG1dAAJRFFumyRM+X/eh0NHNmAI14JJ43hB6Zw3dzzl
+An9BSeECAwEAAaOCATIwggEuMB8GA1UdIwQYMBaAFEJ5VBthzVUrPmPVPEhX9Z/7
+Rc5KMA4GA1UdDwEB/wQEAwIFoDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUH
+AwIwKwYDVR0RBCQwIoIQKi5zZWNvbmRsaWZlLmNvbYIOc2Vjb25kbGlmZS5jb20w
+PQYDVR0fBDYwNDAyoDCgLoYsaHR0cDovL2d0c3NsLWNybC5nZW90cnVzdC5jb20v
+Y3Jscy9ndHNzbC5jcmwwHQYDVR0OBBYEFK9UTMkc4Fh/Ug4fVs6UVhxP6my0MAwG
+A1UdEwEB/wQCMAAwQwYIKwYBBQUHAQEENzA1MDMGCCsGAQUFBzAChidodHRwOi8v
+Z3Rzc2wtYWlhLmdlb3RydXN0LmNvbS9ndHNzbC5jcnQwDQYJKoZIhvcNAQEFBQAD
+ggEBACIR9yggGHDcZ60AMNdFmZ8XJeahTuv6q2X/It2JxqSQp5BVQUei0NGIYYOt
+yg0JFBZn5KqXiQ5Zz84K4hdvh/6grCEAn4v37sozSbkeZ92Lec8NOZR42HfYIOCo
+Hx9q7CNRxdhv6ehV4LekaRBxrtp5etVsIDaWvRZEswCWl46VuLrfjcpauj6DAdOQ
+FfPVAW+4nPgLr8KapZMnXYnabIwrj9DQLQ88w/D7durenu/SYJEahWW9mb++n9is
+eMjyuyzYW0PTUBTaDsj+2ZmHJtoR1tBiLqh0Q62UQnmDgsf5SK5PTb8jnta/1SvN
+3pirsuvjMPV19zuH6b9NpJfXfd0=
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIDfTCCAuagAwIBAgIDErvmMA0GCSqGSIb3DQEBBQUAME4xCzAJBgNVBAYTAlVT
+MRAwDgYDVQQKEwdFcXVpZmF4MS0wKwYDVQQLEyRFcXVpZmF4IFNlY3VyZSBDZXJ0
+aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDIwNTIxMDQwMDAwWhcNMTgwODIxMDQwMDAw
+WjBCMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UE
+AxMSR2VvVHJ1c3QgR2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
+CgKCAQEA2swYYzD99BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9m
+OSm9BXiLnTjoBbdqfnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIu
+T8rxh0PBFpVXLVDviS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6c
+JmTM386DGXHKTubU1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmR
+Cw7+OC7RHQWa9k0+bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5asz
+PeE4uwc2hGKceeoWMPRfwCvocWvk+QIDAQABo4HwMIHtMB8GA1UdIwQYMBaAFEjm
+aPkr0rKV10fYIyAQTzOYkJ/UMB0GA1UdDgQWBBTAephojYn7qwVkDBF9qn1luMrM
+TjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjA6BgNVHR8EMzAxMC+g
+LaArhilodHRwOi8vY3JsLmdlb3RydXN0LmNvbS9jcmxzL3NlY3VyZWNhLmNybDBO
+BgNVHSAERzBFMEMGBFUdIAAwOzA5BggrBgEFBQcCARYtaHR0cHM6Ly93d3cuZ2Vv
+dHJ1c3QuY29tL3Jlc291cmNlcy9yZXBvc2l0b3J5MA0GCSqGSIb3DQEBBQUAA4GB
+AHbhEm5OSxYShjAGsoEIz/AIx8dxfmbuwu3UOx//8PDITtZDOLC5MH0Y0FWDomrL
+NhGc6Ehmo21/uBPUR/6LWlxz/K7ZGzIZOKuXNBSqltLroxwUCEm2u+WR74M26x1W
+b8ravHNjkOR/ez4iyz0H7V84dJzjA1BOoa+Y7mHyhD8S
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIID2TCCAsGgAwIBAgIDAjbQMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT
+MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i
+YWwgQ0EwHhcNMTAwMjE5MjIzOTI2WhcNMjAwMjE4MjIzOTI2WjBAMQswCQYDVQQG
+EwJVUzEXMBUGA1UEChMOR2VvVHJ1c3QsIEluYy4xGDAWBgNVBAMTD0dlb1RydXN0
+IFNTTCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJCzgMHk5Uat
+cGA9uuUU3Z6KXot1WubKbUGlI+g5hSZ6p1V3mkihkn46HhrxJ6ujTDnMyz1Hr4Gu
+FmpcN+9FQf37mpc8oEOdxt8XIdGKolbCA0mEEoE+yQpUYGa5jFTk+eb5lPHgX3UR
+8im55IaisYmtph6DKWOy8FQchQt65+EuDa+kvc3nsVrXjAVaDktzKIt1XTTYdwvh
+dGLicTBi2LyKBeUxY0pUiWozeKdOVSQdl+8a5BLGDzAYtDRN4dgjOyFbLTAZJQ50
+96QhS6CkIMlszZhWwPKoXz4mdaAN+DaIiixafWcwqQ/RmXAueOFRJq9VeiS+jDkN
+d53eAsMMvR8CAwEAAaOB2TCB1jAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFEJ5
+VBthzVUrPmPVPEhX9Z/7Rc5KMB8GA1UdIwQYMBaAFMB6mGiNifurBWQMEX2qfWW4
+ysxOMBIGA1UdEwEB/wQIMAYBAf8CAQAwOgYDVR0fBDMwMTAvoC2gK4YpaHR0cDov
+L2NybC5nZW90cnVzdC5jb20vY3Jscy9ndGdsb2JhbC5jcmwwNAYIKwYBBQUHAQEE
+KDAmMCQGCCsGAQUFBzABhhhodHRwOi8vb2NzcC5nZW90cnVzdC5jb20wDQYJKoZI
+hvcNAQEFBQADggEBANTvU4ToGr2hiwTAqfVfoRB4RV2yV2pOJMtlTjGXkZrUJPji
+J2ZwMZzBYlQG55cdOprApClICq8kx6jEmlTBfEx4TCtoLF0XplR4TEbigMMfOHES
+0tdT41SFULgCy+5jOvhWiU1Vuy7AyBh3hjELC3DwfjWDpCoTZFZnNF0WX3OsewYk
+2k9QbSqr0E1TQcKOu3EDSSmGGM8hQkx0YlEVxW+o78Qn5Rsz3VqI138S0adhJR/V
+4NwdzxoQ2KDLX4z6DOW/cf/lXUQdpj6HR/oaToODEj+IZpWYeZqF6wJHzSXj8gYE
+TpnKXKBuervdo5AaRTPvvz7SBMS24CqFZUE+ENQ=
+-----END CERTIFICATE-----
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index ef6f8fd3eee14dea0001feeae55a175a1cce4a35..ced46c72949ce04ab40d9d66f62b08af05091d4e 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -950,39 +950,6 @@
       <key>Value</key>
       <integer>1</integer>
     </map>
-    <key>BulkChangeIncludeAnimations</key>
-    <map>
-      <key>Comment</key>
-      <string>Bulk permission changes affect animations</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>Boolean</string>
-      <key>Value</key>
-      <integer>1</integer>
-    </map>
-    <key>BulkChangeIncludeAnimations</key>
-    <map>
-      <key>Comment</key>
-      <string>Bulk permission changes affect animations</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>Boolean</string>
-      <key>Value</key>
-      <integer>1</integer>
-    </map>
-    <key>BulkChangeIncludeAnimations</key>
-    <map>
-      <key>Comment</key>
-      <string>Bulk permission changes affect animations</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>Boolean</string>
-      <key>Value</key>
-      <integer>1</integer>
-    </map>
     <key>BulkChangeIncludeBodyParts</key>
     <map>
       <key>Comment</key>
@@ -1195,18 +1162,7 @@
     <key>CacheLocationTopFolder</key>
     <map>
       <key>Comment</key>
-      <string>Controls the top folder location of the local disk cache</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>String</string>
-      <key>Value</key>
-      <string />
-    </map>	
-    <key>CacheLocationTopFolder</key>
-    <map>
-      <key>Comment</key>
-      <string>Controls the location of the local disk cache</string>
+      <string>Controls the top folder location of the the local disk cache</string>
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
@@ -1223,7 +1179,7 @@
       <key>Type</key>
       <string>U32</string>
       <key>Value</key>
-      <integer>20000</integer>
+      <integer>128</integer>
     </map>
     <key>CacheSize</key>
     <map>
@@ -1918,10 +1874,21 @@
     <key>Value</key>
     <integer>0</integer>
   </map>
+  <key>DebugShowTextureInfo</key>
+    <map>
+      <key>Comment</key>
+      <string>Show inertested texture info</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Boolean</string>
+      <key>Value</key>
+      <integer>0</integer>
+    </map>
   <key>DebugShowTime</key>
     <map>
       <key>Comment</key>
-      <string>Show depth buffer contents</string>
+      <string>Show time info</string>
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
@@ -3118,17 +3085,6 @@
         <key>Value</key>
         <string>http://viewer-settings.secondlife.com</string>
     </map>
-    <key>FPSLogFrequency</key>
-    <map>
-      <key>Comment</key>
-      <string>Seconds between display of FPS in log (0 for never)</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>F32</string>
-      <key>Value</key>
-      <real>60.0</real>
-    </map>
     <key>FPSLogFrequency</key>
         <map>
         <key>Comment</key>
@@ -6082,17 +6038,6 @@
       <integer>0</integer>
     </map>
     <key>OutBandwidth</key>
-    <map>
-      <key>Comment</key>
-      <string>Expand render stats display</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>Boolean</string>
-      <key>Value</key>
-      <integer>1</integer>
-    </map>
-    <key>OutBandwidth</key>
     <map>
       <key>Comment</key>
       <string>Outgoing bandwidth throttle (bps)</string>
@@ -11452,8 +11397,6 @@
       <key>Type</key>
       <string>LLSD</string>
       <key>Value</key>
-      <map>
-      </map>
     </map>
     <key>VFSOldSize</key>
     <map>
@@ -11609,17 +11552,6 @@
       <key>Value</key>
       <string></string>
     </map>
-    <key>VivoxDebugSIPURIHostName</key>
-    <map>
-      <key>Comment</key>
-      <string>Hostname portion of vivox SIP URIs (empty string for the default).</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>String</string>
-      <key>Value</key>
-      <string></string>
-    </map>
     <key>VivoxDebugVoiceAccountServerURI</key>
     <map>
       <key>Comment</key>
@@ -12445,16 +12377,5 @@
       <key>Value</key>
       <string>name</string>
     </map>
-    <key>ReleaseNotesURL</key>
-    <map>
-      <key>Comment</key>
-      <string>Release notes URL template</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>String</string>
-      <key>Value</key>
-      <string>http://secondlife.com/app/releasenotes/?channel=[CHANNEL]&amp;version=[VERSION]</string>
-    </map>
 </map>
 </llsd>
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 80c752da9ac7a0853597216de6aceffb76d70459..6a9dfaf21b6cbe21e3ade86ecc8983f129a04e04 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -473,8 +473,6 @@ static void settings_to_globals()
 	gDebugWindowProc = gSavedSettings.getBOOL("DebugWindowProc");
 	gShowObjectUpdates = gSavedSettings.getBOOL("ShowObjectUpdates");
 	LLWorldMapView::sMapScale = gSavedSettings.getF32("MapScale");
-
-	LLCubeMap::sUseCubeMaps = LLFeatureManager::getInstance()->isFeatureAvailable("RenderCubeMap");
 }
 
 static void settings_modify()
@@ -854,6 +852,9 @@ bool LLAppViewer::init()
 	gGLActive = TRUE;
 	initWindow();
 
+	// initWindow also initializes the Feature List, so now we can initialize this global.
+	LLCubeMap::sUseCubeMaps = LLFeatureManager::getInstance()->isFeatureAvailable("RenderCubeMap");
+
 	// call all self-registered classes
 	LLInitClassList::instance().fireCallbacks();
 
@@ -1397,16 +1398,6 @@ bool LLAppViewer::cleanup()
 	}
 	mPlugins.clear();
 
-	//----------------------------------------------
-	//this test code will be removed after the test
-	//test manual call stack tracer
-	if(gSavedSettings.getBOOL("QAMode"))
-	{
-		LLError::LLCallStacks::print() ;
-	}
-	//end of the test code
-	//----------------------------------------------
-
 	//flag all elements as needing to be destroyed immediately
 	// to ensure shutdown order
 	LLMortician::setZealous(TRUE);
@@ -3076,35 +3067,32 @@ void LLAppViewer::initMarkerFile()
 	std::string llerror_marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, LLERROR_MARKER_FILE_NAME);
 	std::string error_marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, ERROR_MARKER_FILE_NAME);
 
-	
 	if (LLAPRFile::isExist(mMarkerFileName, NULL, LL_APR_RB) && !anotherInstanceRunning())
 	{
 		gLastExecEvent = LAST_EXEC_FROZE;
 		LL_INFOS("MarkerFile") << "Exec marker found: program froze on previous execution" << LL_ENDL;
 	}    
-    
 	if(LLAPRFile::isExist(logout_marker_file, NULL, LL_APR_RB))
 	{
-		LL_INFOS("MarkerFile") << "Last exec LLError crashed, setting LastExecEvent to " << LAST_EXEC_LLERROR_CRASH << LL_ENDL;
 		gLastExecEvent = LAST_EXEC_LOGOUT_FROZE;
+		LL_INFOS("MarkerFile") << "Last exec LLError crashed, setting LastExecEvent to " << gLastExecEvent << LL_ENDL;
+		LLAPRFile::remove(logout_marker_file);
 	}
 	if(LLAPRFile::isExist(llerror_marker_file, NULL, LL_APR_RB))
 	{
-		llinfos << "Last exec LLError crashed, setting LastExecEvent to " << LAST_EXEC_LLERROR_CRASH << llendl;
 		if(gLastExecEvent == LAST_EXEC_LOGOUT_FROZE) gLastExecEvent = LAST_EXEC_LOGOUT_CRASH;
 		else gLastExecEvent = LAST_EXEC_LLERROR_CRASH;
+		LL_INFOS("MarkerFile") << "Last exec LLError crashed, setting LastExecEvent to " << gLastExecEvent << LL_ENDL;
+		LLAPRFile::remove(llerror_marker_file);
 	}
 	if(LLAPRFile::isExist(error_marker_file, NULL, LL_APR_RB))
 	{
-		LL_INFOS("MarkerFile") << "Last exec crashed, setting LastExecEvent to " << LAST_EXEC_OTHER_CRASH << LL_ENDL;
 		if(gLastExecEvent == LAST_EXEC_LOGOUT_FROZE) gLastExecEvent = LAST_EXEC_LOGOUT_CRASH;
 		else gLastExecEvent = LAST_EXEC_OTHER_CRASH;
+		LL_INFOS("MarkerFile") << "Last exec crashed, setting LastExecEvent to " << gLastExecEvent << LL_ENDL;
+		LLAPRFile::remove(error_marker_file);
 	}
-	
-	LLAPRFile::remove(logout_marker_file);
-	LLAPRFile::remove(llerror_marker_file);
-	LLAPRFile::remove(error_marker_file);
-	
+
 	// No new markers if another instance is running.
 	if(anotherInstanceRunning()) 
 	{
@@ -3746,6 +3734,7 @@ void LLAppViewer::loadNameCache()
 	// display names cache
 	std::string filename =
 		gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "avatar_name_cache.xml");
+	LL_INFOS("AvNameCache") << filename << LL_ENDL;
 	llifstream name_cache_stream(filename);
 	if(name_cache_stream.is_open())
 	{
diff --git a/indra/newview/llcapabilityprovider.h b/indra/newview/llcapabilityprovider.h
index a6e743f625db2ca3e58b66c006247eb41deacfd0..9d912455977289d779a4a2ba27cbe26a478a2e02 100644
--- a/indra/newview/llcapabilityprovider.h
+++ b/indra/newview/llcapabilityprovider.h
@@ -46,7 +46,7 @@ class LLCapabilityProvider
     /**
      * Get host to which to send that capability request.
      */
-    virtual LLHost getHost() const = 0;
+    virtual const LLHost& getHost() const = 0;
     /**
      * Describe this LLCapabilityProvider for logging etc.
      */
diff --git a/indra/newview/llcolorswatch.cpp b/indra/newview/llcolorswatch.cpp
index 4a1ba6f1b5fe91903323ccb8f5ad23b280eb7305..6f02192d0aeacd99ef5fce0215591d876dd78bfa 100644
--- a/indra/newview/llcolorswatch.cpp
+++ b/indra/newview/llcolorswatch.cpp
@@ -319,7 +319,7 @@ void LLColorSwatchCtrl::onColorChanged ( void* data, EColorPickOp pick_op )
 // This is called when the main floatercustomize panel is closed.
 // Since this class has pointers up to its parents, we need to cleanup
 // this class first in order to avoid a crash.
-void LLColorSwatchCtrl::onParentFloaterClosed()
+void LLColorSwatchCtrl::closeFloaterColorPicker()
 {
 	LLFloaterColorPicker* pickerp = (LLFloaterColorPicker*)mPickerHandle.get();
 	if (pickerp)
diff --git a/indra/newview/llcolorswatch.h b/indra/newview/llcolorswatch.h
index cd859ea1286c052a51d4247c627907f9f562d4d1..5bdd1712d2002cc84166b2643fb5fd9b7057085e 100644
--- a/indra/newview/llcolorswatch.h
+++ b/indra/newview/llcolorswatch.h
@@ -100,7 +100,7 @@ class LLColorSwatchCtrl
 	/*virtual*/ void	setEnabled( BOOL enabled );
 
 	static void		onColorChanged ( void* data, EColorPickOp pick_op = COLOR_CHANGE );
-	void			onParentFloaterClosed();
+	void			closeFloaterColorPicker();
 
 protected:
 	BOOL			mValid;
diff --git a/indra/newview/lldynamictexture.cpp b/indra/newview/lldynamictexture.cpp
index a3d2941114f39d4124e0cc9b550202676debb977..f781d5f3ff96274388f40bc2a12bfcebc53ba944 100644
--- a/indra/newview/lldynamictexture.cpp
+++ b/indra/newview/lldynamictexture.cpp
@@ -177,10 +177,6 @@ void LLViewerDynamicTexture::postRender(BOOL success)
 				generateGLTexture() ;
 			}
 
-			if(gGLManager.mDebugGPU)
-			{
-				LLGLState::dumpStates() ;
-			}
 			success = mGLTexturep->setSubImageFromFrameBuffer(0, 0, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight);
 		}
 	}
@@ -220,12 +216,6 @@ BOOL LLViewerDynamicTexture::updateAllInstances()
 			LLViewerDynamicTexture *dynamicTexture = *iter;
 			if (dynamicTexture->needsRender())
 			{				
-				if(gGLManager.mDebugGPU)
-				{				
-					llinfos << "class type: " << (S32)dynamicTexture->getType() << llendl;
-					LLGLState::dumpStates() ;
-				}
-
 				glClear(GL_DEPTH_BUFFER_BIT);
 				gDepthDirty = TRUE;
 								
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 2471da9da57e83230abce89622d4a481b544a096..fe201a6773f754bdebe2af2469fe0a397fd47423 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1155,7 +1155,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		if (rebuild_tcoord)
 		{
 			LLVector2 tc = vf.mVertices[i].mTexCoord;
-		
+		   
 			if (texgen != LLTextureEntry::TEX_GEN_DEFAULT)
 			{
 				LLVector3 vec = vf.mVertices[i].mPosition; 
@@ -1331,7 +1331,14 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		mTexExtents[0].setVec(0,0);
 		mTexExtents[1].setVec(1,1);
 		xform(mTexExtents[0], cos_ang, sin_ang, os, ot, ms, mt);
-		xform(mTexExtents[1], cos_ang, sin_ang, os, ot, ms, mt);		
+		xform(mTexExtents[1], cos_ang, sin_ang, os, ot, ms, mt);
+		
+		F32 es = vf.mTexCoordExtents[1].mV[0] - vf.mTexCoordExtents[0].mV[0] ;
+		F32 et = vf.mTexCoordExtents[1].mV[1] - vf.mTexCoordExtents[0].mV[1] ;
+		mTexExtents[0][0] *= es ;
+		mTexExtents[1][0] *= es ;
+		mTexExtents[0][1] *= et ;
+		mTexExtents[1][1] *= et ;
 	}
 
 	mLastVertexBuffer = mVertexBuffer;
diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp
index ca2ef5f5b8e1bdafcf462cccf502359253947c76..4e16cc4217dcb1c1c67f7fa944c929b2f8a822e2 100644
--- a/indra/newview/llfeaturemanager.cpp
+++ b/indra/newview/llfeaturemanager.cpp
@@ -290,11 +290,9 @@ BOOL LLFeatureManager::parseFeatureTable(std::string filename)
 	mTableVersion = version;
 
 	LLFeatureList *flp = NULL;
-	while (!file.eof() && file.good())
+	while (file >> name)
 	{
 		char buffer[MAX_STRING];		 /*Flawfinder: ignore*/
-
-		file >> name;
 		
 		if (name.substr(0,2) == "//")
 		{
@@ -303,13 +301,6 @@ BOOL LLFeatureManager::parseFeatureTable(std::string filename)
 			continue;
 		}
 
-		if (name.empty())
-		{
-			// This is a blank line
-			file.getline(buffer, MAX_STRING);
-			continue;
-		}
-
 		if (name == "list")
 		{
 			if (flp)
diff --git a/indra/newview/llfloatersettingsdebug.cpp b/indra/newview/llfloatersettingsdebug.cpp
index 71882fbb839b91e2f250b4af29d29d19835e6a4d..07f5220ab7f8419cc50d5b0723c1d7f7e63a97dc 100644
--- a/indra/newview/llfloatersettingsdebug.cpp
+++ b/indra/newview/llfloatersettingsdebug.cpp
@@ -178,7 +178,7 @@ void LLFloaterSettingsDebug::onClickDefault()
 
 	if (controlp)
 	{
-		controlp->resetToDefault();
+		controlp->resetToDefault(true);
 		updateControl(controlp);
 	}
 }
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index afd565bb26424a7882edbb444ece40a2bb2b6afe..9623554200f4675e0e23997595f2c53c0d360169 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -279,7 +279,7 @@ LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string&
 
 void LLIMModel::LLIMSession::onAdHocNameCache(const LLAvatarName& av_name)
 {
-	if (av_name.mIsDummy)
+	if (av_name.mIsTemporaryName)
 	{
 		S32 separator_index = mName.rfind(" ");
 		std::string name = mName.substr(0, separator_index);
diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp
index f93bfb61d3cc4f40f49529484a84bd59e65a8d45..33e051bfab8e6286f73c64862a8fe6ee05019c54 100644
--- a/indra/newview/lllogininstance.cpp
+++ b/indra/newview/lllogininstance.cpp
@@ -214,6 +214,9 @@ void MandatoryUpdateMachine::start(void)
 			case LLUpdaterService::CHECKING_FOR_UPDATE:
 				setCurrentState(new CheckingForUpdate(*this));
 				break;
+			case LLUpdaterService::TEMPORARY_ERROR:
+				setCurrentState(new Error(*this));
+				break;
 			case LLUpdaterService::DOWNLOADING:
 				setCurrentState(new WaitingForDownload(*this));
 				break;
@@ -289,6 +292,7 @@ bool MandatoryUpdateMachine::CheckingForUpdate::onEvent(LLSD const & event)
 			case LLUpdaterService::DOWNLOADING:
 				mMachine.setCurrentState(new WaitingForDownload(mMachine));
 				break;
+			case LLUpdaterService::TEMPORARY_ERROR:
 			case LLUpdaterService::UP_TO_DATE:
 			case LLUpdaterService::TERMINAL:
 			case LLUpdaterService::FAILURE:
@@ -324,7 +328,7 @@ MandatoryUpdateMachine::Error::Error(MandatoryUpdateMachine & machine):
 void MandatoryUpdateMachine::Error::enter(void)
 {
 	llinfos << "entering error" << llendl;
-	LLNotificationsUtil::add("FailedUpdateInstall", LLSD(), LLSD(), boost::bind(&MandatoryUpdateMachine::Error::onButtonClicked, this, _1, _2));
+	LLNotificationsUtil::add("FailedRequiredUpdateInstall", LLSD(), LLSD(), boost::bind(&MandatoryUpdateMachine::Error::onButtonClicked, this, _1, _2));
 }
 
 
diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp
index 90ed8b9e587a106dca3b0330913081c165d139bf..4a74b7925c1965afd7313369e74301d356d52df3 100644
--- a/indra/newview/llpaneleditwearable.cpp
+++ b/indra/newview/llpaneleditwearable.cpp
@@ -569,6 +569,7 @@ static void update_color_swatch_ctrl(LLPanelEditWearable* self, LLPanel* panel,
 	if (color_swatch_ctrl)
 	{
 		color_swatch_ctrl->set(self->getWearable()->getClothesColor(entry->mTextureIndex));
+		color_swatch_ctrl->closeFloaterColorPicker();
 	}
 }
 
diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp
index d1362d79227f5826091a3eefeb027dd461465a8e..3dbc637318a7eab48a77cc668a45ee554eaa7d88 100644
--- a/indra/newview/llpanelgrouproles.cpp
+++ b/indra/newview/llpanelgrouproles.cpp
@@ -1843,7 +1843,8 @@ bool LLPanelGroupRolesSubTab::apply(std::string& mesg)
 {
 	lldebugs << "LLPanelGroupRolesSubTab::apply()" << llendl;
 
-	saveRoleChanges();
+	saveRoleChanges(true);
+
 	LLGroupMgr::getInstance()->sendGroupRoleChanges(mGroupID);
 
 	notifyObservers();
@@ -2022,7 +2023,7 @@ void LLPanelGroupRolesSubTab::handleRoleSelect()
 		return;
 	}
 
-	saveRoleChanges();
+	saveRoleChanges(false);
 
 	// Check if there is anything selected.
 	LLScrollListItem* item = mRolesList->getFirstSelected();
@@ -2385,7 +2386,7 @@ void LLPanelGroupRolesSubTab::handleDeleteRole()
 	notifyObservers();
 }
 
-void LLPanelGroupRolesSubTab::saveRoleChanges()
+void LLPanelGroupRolesSubTab::saveRoleChanges(bool select_saved_role)
 {
 	LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID);
 
@@ -2400,13 +2401,23 @@ void LLPanelGroupRolesSubTab::saveRoleChanges()
 		rd.mRoleDescription = mRoleDescription->getText();
 		rd.mRoleTitle = mRoleTitle->getText();
 
+		S32 role_members_count = 0;
+		if (mSelectedRole.isNull())
+		{
+			role_members_count = gdatap->mMemberCount;
+		}
+		else if(LLGroupRoleData* grd = get_ptr_in_map(gdatap->mRoles, mSelectedRole))
+		{
+			role_members_count = grd->getTotalMembersInRole();
+		}
+
 		gdatap->setRoleData(mSelectedRole,rd);
 
 		mRolesList->deleteSingleItem(mRolesList->getItemIndex(mSelectedRole));
 		
-		LLSD row = createRoleItem(mSelectedRole,rd.mRoleName,rd.mRoleTitle,0);
+		LLSD row = createRoleItem(mSelectedRole,rd.mRoleName,rd.mRoleTitle,role_members_count);
 		LLScrollListItem* item = mRolesList->addElement(row, ADD_BOTTOM, this);
-		item->setSelected(TRUE);
+		item->setSelected(select_saved_role);
 
 		mHasRoleChange = FALSE;
 	}
diff --git a/indra/newview/llpanelgrouproles.h b/indra/newview/llpanelgrouproles.h
index 270259c16f90824a5f9a34f5f41f40413dc83820..a55e26415077d169adc18333384aeee57b546403 100644
--- a/indra/newview/llpanelgrouproles.h
+++ b/indra/newview/llpanelgrouproles.h
@@ -257,7 +257,7 @@ class LLPanelGroupRolesSubTab : public LLPanelGroupSubTab
 	static void onDeleteRole(void*);
 	void handleDeleteRole();
 
-	void saveRoleChanges();
+	void saveRoleChanges(bool select_saved_role);
 
 	virtual void setGroupID(const LLUUID& id);
 protected:
diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp
index e8c8273a9d038e0f64f143183bf9eda2a1eb4f27..80f68621697fe9487b0529ed1cf5e53b815b795d 100644
--- a/indra/newview/llpanellandmarks.cpp
+++ b/indra/newview/llpanellandmarks.cpp
@@ -71,6 +71,7 @@ static void collapse_all_folders(LLFolderView* root_folder);
 static void expand_all_folders(LLFolderView* root_folder);
 static bool has_expanded_folders(LLFolderView* root_folder);
 static bool has_collapsed_folders(LLFolderView* root_folder);
+static void toggle_restore_menu(LLMenuGL* menu, BOOL visible, BOOL enabled);
 
 /**
  * Functor counting expanded and collapsed folders in folder view tree to know
@@ -708,6 +709,9 @@ void LLLandmarksPanel::initListCommandsHandlers()
 	mGearFolderMenu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_places_gear_folder.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
 	mMenuAdd = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_place_add_button.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
 
+	mGearLandmarkMenu->setVisibilityChangeCallback(boost::bind(&LLLandmarksPanel::onMenuVisibilityChange, this, _1, _2));
+	mGearFolderMenu->setVisibilityChangeCallback(boost::bind(&LLLandmarksPanel::onMenuVisibilityChange, this, _1, _2));
+
 	mListCommands->childSetAction(ADD_BUTTON_NAME, boost::bind(&LLLandmarksPanel::showActionMenu, this, mMenuAdd, ADD_BUTTON_NAME));
 }
 
@@ -1079,6 +1083,60 @@ void LLLandmarksPanel::onCustomAction(const LLSD& userdata)
 	{
 		doActionOnCurSelectedLandmark(boost::bind(&LLLandmarksPanel::doCreatePick, this, _1));
 	}
+	else if ("restore" == command_name && mCurrentSelectedList)
+	{
+		mCurrentSelectedList->doToSelected(userdata);
+	}
+}
+
+void LLLandmarksPanel::onMenuVisibilityChange(LLUICtrl* ctrl, const LLSD& param)
+{
+	bool new_visibility = param["visibility"].asBoolean();
+
+	// We don't have to update items visibility if the menu is hiding.
+	if (!new_visibility) return;
+
+	BOOL are_any_items_in_trash = FALSE;
+	BOOL are_all_items_in_trash = TRUE;
+
+	LLFolderView* root_folder_view = mCurrentSelectedList ? mCurrentSelectedList->getRootFolder() : NULL;
+	if(root_folder_view)
+	{
+		const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
+
+		std::set<LLUUID> selected_uuids = root_folder_view->getSelectionList();
+
+		// Iterate through selected items to find out if any of these items are in Trash
+		// or all the items are in Trash category.
+		for (std::set<LLUUID>::const_iterator iter = selected_uuids.begin(); iter != selected_uuids.end(); ++iter)
+		{
+			LLFolderViewItem* item = root_folder_view->getItemByID(*iter);
+
+			// If no item is found it might be a folder id.
+			if (!item)
+			{
+				item = root_folder_view->getFolderByID(*iter);
+			}
+			if (!item) continue;
+
+			LLFolderViewEventListener* listenerp = item->getListener();
+			if(!listenerp) continue;
+
+			// Trash category itself should not be included because it can't be
+			// actually restored from trash.
+			are_all_items_in_trash &= listenerp->isItemInTrash() && *iter != trash_id;
+
+			// If there are any selected items in Trash including the Trash category itself
+			// we show "Restore Item" in context menu and hide other irrelevant items.
+			are_any_items_in_trash |= listenerp->isItemInTrash();
+		}
+	}
+
+	// Display "Restore Item" menu entry if at least one of the selected items
+	// is in Trash or the Trash category itself is among selected items.
+	// Hide other menu entries in this case.
+	// Enable this menu entry only if all selected items are in the Trash category.
+	toggle_restore_menu((LLMenuGL*)ctrl, are_any_items_in_trash, are_all_items_in_trash);
 }
 
 /*
@@ -1414,4 +1472,31 @@ static bool has_collapsed_folders(LLFolderView* root_folder)
 
 	return true;
 }
+
+// Displays "Restore Item" context menu entry while hiding
+// all other entries or vice versa.
+// Sets "Restore Item" enabled state.
+void toggle_restore_menu(LLMenuGL *menu, BOOL visible, BOOL enabled)
+{
+	if (!menu) return;
+
+	const LLView::child_list_t *list = menu->getChildList();
+	for (LLView::child_list_t::const_iterator itor = list->begin();
+		 itor != list->end();
+		 ++itor)
+	{
+		LLView *menu_item = (*itor);
+		std::string name = menu_item->getName();
+
+		if ("restore_item" == name)
+		{
+			menu_item->setVisible(visible);
+			menu_item->setEnabled(enabled);
+		}
+		else
+		{
+			menu_item->setVisible(!visible);
+		}
+	}
+}
 // EOF
diff --git a/indra/newview/llpanellandmarks.h b/indra/newview/llpanellandmarks.h
index 8dcbca04406542ff0fc9b96bb416a8641b1b9454..b2f4e92473f587a0bce100d3e0d4da6f051e1bce 100644
--- a/indra/newview/llpanellandmarks.h
+++ b/indra/newview/llpanellandmarks.h
@@ -128,6 +128,14 @@ class LLLandmarksPanel : public LLPanelPlacesTab, LLRemoteParcelInfoObserver
 	bool isActionEnabled(const LLSD& command_name) const;
 	void onCustomAction(const LLSD& command_name);
 
+	/**
+	 * Updates context menu depending on the selected items location.
+	 *
+	 * For items in Trash category the menu includes the "Restore Item"
+	 * context menu entry.
+	 */
+	void onMenuVisibilityChange(LLUICtrl* ctrl, const LLSD& param);
+
 	/**
 	 * Determines if an item can be modified via context/gear menu.
 	 *
diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp
index c143aff2d413fdbc42436ada6ef6735cf6bea88a..8d3b1fd7a0dbe0f9ee77c81eaae98ac7ba061db5 100644
--- a/indra/newview/llpanellogin.cpp
+++ b/indra/newview/llpanellogin.cpp
@@ -35,6 +35,7 @@
 #include "llsecondlifeurls.h"
 #include "v4color.h"
 
+#include "llappviewer.h"
 #include "llbutton.h"
 #include "llcheckboxctrl.h"
 #include "llcommandhandler.h"		// for secondlife:///app/login/
@@ -859,6 +860,13 @@ void LLPanelLogin::loadLoginPage()
 	char* curl_grid = curl_escape(LLGridManager::getInstance()->getGridLabel().c_str(), 0);
 	oStr << "&grid=" << curl_grid;
 	curl_free(curl_grid);
+	
+	// add OS info
+	char * os_info = curl_escape(LLAppViewer::instance()->getOSInfo().getOSStringSimple().c_str(), 0);
+	oStr << "&os=" << os_info;
+	curl_free(os_info);
+	
+	
 	gViewerWindow->setMenuBackgroundColor(false, !LLGridManager::getInstance()->isInProductionGrid());
 	gLoginMenuBarView->setBackgroundColor(gMenuBarView->getBackgroundColor());
 	
diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp
index fcc67d68407a1bc157407437515188b15635fd7e..14e39f2c48714eea00e81aa9c8a7a982ec0b5e26 100644
--- a/indra/newview/llpanelnearbymedia.cpp
+++ b/indra/newview/llpanelnearbymedia.cpp
@@ -958,7 +958,7 @@ void LLPanelNearByMedia::onAdvancedButtonClick()
 
 void LLPanelNearByMedia::onMoreLess()
 {
-	bool is_more = getChild<LLUICtrl>("more_btn")->getVisible();
+	bool is_more = getChild<LLButton>("more_btn")->getToggleState();
 	mNearbyMediaPanel->setVisible(is_more);
 
 	// enable resizing when expanded
@@ -969,8 +969,7 @@ void LLPanelNearByMedia::onMoreLess()
 
 	setShape(new_rect);
 
-	getChild<LLUICtrl>("more_btn")->setVisible(!is_more);
-	getChild<LLUICtrl>("less_btn")->setVisible(is_more);
+	getChild<LLUICtrl>("more_btn")->setVisible(true);
 }
 
 void LLPanelNearByMedia::updateControls()
diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp
index 7657cccd4ea3b5f6602d15d6e98f6fd9e8d28ed3..6cfb708112ab10ab270e7eaa90ac6672e8af4427 100644
--- a/indra/newview/llpreviewtexture.cpp
+++ b/indra/newview/llpreviewtexture.cpp
@@ -273,6 +273,8 @@ void LLPreviewTexture::saveAs()
 	mSaveFileName = file_picker.getFirstFile();
 	mLoadingFullImage = TRUE;
 	getWindow()->incBusyCount();
+
+	mImage->forceToSaveRawImage(0) ;//re-fetch the raw image if the old one is removed.
 	mImage->setLoadedCallback( LLPreviewTexture::onFileLoadedForSave, 
 								0, TRUE, FALSE, new LLUUID( mItemUUID ), &mCallbackTextureList );
 }
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index 7478ed5f9a3db2d1ff850a048c2f7c632e9d8d17..65a9a493f606f5bd69e39c1c0247c6e9ee95afb7 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -235,7 +235,7 @@ class LLObjectSelection : public LLRefCount
 	{
 		bool operator()(LLSelectNode* node);
 	};
-	typedef boost::filter_iterator<is_root, list_t::iterator > valid_root_iterator;
+	typedef boost::filter_iterator<is_valid_root, list_t::iterator > valid_root_iterator;
 	valid_root_iterator valid_root_begin() { return valid_root_iterator(mList.begin(), mList.end()); }
 	valid_root_iterator valid_root_end() { return valid_root_iterator(mList.end(), mList.end()); }
 	
diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp
index b316171604a52ca57471c8d6e464b314952cef48..363fe5f12b80f6a6b1453130458c183ae588ce7b 100644
--- a/indra/newview/llsidepanelappearance.cpp
+++ b/indra/newview/llsidepanelappearance.cpp
@@ -185,7 +185,7 @@ void LLSidepanelAppearance::onVisibilityChange(const LLSD &new_visibility)
 {
 	LLSD visibility;
 	visibility["visible"] = new_visibility.asBoolean();
-	visibility["reset_accordion"] = true;
+	visibility["reset_accordion"] = false;
 	updateToVisibility(visibility);
 }
 
diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp
index 6a213309a0bff583ceb3b205df5fd4189ee01b40..f54214b95cbc6e173270fe7d39cc544299171c9e 100644
--- a/indra/newview/lltexturecache.cpp
+++ b/indra/newview/lltexturecache.cpp
@@ -326,6 +326,7 @@ bool LLTextureCacheRemoteWorker::doRead()
 	// First state / stage : find out if the file is local
 	if (mState == INIT)
 	{
+#if 0
 		std::string filename = mCache->getLocalFileName(mID);	
 		// Is it a JPEG2000 file? 
 		{
@@ -360,6 +361,11 @@ bool LLTextureCacheRemoteWorker::doRead()
 		}
 		// Determine the next stage: if we found a file, then LOCAL else CACHE
 		mState = (local_size > 0 ? LOCAL : CACHE);
+
+		llassert_always(mState == CACHE) ;
+#else
+		mState = CACHE;
+#endif
 	}
 
 	// Second state / stage : if the file is local, load it and leave
@@ -1592,7 +1598,7 @@ void LLTextureCache::purgeTextures(bool validate)
 	if (validate)
 	{
 		validate_idx = gSavedSettings.getU32("CacheValidateCounter");
-		U32 next_idx = (++validate_idx) % 256;
+		U32 next_idx = (validate_idx + 1) % 256;
 		gSavedSettings.setU32("CacheValidateCounter", next_idx);
 		LL_DEBUGS("TextureCache") << "TEXTURE CACHE: Validating: " << validate_idx << LL_ENDL;
 	}
@@ -1858,8 +1864,22 @@ void LLTextureCache::removeCachedTexture(const LLUUID& id)
 //called after mHeaderMutex is locked.
 void LLTextureCache::removeEntry(S32 idx, Entry& entry, std::string& filename)
 {
+ 	bool file_maybe_exists = true;	// Always attempt to remove when idx is invalid.
+
 	if(idx >= 0) //valid entry
 	{
+		if (entry.mBodySize == 0)	// Always attempt to remove when mBodySize > 0.
+		{
+		  if (LLAPRFile::isExist(filename, getLocalAPRFilePool()))		// Sanity check. Shouldn't exist when body size is 0.
+		  {
+			  LL_WARNS("TextureCache") << "Entry has body size of zero but file " << filename << " exists. Deleting this file, too." << LL_ENDL;
+		  }
+		  else
+		  {
+			  file_maybe_exists = false;
+		  }
+		}
+
 		entry.mImageSize = -1;
 		entry.mBodySize = 0;
 		mHeaderIDMap.erase(entry.mID);
@@ -1869,7 +1889,10 @@ void LLTextureCache::removeEntry(S32 idx, Entry& entry, std::string& filename)
 		mFreeList.insert(idx);	
 	}
 
-	LLAPRFile::remove(filename, getLocalAPRFilePool());		
+	if (file_maybe_exists)
+	{
+		LLAPRFile::remove(filename, getLocalAPRFilePool());		
+	}
 }
 
 bool LLTextureCache::removeFromCache(const LLUUID& id)
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 4f63abb152dc59faaca838d5938d28e056034f81..5cdf1706e652cf057214653d1d730a7860c8d8df 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -1,3000 +1,3011 @@
-/** 
- * @file lltexturefetch.cpp
- * @brief Object which fetches textures from the cache and/or network
- *
- * $LicenseInfo:firstyear=2000&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-
-#include <iostream>
-#include <map>
-
-#include "llstl.h"
-
-#include "lltexturefetch.h"
-
-#include "llcurl.h"
-#include "lldir.h"
-#include "llhttpclient.h"
-#include "llhttpstatuscodes.h"
-#include "llimage.h"
-#include "llimagej2c.h"
-#include "llimageworker.h"
-#include "llworkerthread.h"
-#include "message.h"
-
-#include "llagent.h"
-#include "lltexturecache.h"
-#include "llviewercontrol.h"
-#include "llviewertexturelist.h"
-#include "llviewertexture.h"
-#include "llviewerregion.h"
-#include "llviewerstats.h"
-#include "llviewerassetstats.h"
-#include "llworld.h"
-
-//////////////////////////////////////////////////////////////////////////////
-class LLTextureFetchWorker : public LLWorkerClass
-{
-	friend class LLTextureFetch;
-	friend class HTTPGetResponder;
-	
-private:
-	class CacheReadResponder : public LLTextureCache::ReadResponder
-	{
-	public:
-		CacheReadResponder(LLTextureFetch* fetcher, const LLUUID& id, LLImageFormatted* image)
-			: mFetcher(fetcher), mID(id)
-		{
-			setImage(image);
-		}
-		virtual void completed(bool success)
-		{
-			LLTextureFetchWorker* worker = mFetcher->getWorker(mID);
-			if (worker)
-			{
- 				worker->callbackCacheRead(success, mFormattedImage, mImageSize, mImageLocal);
-			}
-		}
-	private:
-		LLTextureFetch* mFetcher;
-		LLUUID mID;
-	};
-
-	class CacheWriteResponder : public LLTextureCache::WriteResponder
-	{
-	public:
-		CacheWriteResponder(LLTextureFetch* fetcher, const LLUUID& id)
-			: mFetcher(fetcher), mID(id)
-		{
-		}
-		virtual void completed(bool success)
-		{
-			LLTextureFetchWorker* worker = mFetcher->getWorker(mID);
-			if (worker)
-			{
-				worker->callbackCacheWrite(success);
-			}
-		}
-	private:
-		LLTextureFetch* mFetcher;
-		LLUUID mID;
-	};
-	
-	class DecodeResponder : public LLImageDecodeThread::Responder
-	{
-	public:
-		DecodeResponder(LLTextureFetch* fetcher, const LLUUID& id, LLTextureFetchWorker* worker)
-			: mFetcher(fetcher), mID(id), mWorker(worker)
-		{
-		}
-		virtual void completed(bool success, LLImageRaw* raw, LLImageRaw* aux)
-		{
-			LLTextureFetchWorker* worker = mFetcher->getWorker(mID);
-			if (worker)
-			{
- 				worker->callbackDecoded(success, raw, aux);
-			}
-		}
-	private:
-		LLTextureFetch* mFetcher;
-		LLUUID mID;
-		LLTextureFetchWorker* mWorker; // debug only (may get deleted from under us, use mFetcher/mID)
-	};
-
-	struct Compare
-	{
-		// lhs < rhs
-		bool operator()(const LLTextureFetchWorker* lhs, const LLTextureFetchWorker* rhs) const
-		{
-			// greater priority is "less"
-			const F32 lpriority = lhs->mImagePriority;
-			const F32 rpriority = rhs->mImagePriority;
-			if (lpriority > rpriority) // higher priority
-				return true;
-			else if (lpriority < rpriority)
-				return false;
-			else
-				return lhs < rhs;
-		}
-	};
-	
-public:
-	/*virtual*/ bool doWork(S32 param); // Called from LLWorkerThread::processRequest()
-	/*virtual*/ void finishWork(S32 param, bool completed); // called from finishRequest() (WORK THREAD)
-	/*virtual*/ bool deleteOK(); // called from update() (WORK THREAD)
-
-	~LLTextureFetchWorker();
-	// void relese() { --mActiveCount; }
-
-	S32 callbackHttpGet(const LLChannelDescriptors& channels,
-						 const LLIOPipe::buffer_ptr_t& buffer,
-						 bool partial, bool success);
-	void callbackCacheRead(bool success, LLImageFormatted* image,
-						   S32 imagesize, BOOL islocal);
-	void callbackCacheWrite(bool success);
-	void callbackDecoded(bool success, LLImageRaw* raw, LLImageRaw* aux);
-	
-	void setGetStatus(U32 status, const std::string& reason)
-	{
-		LLMutexLock lock(&mWorkMutex);
-
-		mGetStatus = status;
-		mGetReason = reason;
-	}
-
-	void setCanUseHTTP(bool can_use_http) { mCanUseHTTP = can_use_http; }
-	bool getCanUseHTTP() const { return mCanUseHTTP; }
-
-	LLTextureFetch & getFetcher() { return *mFetcher; }
-	
-protected:
-	LLTextureFetchWorker(LLTextureFetch* fetcher, const std::string& url, const LLUUID& id, const LLHost& host,
-						 F32 priority, S32 discard, S32 size);
-
-private:
-	/*virtual*/ void startWork(S32 param); // called from addWork() (MAIN THREAD)
-	/*virtual*/ void endWork(S32 param, bool aborted); // called from doWork() (MAIN THREAD)
-
-	void resetFormattedData();
-	
-	void setImagePriority(F32 priority);
-	void setDesiredDiscard(S32 discard, S32 size);
-	bool insertPacket(S32 index, U8* data, S32 size);
-	void clearPackets();
-	void setupPacketData();
-	U32 calcWorkPriority();
-	void removeFromCache();
-	bool processSimulatorPackets();
-	bool writeToCacheComplete();
-	
-	void lockWorkMutex() { mWorkMutex.lock(); }
-	void unlockWorkMutex() { mWorkMutex.unlock(); }
-
-private:
-	enum e_state // mState
-	{
-		// NOTE: Affects LLTextureBar::draw in lltextureview.cpp (debug hack)
-		INVALID = 0,
-		INIT,
-		LOAD_FROM_TEXTURE_CACHE,
-		CACHE_POST,
-		LOAD_FROM_NETWORK,
-		LOAD_FROM_SIMULATOR,
-		SEND_HTTP_REQ,
-		WAIT_HTTP_REQ,
-		DECODE_IMAGE,
-		DECODE_IMAGE_UPDATE,
-		WRITE_TO_CACHE,
-		WAIT_ON_WRITE,
-		DONE
-	};
-	enum e_request_state // mSentRequest
-	{
-		UNSENT = 0,
-		QUEUED = 1,
-		SENT_SIM = 2
-	};
-	enum e_write_to_cache_state //mWriteToCacheState
-	{
-		NOT_WRITE = 0,
-		CAN_WRITE = 1,
-		SHOULD_WRITE = 2
-	};
-	static const char* sStateDescs[];
-	e_state mState;
-	e_write_to_cache_state mWriteToCacheState;
-	LLTextureFetch* mFetcher;
-	LLPointer<LLImageFormatted> mFormattedImage;
-	LLPointer<LLImageRaw> mRawImage;
-	LLPointer<LLImageRaw> mAuxImage;
-	LLUUID mID;
-	LLHost mHost;
-	std::string mUrl;
-	U8 mType;
-	F32 mImagePriority;
-	U32 mWorkPriority;
-	F32 mRequestedPriority;
-	S32 mDesiredDiscard;
-	S32 mSimRequestedDiscard;
-	S32 mRequestedDiscard;
-	S32 mLoadedDiscard;
-	S32 mDecodedDiscard;
-	LLFrameTimer mRequestedTimer;
-	LLFrameTimer mFetchTimer;
-	LLTextureCache::handle_t mCacheReadHandle;
-	LLTextureCache::handle_t mCacheWriteHandle;
-	U8* mBuffer;
-	S32 mBufferSize;
-	S32 mRequestedSize;
-	S32 mDesiredSize;
-	S32 mFileSize;
-	S32 mCachedSize;	
-	e_request_state mSentRequest;
-	handle_t mDecodeHandle;
-	BOOL mLoaded;
-	BOOL mDecoded;
-	BOOL mWritten;
-	BOOL mNeedsAux;
-	BOOL mHaveAllData;
-	BOOL mInLocalCache;
-	bool mCanUseHTTP ;
-	bool mCanUseNET ; //can get from asset server.
-	S32 mHTTPFailCount;
-	S32 mRetryAttempt;
-	S32 mActiveCount;
-	U32 mGetStatus;
-	std::string mGetReason;
-	
-	// Work Data
-	LLMutex mWorkMutex;
-	struct PacketData
-	{
-		PacketData(U8* data, S32 size) { mData = data; mSize = size; }
-		~PacketData() { clearData(); }
-		void clearData() { delete[] mData; mData = NULL; }
-		U8* mData;
-		U32 mSize;
-	};
-	std::vector<PacketData*> mPackets;
-	S32 mFirstPacket;
-	S32 mLastPacket;
-	U16 mTotalPackets;
-	U8 mImageCodec;
-
-	LLViewerAssetStats::duration_t mMetricsStartTime;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-class HTTPGetResponder : public LLCurl::Responder
-{
-	LOG_CLASS(HTTPGetResponder);
-public:
-	HTTPGetResponder(LLTextureFetch* fetcher, const LLUUID& id, U64 startTime, S32 requestedSize, U32 offset, bool redir)
-		: mFetcher(fetcher), mID(id), mStartTime(startTime), mRequestedSize(requestedSize), mOffset(offset), mFollowRedir(redir)
-	{
-	}
-	~HTTPGetResponder()
-	{
-	}
-
-	virtual void completedRaw(U32 status, const std::string& reason,
-							  const LLChannelDescriptors& channels,
-							  const LLIOPipe::buffer_ptr_t& buffer)
-	{
-		static LLCachedControl<bool> log_to_viewer_log(gSavedSettings,"LogTextureDownloadsToViewerLog");
-		static LLCachedControl<bool> log_to_sim(gSavedSettings,"LogTextureDownloadsToSimulator");
-		static LLCachedControl<bool> log_texture_traffic(gSavedSettings,"LogTextureNetworkTraffic") ;
-
-		if (log_to_viewer_log || log_to_sim)
-		{
-			mFetcher->mTextureInfo.setRequestStartTime(mID, mStartTime);
-			U64 timeNow = LLTimer::getTotalTime();
-			mFetcher->mTextureInfo.setRequestType(mID, LLTextureInfoDetails::REQUEST_TYPE_HTTP);
-			mFetcher->mTextureInfo.setRequestSize(mID, mRequestedSize);
-			mFetcher->mTextureInfo.setRequestOffset(mID, mOffset);
-			mFetcher->mTextureInfo.setRequestCompleteTimeAndLog(mID, timeNow);
-		}
-
-		lldebugs << "HTTP COMPLETE: " << mID << llendl;
-		LLTextureFetchWorker* worker = mFetcher->getWorker(mID);
-		if (worker)
-		{
-			bool success = false;
-			bool partial = false;
-			if (HTTP_OK <= status &&  status < HTTP_MULTIPLE_CHOICES)
-			{
-				success = true;
-				if (HTTP_PARTIAL_CONTENT == status) // partial information
-				{
-					partial = true;
-				}
-			}
-
-			if (!success)
-			{
-				worker->setGetStatus(status, reason);
-// 				llwarns << "CURL GET FAILED, status:" << status << " reason:" << reason << llendl;
-			}
-			
-			S32 data_size = worker->callbackHttpGet(channels, buffer, partial, success);
-			
-			if(log_texture_traffic && data_size > 0)
-			{
-				LLViewerTexture* tex = LLViewerTextureManager::findTexture(mID) ;
-				if(tex)
-				{
-					gTotalTextureBytesPerBoostLevel[tex->getBoostLevel()] += data_size ;
-				}
-			}
-
-			mFetcher->removeFromHTTPQueue(mID, data_size);
-
-			if (worker->mMetricsStartTime)
-			{
-				LLViewerAssetStatsFF::record_response_thread1(LLViewerAssetType::AT_TEXTURE,
-															  true,
-															  LLImageBase::TYPE_AVATAR_BAKE == worker->mType,
-															  LLViewerAssetStatsFF::get_timestamp() - worker->mMetricsStartTime);
-				worker->mMetricsStartTime = 0;
-			}
-			LLViewerAssetStatsFF::record_dequeue_thread1(LLViewerAssetType::AT_TEXTURE,
-														 true,
-														 LLImageBase::TYPE_AVATAR_BAKE == worker->mType);
-		}
-		else
-		{
-			mFetcher->removeFromHTTPQueue(mID);
- 			llwarns << "Worker not found: " << mID << llendl;
-		}
-	}
-
-	virtual bool followRedir()
-	{
-		return mFollowRedir;
-	}
-	
-private:
-	LLTextureFetch* mFetcher;
-	LLUUID mID;
-	U64 mStartTime;
-	S32 mRequestedSize;
-	U32 mOffset;
-	bool mFollowRedir;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-// Cross-thread messaging for asset metrics.
-
-/**
- * @brief Base class for cross-thread requests made of the fetcher
- *
- * I believe the intent of the LLQueuedThread class was to
- * have these operations derived from LLQueuedThread::QueuedRequest
- * but the texture fetcher has elected to manage the queue
- * in its own manner.  So these are free-standing objects which are
- * managed in simple FIFO order on the mCommands queue of the
- * LLTextureFetch object.
- *
- * What each represents is a simple command sent from an
- * outside thread into the TextureFetch thread to be processed
- * in order and in a timely fashion (though not an absolute
- * higher priority than other operations of the thread).
- * Each operation derives a new class from the base customizing
- * members, constructors and the doWork() method to effect
- * the command.
- *
- * The flow is one-directional.  There are two global instances
- * of the LLViewerAssetStats collector, one for the main program's
- * thread pointed to by gViewerAssetStatsMain and one for the
- * TextureFetch thread pointed to by gViewerAssetStatsThread1.
- * Common operations has each thread recording metrics events
- * into the respective collector unconcerned with locking and
- * the state of any other thread.  But when the agent moves into
- * a different region or the metrics timer expires and a report
- * needs to be sent back to the grid, messaging across threads
- * is required to distribute data and perform global actions.
- * In pseudo-UML, it looks like:
- *
- *                       Main                 Thread1
- *                        .                      .
- *                        .                      .
- *                     +-----+                   .
- *                     | AM  |                   .
- *                     +--+--+                   .
- *      +-------+         |                      .
- *      | Main  |      +--+--+                   .
- *      |       |      | SRE |---.               .
- *      | Stats |      +-----+    \              .
- *      |       |         |        \  (uuid)  +-----+
- *      | Coll. |      +--+--+      `-------->| SR  |
- *      +-------+      | MSC |                +--+--+
- *         | ^         +-----+                   |
- *         | |  (uuid)  / .                   +-----+ (uuid)
- *         |  `--------'  .                   | MSC |---------.
- *         |              .                   +-----+         |
- *         |           +-----+                   .            v
- *         |           | TE  |                   .        +-------+
- *         |           +--+--+                   .        | Thd1  |
- *         |              |                      .        |       |
- *         |           +-----+                   .        | Stats |
- *          `--------->| RSC |                   .        |       |
- *                     +--+--+                   .        | Coll. |
- *                        |                      .        +-------+
- *                     +--+--+                   .            |
- *                     | SME |---.               .            |
- *                     +-----+    \              .            |
- *                        .        \ (clone)  +-----+         |
- *                        .         `-------->| SM  |         |
- *                        .                   +--+--+         |
- *                        .                      |            |
- *                        .                   +-----+         |
- *                        .                   | RSC |<--------'
- *                        .                   +-----+
- *                        .                      |
- *                        .                   +-----+
- *                        .                   | CP  |--> HTTP POST
- *                        .                   +-----+
- *                        .                      .
- *                        .                      .
- *
- *
- * Key:
- *
- * SRE - Set Region Enqueued.  Enqueue a 'Set Region' command in
- *       the other thread providing the new UUID of the region.
- *       TFReqSetRegion carries the data.
- * SR  - Set Region.  New region UUID is sent to the thread-local
- *       collector.
- * SME - Send Metrics Enqueued.  Enqueue a 'Send Metrics' command
- *       including an ownership transfer of a cloned LLViewerAssetStats.
- *       TFReqSendMetrics carries the data.
- * SM  - Send Metrics.  Global metrics reporting operation.  Takes
- *       the cloned stats from the command, merges it with the
- *       thread's local stats, converts to LLSD and sends it on
- *       to the grid.
- * AM  - Agent Moved.  Agent has completed some sort of move to a
- *       new region.
- * TE  - Timer Expired.  Metrics timer has expired (on the order
- *       of 10 minutes).
- * CP  - CURL Post
- * MSC - Modify Stats Collector.  State change in the thread-local
- *       collector.  Typically a region change which affects the
- *       global pointers used to find the 'current stats'.
- * RSC - Read Stats Collector.  Extract collector data cloning it
- *       (i.e. deep copy) when necessary.
- *
- */
-class LLTextureFetch::TFRequest // : public LLQueuedThread::QueuedRequest
-{
-public:
-	// Default ctors and assignment operator are correct.
-
-	virtual ~TFRequest()
-		{}
-
-	// Patterned after QueuedRequest's method but expected behavior
-	// is different.  Always expected to complete on the first call
-	// and work dispatcher will assume the same and delete the
-	// request after invocation.
-	virtual bool doWork(LLTextureFetch * fetcher) = 0;
-};
-
-namespace 
-{
-
-/**
- * @brief Implements a 'Set Region' cross-thread command.
- *
- * When an agent moves to a new region, subsequent metrics need
- * to be binned into a new or existing stats collection in 1:1
- * relationship with the region.  We communicate this region
- * change across the threads involved in the communication with
- * this message.
- *
- * Corresponds to LLTextureFetch::commandSetRegion()
- */
-class TFReqSetRegion : public LLTextureFetch::TFRequest
-{
-public:
-	TFReqSetRegion(U64 region_handle)
-		: LLTextureFetch::TFRequest(),
-		  mRegionHandle(region_handle)
-		{}
-	TFReqSetRegion & operator=(const TFReqSetRegion &);	// Not defined
-
-	virtual ~TFReqSetRegion()
-		{}
-
-	virtual bool doWork(LLTextureFetch * fetcher);
-		
-public:
-	const U64 mRegionHandle;
-};
-
-
-/**
- * @brief Implements a 'Send Metrics' cross-thread command.
- *
- * This is the big operation.  The main thread gathers metrics
- * for a period of minutes into LLViewerAssetStats and other
- * objects then makes a snapshot of the data by cloning the
- * collector.  This command transfers the clone, along with a few
- * additional arguments (UUIDs), handing ownership to the
- * TextureFetch thread.  It then merges its own data into the
- * cloned copy, converts to LLSD and kicks off an HTTP POST of
- * the resulting data to the currently active metrics collector.
- *
- * Corresponds to LLTextureFetch::commandSendMetrics()
- */
-class TFReqSendMetrics : public LLTextureFetch::TFRequest
-{
-public:
-    /**
-	 * Construct the 'Send Metrics' command to have the TextureFetch
-	 * thread add and log metrics data.
-	 *
-	 * @param	caps_url		URL of a "ViewerMetrics" Caps target
-	 *							to receive the data.  Does not have to
-	 *							be associated with a particular region.
-	 *
-	 * @param	session_id		UUID of the agent's session.
-	 *
-	 * @param	agent_id		UUID of the agent.  (Being pure here...)
-	 *
-	 * @param	main_stats		Pointer to a clone of the main thread's
-	 *							LLViewerAssetStats data.  Thread1 takes
-	 *							ownership of the copy and disposes of it
-	 *							when done.
-	 */
-	TFReqSendMetrics(const std::string & caps_url,
-					 const LLUUID & session_id,
-					 const LLUUID & agent_id,
-					 LLViewerAssetStats * main_stats)
-		: LLTextureFetch::TFRequest(),
-		  mCapsURL(caps_url),
-		  mSessionID(session_id),
-		  mAgentID(agent_id),
-		  mMainStats(main_stats)
-		{}
-	TFReqSendMetrics & operator=(const TFReqSendMetrics &);	// Not defined
-
-	virtual ~TFReqSendMetrics();
-
-	virtual bool doWork(LLTextureFetch * fetcher);
-		
-public:
-	const std::string mCapsURL;
-	const LLUUID mSessionID;
-	const LLUUID mAgentID;
-	LLViewerAssetStats * mMainStats;
-};
-
-/*
- * Examines the merged viewer metrics report and if found to be too long,
- * will attempt to truncate it in some reasonable fashion.
- *
- * @param		max_regions		Limit of regions allowed in report.
- *
- * @param		metrics			Full, merged viewer metrics report.
- *
- * @returns		If data was truncated, returns true.
- */
-bool truncate_viewer_metrics(int max_regions, LLSD & metrics);
-
-} // end of anonymous namespace
-
-
-//////////////////////////////////////////////////////////////////////////////
-
-//static
-const char* LLTextureFetchWorker::sStateDescs[] = {
-	"INVALID",
-	"INIT",
-	"LOAD_FROM_TEXTURE_CACHE",
-	"CACHE_POST",
-	"LOAD_FROM_NETWORK",
-	"LOAD_FROM_SIMULATOR",
-	"SEND_HTTP_REQ",
-	"WAIT_HTTP_REQ",
-	"DECODE_IMAGE",
-	"DECODE_IMAGE_UPDATE",
-	"WRITE_TO_CACHE",
-	"WAIT_ON_WRITE",
-	"DONE",
-};
-
-// static
-volatile bool LLTextureFetch::svMetricsDataBreak(true);	// Start with a data break
-
-// called from MAIN THREAD
-
-LLTextureFetchWorker::LLTextureFetchWorker(LLTextureFetch* fetcher,
-										   const std::string& url, // Optional URL
-										   const LLUUID& id,	// Image UUID
-										   const LLHost& host,	// Simulator host
-										   F32 priority,		// Priority
-										   S32 discard,			// Desired discard
-										   S32 size)			// Desired size
-	: LLWorkerClass(fetcher, "TextureFetch"),
-	  mState(INIT),
-	  mWriteToCacheState(NOT_WRITE),
-	  mFetcher(fetcher),
-	  mID(id),
-	  mHost(host),
-	  mUrl(url),
-	  mImagePriority(priority),
-	  mWorkPriority(0),
-	  mRequestedPriority(0.f),
-	  mDesiredDiscard(-1),
-	  mSimRequestedDiscard(-1),
-	  mRequestedDiscard(-1),
-	  mLoadedDiscard(-1),
-	  mDecodedDiscard(-1),
-	  mCacheReadHandle(LLTextureCache::nullHandle()),
-	  mCacheWriteHandle(LLTextureCache::nullHandle()),
-	  mBuffer(NULL),
-	  mBufferSize(0),
-	  mRequestedSize(0),
-	  mDesiredSize(TEXTURE_CACHE_ENTRY_SIZE),
-	  mFileSize(0),
-	  mCachedSize(0),
-	  mLoaded(FALSE),
-	  mSentRequest(UNSENT),
-	  mDecodeHandle(0),
-	  mDecoded(FALSE),
-	  mWritten(FALSE),
-	  mNeedsAux(FALSE),
-	  mHaveAllData(FALSE),
-	  mInLocalCache(FALSE),
-	  mCanUseHTTP(true),
-	  mHTTPFailCount(0),
-	  mRetryAttempt(0),
-	  mActiveCount(0),
-	  mGetStatus(0),
-	  mWorkMutex(NULL),
-	  mFirstPacket(0),
-	  mLastPacket(-1),
-	  mTotalPackets(0),
-	  mImageCodec(IMG_CODEC_INVALID),
-	  mMetricsStartTime(0)
-{
-	mCanUseNET = mUrl.empty() ;
-
-	calcWorkPriority();
-	mType = host.isOk() ? LLImageBase::TYPE_AVATAR_BAKE : LLImageBase::TYPE_NORMAL;
-// 	llinfos << "Create: " << mID << " mHost:" << host << " Discard=" << discard << llendl;
-	if (!mFetcher->mDebugPause)
-	{
-		U32 work_priority = mWorkPriority | LLWorkerThread::PRIORITY_HIGH;
-		addWork(0, work_priority );
-	}
-	setDesiredDiscard(discard, size);
-}
-
-LLTextureFetchWorker::~LLTextureFetchWorker()
-{
-// 	llinfos << "Destroy: " << mID
-// 			<< " Decoded=" << mDecodedDiscard
-// 			<< " Requested=" << mRequestedDiscard
-// 			<< " Desired=" << mDesiredDiscard << llendl;
-	llassert_always(!haveWork());
-	lockWorkMutex();
-	if (mCacheReadHandle != LLTextureCache::nullHandle() && mFetcher->mTextureCache)
-	{
-		mFetcher->mTextureCache->readComplete(mCacheReadHandle, true);
-	}
-	if (mCacheWriteHandle != LLTextureCache::nullHandle() && mFetcher->mTextureCache)
-	{
-		mFetcher->mTextureCache->writeComplete(mCacheWriteHandle, true);
-	}
-	mFormattedImage = NULL;
-	clearPackets();
-	unlockWorkMutex();
-	mFetcher->removeFromHTTPQueue(mID);
-}
-
-void LLTextureFetchWorker::clearPackets()
-{
-	for_each(mPackets.begin(), mPackets.end(), DeletePointer());
-	mPackets.clear();
-	mTotalPackets = 0;
-	mLastPacket = -1;
-	mFirstPacket = 0;
-}
-
-void LLTextureFetchWorker::setupPacketData()
-{
-	S32 data_size = 0;
-	if (mFormattedImage.notNull())
-	{
-		data_size = mFormattedImage->getDataSize();
-	}
-	if (data_size > 0)
-	{
-		// Only used for simulator requests
-		mFirstPacket = (data_size - FIRST_PACKET_SIZE) / MAX_IMG_PACKET_SIZE + 1;
-		if (FIRST_PACKET_SIZE + (mFirstPacket-1) * MAX_IMG_PACKET_SIZE != data_size)
-		{
-			llwarns << "Bad CACHED TEXTURE size: " << data_size << " removing." << llendl;
-			removeFromCache();
-			resetFormattedData();
-			clearPackets();
-		}
-		else if (mFileSize > 0)
-		{
-			mLastPacket = mFirstPacket-1;
-			mTotalPackets = (mFileSize - FIRST_PACKET_SIZE + MAX_IMG_PACKET_SIZE-1) / MAX_IMG_PACKET_SIZE + 1;
-		}
-		else
-		{
-			// This file was cached using HTTP so we have to refetch the first packet
-			resetFormattedData();
-			clearPackets();
-		}
-	}
-}
-
-U32 LLTextureFetchWorker::calcWorkPriority()
-{
- 	//llassert_always(mImagePriority >= 0 && mImagePriority <= LLViewerFetchedTexture::maxDecodePriority());
-	static const F32 PRIORITY_SCALE = (F32)LLWorkerThread::PRIORITY_LOWBITS / LLViewerFetchedTexture::maxDecodePriority();
-
-	mWorkPriority = llmin((U32)LLWorkerThread::PRIORITY_LOWBITS, (U32)(mImagePriority * PRIORITY_SCALE));
-	return mWorkPriority;
-}
-
-// mWorkMutex is locked
-void LLTextureFetchWorker::setDesiredDiscard(S32 discard, S32 size)
-{
-	bool prioritize = false;
-	if (mDesiredDiscard != discard)
-	{
-		if (!haveWork())
-		{
-			calcWorkPriority();
-			if (!mFetcher->mDebugPause)
-			{
-				U32 work_priority = mWorkPriority | LLWorkerThread::PRIORITY_HIGH;
-				addWork(0, work_priority);
-			}
-		}
-		else if (mDesiredDiscard < discard)
-		{
-			prioritize = true;
-		}
-		mDesiredDiscard = discard;
-		mDesiredSize = size;
-	}
-	else if (size > mDesiredSize)
-	{
-		mDesiredSize = size;
-		prioritize = true;
-	}
-	mDesiredSize = llmax(mDesiredSize, TEXTURE_CACHE_ENTRY_SIZE);
-	if ((prioritize && mState == INIT) || mState == DONE)
-	{
-		mState = INIT;
-		U32 work_priority = mWorkPriority | LLWorkerThread::PRIORITY_HIGH;
-		setPriority(work_priority);
-	}
-}
-
-void LLTextureFetchWorker::setImagePriority(F32 priority)
-{
-// 	llassert_always(priority >= 0 && priority <= LLViewerTexture::maxDecodePriority());
-	F32 delta = fabs(priority - mImagePriority);
-	if (delta > (mImagePriority * .05f) || mState == DONE)
-	{
-		mImagePriority = priority;
-		calcWorkPriority();
-		U32 work_priority = mWorkPriority | (getPriority() & LLWorkerThread::PRIORITY_HIGHBITS);
-		setPriority(work_priority);
-	}
-}
-
-void LLTextureFetchWorker::resetFormattedData()
-{
-	delete[] mBuffer;
-	mBuffer = NULL;
-	mBufferSize = 0;
-	if (mFormattedImage.notNull())
-	{
-		mFormattedImage->deleteData();
-	}
-	mHaveAllData = FALSE;
-}
-
-// Called from MAIN thread
-void LLTextureFetchWorker::startWork(S32 param)
-{
-	llassert(mFormattedImage.isNull());
-}
-
-#include "llviewertexturelist.h" // debug
-
-// Called from LLWorkerThread::processRequest()
-bool LLTextureFetchWorker::doWork(S32 param)
-{
-	LLMutexLock lock(&mWorkMutex);
-
-	if ((mFetcher->isQuitting() || getFlags(LLWorkerClass::WCF_DELETE_REQUESTED)))
-	{
-		if (mState < DECODE_IMAGE)
-		{
-			return true; // abort
-		}
-	}
-
-	if(mImagePriority < F_ALMOST_ZERO)
-	{
-		if (mState == INIT || mState == LOAD_FROM_NETWORK || mState == LOAD_FROM_SIMULATOR)
-		{
-			return true; // abort
-		}
-	}
-	if(mState > CACHE_POST && !mCanUseNET && !mCanUseHTTP)
-	{
-		//nowhere to get data, abort.
-		return true ;
-	}
-
-	if (mFetcher->mDebugPause)
-	{
-		return false; // debug: don't do any work
-	}
-	if (mID == mFetcher->mDebugID)
-	{
-		mFetcher->mDebugCount++; // for setting breakpoints
-	}
-
-	if (mState != DONE)
-	{
-		mFetchTimer.reset();
-	}
-
-	if (mState == INIT)
-	{		
-		mRawImage = NULL ;
-		mRequestedDiscard = -1;
-		mLoadedDiscard = -1;
-		mDecodedDiscard = -1;
-		mRequestedSize = 0;
-		mFileSize = 0;
-		mCachedSize = 0;
-		mLoaded = FALSE;
-		mSentRequest = UNSENT;
-		mDecoded  = FALSE;
-		mWritten  = FALSE;
-		delete[] mBuffer;
-		mBuffer = NULL;
-		mBufferSize = 0;
-		mHaveAllData = FALSE;
-		clearPackets(); // TODO: Shouldn't be necessary
-		mCacheReadHandle = LLTextureCache::nullHandle();
-		mCacheWriteHandle = LLTextureCache::nullHandle();
-		mState = LOAD_FROM_TEXTURE_CACHE;
-		mDesiredSize = llmax(mDesiredSize, TEXTURE_CACHE_ENTRY_SIZE); // min desired size is TEXTURE_CACHE_ENTRY_SIZE
-		LL_DEBUGS("Texture") << mID << ": Priority: " << llformat("%8.0f",mImagePriority)
-							 << " Desired Discard: " << mDesiredDiscard << " Desired Size: " << mDesiredSize << LL_ENDL;
-		// fall through
-	}
-
-	if (mState == LOAD_FROM_TEXTURE_CACHE)
-	{
-		if (mCacheReadHandle == LLTextureCache::nullHandle())
-		{
-			U32 cache_priority = mWorkPriority;
-			S32 offset = mFormattedImage.notNull() ? mFormattedImage->getDataSize() : 0;
-			S32 size = mDesiredSize - offset;
-			if (size <= 0)
-			{
-				mState = CACHE_POST;
-				return false;
-			}
-			mFileSize = 0;
-			mLoaded = FALSE;			
-			
-			if (mUrl.compare(0, 7, "file://") == 0)
-			{
-				setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); // Set priority first since Responder may change it
-
-				// read file from local disk
-				std::string filename = mUrl.substr(7, std::string::npos);
-				CacheReadResponder* responder = new CacheReadResponder(mFetcher, mID, mFormattedImage);
-				mCacheReadHandle = mFetcher->mTextureCache->readFromCache(filename, mID, cache_priority,
-																		  offset, size, responder);
-			}
-			else if (mUrl.empty())
-			{
-				setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); // Set priority first since Responder may change it
-
-				CacheReadResponder* responder = new CacheReadResponder(mFetcher, mID, mFormattedImage);
-				mCacheReadHandle = mFetcher->mTextureCache->readFromCache(mID, cache_priority,
-																		  offset, size, responder);
-			}
-			else if(mCanUseHTTP)
-			{
-				if (!(mUrl.compare(0, 7, "http://") == 0))
-				{
-					// *TODO:?remove this warning
-					llwarns << "Unknown URL Type: " << mUrl << llendl;
-				}
-				setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
-				mState = SEND_HTTP_REQ;
-			}
-			else
-			{
-				setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
-				mState = LOAD_FROM_NETWORK;
-			}
-		}
-
-		if (mLoaded)
-		{
-			// Make sure request is complete. *TODO: make this auto-complete
-			if (mFetcher->mTextureCache->readComplete(mCacheReadHandle, false))
-			{
-				mCacheReadHandle = LLTextureCache::nullHandle();
-				mState = CACHE_POST;
-				// fall through
-			}
-			else
-			{
-				return false;
-			}
-		}
-		else
-		{
-			return false;
-		}
-	}
-
-	if (mState == CACHE_POST)
-	{
-		mCachedSize = mFormattedImage.notNull() ? mFormattedImage->getDataSize() : 0;
-		// Successfully loaded
-		if ((mCachedSize >= mDesiredSize) || mHaveAllData)
-		{
-			// we have enough data, decode it
-			llassert_always(mFormattedImage->getDataSize() > 0);
-			mLoadedDiscard = mDesiredDiscard;
-			mState = DECODE_IMAGE;
-			mWriteToCacheState = NOT_WRITE ;
-			LL_DEBUGS("Texture") << mID << ": Cached. Bytes: " << mFormattedImage->getDataSize()
-								 << " Size: " << llformat("%dx%d",mFormattedImage->getWidth(),mFormattedImage->getHeight())
-								 << " Desired Discard: " << mDesiredDiscard << " Desired Size: " << mDesiredSize << LL_ENDL;
-			// fall through
-		}
-		else
-		{
-			if (mUrl.compare(0, 7, "file://") == 0)
-			{
-				// failed to load local file, we're done.
-				return true;
-			}
-			// need more data
-			else
-			{
-				LL_DEBUGS("Texture") << mID << ": Not in Cache" << LL_ENDL;
-				mState = LOAD_FROM_NETWORK;
-			}
-			// fall through
-		}
-	}
-
-	if (mState == LOAD_FROM_NETWORK)
-	{
-		static LLCachedControl<bool> use_http(gSavedSettings,"ImagePipelineUseHTTP");
-
-// 		if (mHost != LLHost::invalid) get_url = false;
-		if ( use_http && mCanUseHTTP && mUrl.empty())//get http url.
-		{
-			LLViewerRegion* region = NULL;
-			if (mHost == LLHost::invalid)
-				region = gAgent.getRegion();
-			else
-				region = LLWorld::getInstance()->getRegion(mHost);
-
-			if (region)
-			{
-				std::string http_url = region->getHttpUrl() ;
-				if (!http_url.empty())
-				{
-					mUrl = http_url + "/?texture_id=" + mID.asString().c_str();
-					mWriteToCacheState = CAN_WRITE ; //because this texture has a fixed texture id.
-				}
-				else
-				{
-					mCanUseHTTP = false ;
-				}
-			}
-			else
-			{
-				// This will happen if not logged in or if a region deoes not have HTTP Texture enabled
-				//llwarns << "Region not found for host: " << mHost << llendl;
-				mCanUseHTTP = false;
-			}
-		}
-		if (mCanUseHTTP && !mUrl.empty())
-		{
-			mState = LLTextureFetchWorker::SEND_HTTP_REQ;
-			setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
-			if(mWriteToCacheState != NOT_WRITE)
-			{
-				mWriteToCacheState = CAN_WRITE ;
-			}
-			// don't return, fall through to next state
-		}
-		else if (mSentRequest == UNSENT && mCanUseNET)
-		{
-			// Add this to the network queue and sit here.
-			// LLTextureFetch::update() will send off a request which will change our state
-			mWriteToCacheState = CAN_WRITE ;
-			mRequestedSize = mDesiredSize;
-			mRequestedDiscard = mDesiredDiscard;
-			mSentRequest = QUEUED;
-			mFetcher->addToNetworkQueue(this);
-			if (! mMetricsStartTime)
-			{
-				mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp();
-			}
-			LLViewerAssetStatsFF::record_enqueue_thread1(LLViewerAssetType::AT_TEXTURE,
-														 false,
-														 LLImageBase::TYPE_AVATAR_BAKE == mType);
-			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
-			
-			return false;
-		}
-		else
-		{
-			// Shouldn't need to do anything here
-			//llassert_always(mFetcher->mNetworkQueue.find(mID) != mFetcher->mNetworkQueue.end());
-			// Make certain this is in the network queue
-			//mFetcher->addToNetworkQueue(this);
-			//if (! mMetricsStartTime)
-			//{
-			//   mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp();
-			//}
-			//LLViewerAssetStatsFF::record_enqueue_thread1(LLViewerAssetType::AT_TEXTURE, false,
-			//                                             LLImageBase::TYPE_AVATAR_BAKE == mType);
-			//setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
-			return false;
-		}
-	}
-	
-	if (mState == LOAD_FROM_SIMULATOR)
-	{
-		if (mFormattedImage.isNull())
-		{
-			mFormattedImage = new LLImageJ2C;
-		}
-		if (processSimulatorPackets())
-		{
-			LL_DEBUGS("Texture") << mID << ": Loaded from Sim. Bytes: " << mFormattedImage->getDataSize() << LL_ENDL;
-			mFetcher->removeFromNetworkQueue(this, false);
-			if (mFormattedImage.isNull() || !mFormattedImage->getDataSize())
-			{
-				// processSimulatorPackets() failed
-// 				llwarns << "processSimulatorPackets() failed to load buffer" << llendl;
-				return true; // failed
-			}
-			setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
-			mState = DECODE_IMAGE;
-			mWriteToCacheState = SHOULD_WRITE;
-
-			if (mMetricsStartTime)
-			{
-				LLViewerAssetStatsFF::record_response_thread1(LLViewerAssetType::AT_TEXTURE,
-															  false,
-															  LLImageBase::TYPE_AVATAR_BAKE == mType,
-															  LLViewerAssetStatsFF::get_timestamp() - mMetricsStartTime);
-				mMetricsStartTime = 0;
-			}
-			LLViewerAssetStatsFF::record_dequeue_thread1(LLViewerAssetType::AT_TEXTURE,
-														 false,
-														 LLImageBase::TYPE_AVATAR_BAKE == mType);
-		}
-		else
-		{
-			mFetcher->addToNetworkQueue(this); // failsafe
-			if (! mMetricsStartTime)
-			{
-				mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp();
-			}
-			LLViewerAssetStatsFF::record_enqueue_thread1(LLViewerAssetType::AT_TEXTURE,
-														 false,
-														 LLImageBase::TYPE_AVATAR_BAKE == mType);
-			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
-		}
-		return false;
-	}
-	
-	if (mState == SEND_HTTP_REQ)
-	{
-		if(mCanUseHTTP)
-		{
-			//NOTE:
-			//control the number of the http requests issued for:
-			//1, not openning too many file descriptors at the same time;
-			//2, control the traffic of http so udp gets bandwidth.
-			//
-			static const S32 MAX_NUM_OF_HTTP_REQUESTS_IN_QUEUE = 32 ;
-			if(mFetcher->getNumHTTPRequests() > MAX_NUM_OF_HTTP_REQUESTS_IN_QUEUE)
-			{
-				return false ; //wait.
-			}
-
-			mFetcher->removeFromNetworkQueue(this, false);
-			
-			S32 cur_size = 0;
-			if (mFormattedImage.notNull())
-			{
-				cur_size = mFormattedImage->getDataSize(); // amount of data we already have
-				if (mFormattedImage->getDiscardLevel() == 0)
-				{
-					if(cur_size > 0)
-					{
-						// We already have all the data, just decode it
-						mLoadedDiscard = mFormattedImage->getDiscardLevel();
-						mState = DECODE_IMAGE;
-						return false;
-					}
-					else
-					{
-						return true ; //abort.
-					}
-				}
-			}
-			mRequestedSize = mDesiredSize;
-			mRequestedDiscard = mDesiredDiscard;
-			mRequestedSize -= cur_size;
-			S32 offset = cur_size;
-			mBufferSize = cur_size; // This will get modified by callbackHttpGet()
-			
-			bool res = false;
-			if (!mUrl.empty())
-			{
-				mLoaded = FALSE;
-				mGetStatus = 0;
-				mGetReason.clear();
-				LL_DEBUGS("Texture") << "HTTP GET: " << mID << " Offset: " << offset
-									 << " Bytes: " << mRequestedSize
-									 << " Bandwidth(kbps): " << mFetcher->getTextureBandwidth() << "/" << mFetcher->mMaxBandwidth
-									 << LL_ENDL;
-				setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
-				mState = WAIT_HTTP_REQ;	
-
-				mFetcher->addToHTTPQueue(mID);
-				if (! mMetricsStartTime)
-				{
-					mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp();
-				}
-				LLViewerAssetStatsFF::record_enqueue_thread1(LLViewerAssetType::AT_TEXTURE,
-															 true,
-															 LLImageBase::TYPE_AVATAR_BAKE == mType);
-
-				// Will call callbackHttpGet when curl request completes
-				std::vector<std::string> headers;
-				headers.push_back("Accept: image/x-j2c");
-				res = mFetcher->mCurlGetRequest->getByteRange(mUrl, headers, offset, mRequestedSize,
-															  new HTTPGetResponder(mFetcher, mID, LLTimer::getTotalTime(), mRequestedSize, offset, true));
-			}
-			if (!res)
-			{
-				llwarns << "HTTP GET request failed for " << mID << llendl;
-				resetFormattedData();
-				++mHTTPFailCount;
-				return true; // failed
-			}
-			// fall through
-		}
-		else //can not use http fetch.
-		{
-			return true ; //abort
-		}
-	}
-	
-	if (mState == WAIT_HTTP_REQ)
-	{
-		if (mLoaded)
-		{
-			S32 cur_size = mFormattedImage.notNull() ? mFormattedImage->getDataSize() : 0;
-			if (mRequestedSize < 0)
-			{
-				S32 max_attempts;
-				if (mGetStatus == HTTP_NOT_FOUND)
-				{
-					mHTTPFailCount = max_attempts = 1; // Don't retry
-					llwarns << "Texture missing from server (404): " << mUrl << llendl;
-
-					//roll back to try UDP
-					if(mCanUseNET)
-					{
-						mState = INIT ;
-						mCanUseHTTP = false ;
-						setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
-						return false ;
-					}
-				}
-				else if (mGetStatus == HTTP_SERVICE_UNAVAILABLE)
-				{
-					// *TODO: Should probably introduce a timer here to delay future HTTP requsts
-					// for a short time (~1s) to ease server load? Ideally the server would queue
-					// requests instead of returning 503... we already limit the number pending.
-					++mHTTPFailCount;
-					max_attempts = mHTTPFailCount+1; // Keep retrying
-					LL_INFOS_ONCE("Texture") << "Texture server busy (503): " << mUrl << LL_ENDL;
-				}
-				else
-				{
-					const S32 HTTP_MAX_RETRY_COUNT = 3;
-					max_attempts = HTTP_MAX_RETRY_COUNT + 1;
-					++mHTTPFailCount;
-					llinfos << "HTTP GET failed for: " << mUrl
-							<< " Status: " << mGetStatus << " Reason: '" << mGetReason << "'"
-							<< " Attempt:" << mHTTPFailCount+1 << "/" << max_attempts << llendl;
-				}
-
-				if (mHTTPFailCount >= max_attempts)
-				{
-					if (cur_size > 0)
-					{
-						// Use available data
-						mLoadedDiscard = mFormattedImage->getDiscardLevel();
-						mState = DECODE_IMAGE;
-						return false; 
-					}
-					else
-					{
-						resetFormattedData();
-						mState = DONE;
-						return true; // failed
-					}
-				}
-				else
-				{
-					mState = SEND_HTTP_REQ;
-					return false; // retry
-				}
-			}
-			
-			llassert_always(mBufferSize == cur_size + mRequestedSize);
-			if(!mBufferSize)//no data received.
-			{
-				delete[] mBuffer; 
-				mBuffer = NULL;
-
-				//abort.
-				mState = DONE;
-				return true;
-			}
-
-			if (mFormattedImage.isNull())
-			{
-				// For now, create formatted image based on extension
-				std::string extension = gDirUtilp->getExtension(mUrl);
-				mFormattedImage = LLImageFormatted::createFromType(LLImageBase::getCodecFromExtension(extension));
-				if (mFormattedImage.isNull())
-				{
-					mFormattedImage = new LLImageJ2C; // default
-				}
-			}
-						
-			if (mHaveAllData && mRequestedDiscard == 0) //the image file is fully loaded.
-			{
-				mFileSize = mBufferSize;
-			}
-			else //the file size is unknown.
-			{
-				mFileSize = mBufferSize + 1 ; //flag the file is not fully loaded.
-			}
-			
-			U8* buffer = new U8[mBufferSize];
-			if (cur_size > 0)
-			{
-				memcpy(buffer, mFormattedImage->getData(), cur_size);
-			}
-			memcpy(buffer + cur_size, mBuffer, mRequestedSize); // append
-			// NOTE: setData releases current data and owns new data (buffer)
-			mFormattedImage->setData(buffer, mBufferSize);
-			// delete temp data
-			delete[] mBuffer; // Note: not 'buffer' (assigned in setData())
-			mBuffer = NULL;
-			mBufferSize = 0;
-			mLoadedDiscard = mRequestedDiscard;
-			mState = DECODE_IMAGE;
-			if(mWriteToCacheState != NOT_WRITE)
-			{
-				mWriteToCacheState = SHOULD_WRITE ;
-			}
-			setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
-			return false;
-		}
-		else
-		{
-			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
-			return false;
-		}
-	}
-	
-	if (mState == DECODE_IMAGE)
-	{
-		static LLCachedControl<bool> textures_decode_disabled(gSavedSettings,"TextureDecodeDisabled");
-		if(textures_decode_disabled)
-		{
-			// for debug use, don't decode
-			mState = DONE;
-			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
-			return true;
-		}
-
-		if (mDesiredDiscard < 0)
-		{
-			// We aborted, don't decode
-			mState = DONE;
-			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
-			return true;
-		}
-		
-		if (mFormattedImage->getDataSize() <= 0)
-		{
-			//llerrs << "Decode entered with invalid mFormattedImage. ID = " << mID << llendl;
-			
-			//abort, don't decode
-			mState = DONE;
-			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
-			return true;
-		}
-		if (mLoadedDiscard < 0)
-		{
-			//llerrs << "Decode entered with invalid mLoadedDiscard. ID = " << mID << llendl;
-
-			//abort, don't decode
-			mState = DONE;
-			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
-			return true;
-		}
-		setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); // Set priority first since Responder may change it
-		mRawImage = NULL;
-		mAuxImage = NULL;
-		llassert_always(mFormattedImage.notNull());
-		S32 discard = mHaveAllData ? 0 : mLoadedDiscard;
-		U32 image_priority = LLWorkerThread::PRIORITY_NORMAL | mWorkPriority;
-		mDecoded  = FALSE;
-		mState = DECODE_IMAGE_UPDATE;
-		LL_DEBUGS("Texture") << mID << ": Decoding. Bytes: " << mFormattedImage->getDataSize() << " Discard: " << discard
-				<< " All Data: " << mHaveAllData << LL_ENDL;
-		mDecodeHandle = mFetcher->mImageDecodeThread->decodeImage(mFormattedImage, image_priority, discard, mNeedsAux,
-																  new DecodeResponder(mFetcher, mID, this));
-		// fall though
-	}
-	
-	if (mState == DECODE_IMAGE_UPDATE)
-	{
-		if (mDecoded)
-		{
-			if (mDecodedDiscard < 0)
-			{
-				LL_DEBUGS("Texture") << mID << ": Failed to Decode." << LL_ENDL;
-				if (mCachedSize > 0 && !mInLocalCache && mRetryAttempt == 0)
-				{
-					// Cache file should be deleted, try again
-// 					llwarns << mID << ": Decode of cached file failed (removed), retrying" << llendl;
-					llassert_always(mDecodeHandle == 0);
-					mFormattedImage = NULL;
-					++mRetryAttempt;
-					setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
-					mState = INIT;
-					return false;
-				}
-				else
-				{
-// 					llwarns << "UNABLE TO LOAD TEXTURE: " << mID << " RETRIES: " << mRetryAttempt << llendl;
-					mState = DONE; // failed
-				}
-			}
-			else
-			{
-				llassert_always(mRawImage.notNull());
-				LL_DEBUGS("Texture") << mID << ": Decoded. Discard: " << mDecodedDiscard
-						<< " Raw Image: " << llformat("%dx%d",mRawImage->getWidth(),mRawImage->getHeight()) << LL_ENDL;
-				setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
-				mState = WRITE_TO_CACHE;
-			}
-			// fall through
-		}
-		else
-		{
-			return false;
-		}
-	}
-
-	if (mState == WRITE_TO_CACHE)
-	{
-		if (mWriteToCacheState != SHOULD_WRITE || mFormattedImage.isNull())
-		{
-			// If we're in a local cache or we didn't actually receive any new data,
-			// or we failed to load anything, skip
-			mState = DONE;
-			return false;
-		}
-		S32 datasize = mFormattedImage->getDataSize();
-		if(mFileSize < datasize)//This could happen when http fetching and sim fetching mixed.
-		{
-			if(mHaveAllData)
-			{
-				mFileSize = datasize ;
-			}
-			else
-			{
-				mFileSize = datasize + 1 ; //flag not fully loaded.
-			}
-		}
-		llassert_always(datasize);
-		setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); // Set priority first since Responder may change it
-		U32 cache_priority = mWorkPriority;
-		mWritten = FALSE;
-		mState = WAIT_ON_WRITE;
-		CacheWriteResponder* responder = new CacheWriteResponder(mFetcher, mID);
-		mCacheWriteHandle = mFetcher->mTextureCache->writeToCache(mID, cache_priority,
-																  mFormattedImage->getData(), datasize,
-																  mFileSize, responder);
-		// fall through
-	}
-	
-	if (mState == WAIT_ON_WRITE)
-	{
-		if (writeToCacheComplete())
-		{
-			mState = DONE;
-			// fall through
-		}
-		else
-		{
-			if (mDesiredDiscard < mDecodedDiscard)
-			{
-				// We're waiting for this write to complete before we can receive more data
-				// (we can't touch mFormattedImage until the write completes)
-				// Prioritize the write
-				mFetcher->mTextureCache->prioritizeWrite(mCacheWriteHandle);
-			}
-			return false;
-		}
-	}
-
-	if (mState == DONE)
-	{
-		if (mDecodedDiscard >= 0 && mDesiredDiscard < mDecodedDiscard)
-		{
-			// More data was requested, return to INIT
-			mState = INIT;
-			setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
-			return false;
-		}
-		else
-		{
-			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
-			return true;
-		}
-	}
-	
-	return false;
-}
-
-// Called from MAIN thread
-void LLTextureFetchWorker::endWork(S32 param, bool aborted)
-{
-	if (mDecodeHandle != 0)
-	{
-		mFetcher->mImageDecodeThread->abortRequest(mDecodeHandle, false);
-		mDecodeHandle = 0;
-	}
-	mFormattedImage = NULL;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-// virtual
-void LLTextureFetchWorker::finishWork(S32 param, bool completed)
-{
-	// The following are required in case the work was aborted
-	if (mCacheReadHandle != LLTextureCache::nullHandle())
-	{
-		mFetcher->mTextureCache->readComplete(mCacheReadHandle, true);
-		mCacheReadHandle = LLTextureCache::nullHandle();
-	}
-	if (mCacheWriteHandle != LLTextureCache::nullHandle())
-	{
-		mFetcher->mTextureCache->writeComplete(mCacheWriteHandle, true);
-		mCacheWriteHandle = LLTextureCache::nullHandle();
-	}
-}
-
-// virtual
-bool LLTextureFetchWorker::deleteOK()
-{
-	bool delete_ok = true;
-	// Allow any pending reads or writes to complete
-	if (mCacheReadHandle != LLTextureCache::nullHandle())
-	{
-		if (mFetcher->mTextureCache->readComplete(mCacheReadHandle, true))
-		{
-			mCacheReadHandle = LLTextureCache::nullHandle();
-		}
-		else
-		{
-			delete_ok = false;
-		}
-	}
-	if (mCacheWriteHandle != LLTextureCache::nullHandle())
-	{
-		if (mFetcher->mTextureCache->writeComplete(mCacheWriteHandle))
-		{
-			mCacheWriteHandle = LLTextureCache::nullHandle();
-		}
-		else
-		{
-			delete_ok = false;
-		}
-	}
-
-	if ((haveWork() &&
-		 // not ok to delete from these states
-		 ((mState >= WRITE_TO_CACHE && mState <= WAIT_ON_WRITE))))
-	{
-		delete_ok = false;
-	}
-	
-	return delete_ok;
-}
-
-void LLTextureFetchWorker::removeFromCache()
-{
-	if (!mInLocalCache)
-	{
-		mFetcher->mTextureCache->removeFromCache(mID);
-	}
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-
-bool LLTextureFetchWorker::processSimulatorPackets()
-{
-	if (mFormattedImage.isNull() || mRequestedSize < 0)
-	{
-		// not sure how we got here, but not a valid state, abort!
-		llassert_always(mDecodeHandle == 0);
-		mFormattedImage = NULL;
-		return true;
-	}
-	
-	if (mLastPacket >= mFirstPacket)
-	{
-		S32 buffer_size = mFormattedImage->getDataSize();
-		for (S32 i = mFirstPacket; i<=mLastPacket; i++)
-		{
-			llassert_always(mPackets[i]);
-			buffer_size += mPackets[i]->mSize;
-		}
-		bool have_all_data = mLastPacket >= mTotalPackets-1;
-		if (mRequestedSize <= 0)
-		{
-			// We received a packed but haven't requested anything yet (edge case)
-			// Return true (we're "done") since we didn't request anything
-			return true;
-		}
-		if (buffer_size >= mRequestedSize || have_all_data)
-		{
-			/// We have enough (or all) data
-			if (have_all_data)
-			{
-				mHaveAllData = TRUE;
-			}
-			S32 cur_size = mFormattedImage->getDataSize();
-			if (buffer_size > cur_size)
-			{
-				/// We have new data
-				U8* buffer = new U8[buffer_size];
-				S32 offset = 0;
-				if (cur_size > 0 && mFirstPacket > 0)
-				{
-					memcpy(buffer, mFormattedImage->getData(), cur_size);
-					offset = cur_size;
-				}
-				for (S32 i=mFirstPacket; i<=mLastPacket; i++)
-				{
-					memcpy(buffer + offset, mPackets[i]->mData, mPackets[i]->mSize);
-					offset += mPackets[i]->mSize;
-				}
-				// NOTE: setData releases current data
-				mFormattedImage->setData(buffer, buffer_size);
-			}
-			mLoadedDiscard = mRequestedDiscard;
-			return true;
-		}
-	}
-	return false;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-S32 LLTextureFetchWorker::callbackHttpGet(const LLChannelDescriptors& channels,
-										   const LLIOPipe::buffer_ptr_t& buffer,
-										   bool partial, bool success)
-{
-	S32 data_size = 0 ;
-
-	LLMutexLock lock(&mWorkMutex);
-
-	if (mState != WAIT_HTTP_REQ)
-	{
-		llwarns << "callbackHttpGet for unrequested fetch worker: " << mID
-				<< " req=" << mSentRequest << " state= " << mState << llendl;
-		return data_size;
-	}
-	if (mLoaded)
-	{
-		llwarns << "Duplicate callback for " << mID.asString() << llendl;
-		return data_size ; // ignore duplicate callback
-	}
-	if (success)
-	{
-		// get length of stream:
-		data_size = buffer->countAfter(channels.in(), NULL);		
-	
-		LL_DEBUGS("Texture") << "HTTP RECEIVED: " << mID.asString() << " Bytes: " << data_size << LL_ENDL;
-		if (data_size > 0)
-		{
-			// *TODO: set the formatted image data here directly to avoid the copy
-			mBuffer = new U8[data_size];
-			buffer->readAfter(channels.in(), NULL, mBuffer, data_size);
-			mBufferSize += data_size;
-			if (data_size < mRequestedSize && mRequestedDiscard == 0)
-			{
-				mHaveAllData = TRUE;
-			}
-			else if (data_size > mRequestedSize)
-			{
-				// *TODO: This shouldn't be happening any more
-				llwarns << "data_size = " << data_size << " > requested: " << mRequestedSize << llendl;
-				mHaveAllData = TRUE;
-				llassert_always(mDecodeHandle == 0);
-				mFormattedImage = NULL; // discard any previous data we had
-				mBufferSize = data_size;
-			}
-		}
-		else
-		{
-			// We requested data but received none (and no error),
-			// so presumably we have all of it
-			mHaveAllData = TRUE;
-		}
-		mRequestedSize = data_size;
-	}
-	else
-	{
-		mRequestedSize = -1; // error
-	}
-	mLoaded = TRUE;
-	setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
-
-	return data_size ;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-void LLTextureFetchWorker::callbackCacheRead(bool success, LLImageFormatted* image,
-											 S32 imagesize, BOOL islocal)
-{
-	LLMutexLock lock(&mWorkMutex);
-	if (mState != LOAD_FROM_TEXTURE_CACHE)
-	{
-// 		llwarns << "Read callback for " << mID << " with state = " << mState << llendl;
-		return;
-	}
-	if (success)
-	{
-		llassert_always(imagesize >= 0);
-		mFileSize = imagesize;
-		mFormattedImage = image;
-		mImageCodec = image->getCodec();
-		mInLocalCache = islocal;
-		if (mFileSize != 0 && mFormattedImage->getDataSize() >= mFileSize)
-		{
-			mHaveAllData = TRUE;
-		}
-	}
-	mLoaded = TRUE;
-	setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
-}
-
-void LLTextureFetchWorker::callbackCacheWrite(bool success)
-{
-	LLMutexLock lock(&mWorkMutex);
-	if (mState != WAIT_ON_WRITE)
-	{
-// 		llwarns << "Write callback for " << mID << " with state = " << mState << llendl;
-		return;
-	}
-	mWritten = TRUE;
-	setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-void LLTextureFetchWorker::callbackDecoded(bool success, LLImageRaw* raw, LLImageRaw* aux)
-{
-	LLMutexLock lock(&mWorkMutex);
-	if (mDecodeHandle == 0)
-	{
-		return; // aborted, ignore
-	}
-	if (mState != DECODE_IMAGE_UPDATE)
-	{
-// 		llwarns << "Decode callback for " << mID << " with state = " << mState << llendl;
-		mDecodeHandle = 0;
-		return;
-	}
-	llassert_always(mFormattedImage.notNull());
-	
-	mDecodeHandle = 0;
-	if (success)
-	{
-		llassert_always(raw);
-		mRawImage = raw;
-		mAuxImage = aux;
-		mDecodedDiscard = mFormattedImage->getDiscardLevel();
- 		LL_DEBUGS("Texture") << mID << ": Decode Finished. Discard: " << mDecodedDiscard
-							 << " Raw Image: " << llformat("%dx%d",mRawImage->getWidth(),mRawImage->getHeight()) << LL_ENDL;
-	}
-	else
-	{
-		llwarns << "DECODE FAILED: " << mID << " Discard: " << (S32)mFormattedImage->getDiscardLevel() << llendl;
-		removeFromCache();
-		mDecodedDiscard = -1; // Redundant, here for clarity and paranoia
-	}
-	mDecoded = TRUE;
-// 	llinfos << mID << " : DECODE COMPLETE " << llendl;
-	setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-bool LLTextureFetchWorker::writeToCacheComplete()
-{
-	// Complete write to cache
-	if (mCacheWriteHandle != LLTextureCache::nullHandle())
-	{
-		if (!mWritten)
-		{
-			return false;
-		}
-		if (mFetcher->mTextureCache->writeComplete(mCacheWriteHandle))
-		{
-			mCacheWriteHandle = LLTextureCache::nullHandle();
-		}
-		else
-		{
-			return false;
-		}
-	}
-	return true;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-// public
-
-LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* imagedecodethread, bool threaded, bool qa_mode)
-	: LLWorkerThread("TextureFetch", threaded),
-	  mDebugCount(0),
-	  mDebugPause(FALSE),
-	  mPacketCount(0),
-	  mBadPacketCount(0),
-	  mQueueMutex(getAPRPool()),
-	  mNetworkQueueMutex(getAPRPool()),
-	  mTextureCache(cache),
-	  mImageDecodeThread(imagedecodethread),
-	  mTextureBandwidth(0),
-	  mHTTPTextureBits(0),
-	  mCurlGetRequest(NULL),
-	  mQAMode(qa_mode)
-{
-	mCurlPOSTRequestCount = 0;
-	mMaxBandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS");
-	mTextureInfo.setUpLogging(gSavedSettings.getBOOL("LogTextureDownloadsToViewerLog"), gSavedSettings.getBOOL("LogTextureDownloadsToSimulator"), gSavedSettings.getU32("TextureLoggingThreshold"));
-}
-
-LLTextureFetch::~LLTextureFetch()
-{
-	clearDeleteList() ;
-
-	while (! mCommands.empty())
-	{
-		TFRequest * req(mCommands.front());
-		mCommands.erase(mCommands.begin());
-		delete req;
-	}
-	
-	// ~LLQueuedThread() called here
-}
-
-bool LLTextureFetch::createRequest(const std::string& url, const LLUUID& id, const LLHost& host, F32 priority,
-								   S32 w, S32 h, S32 c, S32 desired_discard, bool needs_aux, bool can_use_http)
-{
-	if (mDebugPause)
-	{
-		return false;
-	}
-	
-	LLTextureFetchWorker* worker = getWorker(id) ;
-	if (worker)
-	{
-		if (worker->mHost != host)
-		{
-			llwarns << "LLTextureFetch::createRequest " << id << " called with multiple hosts: "
-					<< host << " != " << worker->mHost << llendl;
-			removeRequest(worker, true);
-			worker = NULL;
-			return false;
-		}
-	}
-
-	S32 desired_size;
-	std::string exten = gDirUtilp->getExtension(url);
-	if (!url.empty() && (!exten.empty() && LLImageBase::getCodecFromExtension(exten) != IMG_CODEC_J2C))
-	{
-		// Only do partial requests for J2C at the moment
-		desired_size = MAX_IMAGE_DATA_SIZE;
-		desired_discard = 0;
-	}
-	else if (desired_discard == 0)
-	{
-		// if we want the entire image, and we know its size, then get it all
-		// (calcDataSizeJ2C() below makes assumptions about how the image
-		// was compressed - this code ensures that when we request the entire image,
-		// we really do get it.)
-		desired_size = MAX_IMAGE_DATA_SIZE;
-	}
-	else if (w*h*c > 0)
-	{
-		// If the requester knows the dimensions of the image,
-		// this will calculate how much data we need without having to parse the header
-
-		desired_size = LLImageJ2C::calcDataSizeJ2C(w, h, c, desired_discard);
-	}
-	else
-	{
-		desired_size = TEXTURE_CACHE_ENTRY_SIZE;
-		desired_discard = MAX_DISCARD_LEVEL;
-	}
-
-	
-	if (worker)
-	{
-		if (worker->wasAborted())
-		{
-			return false; // need to wait for previous aborted request to complete
-		}
-		worker->lockWorkMutex();
-		worker->mActiveCount++;
-		worker->mNeedsAux = needs_aux;
-		worker->setImagePriority(priority);
-		worker->setDesiredDiscard(desired_discard, desired_size);
-		worker->setCanUseHTTP(can_use_http) ;
-		if (!worker->haveWork())
-		{
-			worker->mState = LLTextureFetchWorker::INIT;
-			worker->unlockWorkMutex();
-
-			worker->addWork(0, LLWorkerThread::PRIORITY_HIGH | worker->mWorkPriority);
-		}
-		else
-		{
-			worker->unlockWorkMutex();
-		}
-	}
-	else
-	{
-		worker = new LLTextureFetchWorker(this, url, id, host, priority, desired_discard, desired_size);
-		lockQueue() ;
-		mRequestMap[id] = worker;
-		unlockQueue() ;
-
-		worker->lockWorkMutex();
-		worker->mActiveCount++;
-		worker->mNeedsAux = needs_aux;
-		worker->setCanUseHTTP(can_use_http) ;
-		worker->unlockWorkMutex();
-	}
-	
-// 	llinfos << "REQUESTED: " << id << " Discard: " << desired_discard << llendl;
-	return true;
-}
-
-// protected
-void LLTextureFetch::addToNetworkQueue(LLTextureFetchWorker* worker)
-{
-	lockQueue() ;
-	bool in_request_map = (mRequestMap.find(worker->mID) != mRequestMap.end()) ;
-	unlockQueue() ;
-
-	LLMutexLock lock(&mNetworkQueueMutex);
-	if (in_request_map)
-	{
-		// only add to the queue if in the request map
-		// i.e. a delete has not been requested
-		mNetworkQueue.insert(worker->mID);
-	}
-	for (cancel_queue_t::iterator iter1 = mCancelQueue.begin();
-		 iter1 != mCancelQueue.end(); ++iter1)
-	{
-		iter1->second.erase(worker->mID);
-	}
-}
-
-void LLTextureFetch::removeFromNetworkQueue(LLTextureFetchWorker* worker, bool cancel)
-{
-	LLMutexLock lock(&mNetworkQueueMutex);
-	size_t erased = mNetworkQueue.erase(worker->mID);
-	if (cancel && erased > 0)
-	{
-		mCancelQueue[worker->mHost].insert(worker->mID);
-	}
-}
-
-// protected
-void LLTextureFetch::addToHTTPQueue(const LLUUID& id)
-{
-	LLMutexLock lock(&mNetworkQueueMutex);
-	mHTTPTextureQueue.insert(id);
-}
-
-void LLTextureFetch::removeFromHTTPQueue(const LLUUID& id, S32 received_size)
-{
-	LLMutexLock lock(&mNetworkQueueMutex);
-	mHTTPTextureQueue.erase(id);
-	mHTTPTextureBits += received_size * 8; // Approximate - does not include header bits	
-}
-
-void LLTextureFetch::deleteRequest(const LLUUID& id, bool cancel)
-{
-	lockQueue() ;
-	LLTextureFetchWorker* worker = getWorkerAfterLock(id);
-	if (worker)
-	{		
-		size_t erased_1 = mRequestMap.erase(worker->mID);
-		unlockQueue() ;
-
-		llassert_always(erased_1 > 0) ;
-
-		removeFromNetworkQueue(worker, cancel);
-		llassert_always(!(worker->getFlags(LLWorkerClass::WCF_DELETE_REQUESTED))) ;
-
-		worker->scheduleDelete();	
-	}
-	else
-	{
-		unlockQueue() ;
-	}
-}
-
-void LLTextureFetch::removeRequest(LLTextureFetchWorker* worker, bool cancel)
-{
-	lockQueue() ;
-	size_t erased_1 = mRequestMap.erase(worker->mID);
-	unlockQueue() ;
-
-	llassert_always(erased_1 > 0) ;
-	removeFromNetworkQueue(worker, cancel);
-	llassert_always(!(worker->getFlags(LLWorkerClass::WCF_DELETE_REQUESTED))) ;
-
-	worker->scheduleDelete();	
-}
-
-S32 LLTextureFetch::getNumRequests() 
-{ 
-	lockQueue() ;
-	S32 size = (S32)mRequestMap.size(); 
-	unlockQueue() ;
-
-	return size ;
-}
-
-S32 LLTextureFetch::getNumHTTPRequests() 
-{ 
-	mNetworkQueueMutex.lock() ;
-	S32 size = (S32)mHTTPTextureQueue.size(); 
-	mNetworkQueueMutex.unlock() ;
-
-	return size ;
-}
-
-// call lockQueue() first!
-LLTextureFetchWorker* LLTextureFetch::getWorkerAfterLock(const LLUUID& id)
-{
-	LLTextureFetchWorker* res = NULL;
-	map_t::iterator iter = mRequestMap.find(id);
-	if (iter != mRequestMap.end())
-	{
-		res = iter->second;
-	}
-	return res;
-}
-
-LLTextureFetchWorker* LLTextureFetch::getWorker(const LLUUID& id)
-{
-	LLMutexLock lock(&mQueueMutex) ;
-
-	return getWorkerAfterLock(id) ;
-}
-
-
-bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level,
-										LLPointer<LLImageRaw>& raw, LLPointer<LLImageRaw>& aux)
-{
-	bool res = false;
-	LLTextureFetchWorker* worker = getWorker(id);
-	if (worker)
-	{
-		if (worker->wasAborted())
-		{
-			res = true;
-		}
-		else if (!worker->haveWork())
-		{
-			// Should only happen if we set mDebugPause...
-			if (!mDebugPause)
-			{
-// 				llwarns << "Adding work for inactive worker: " << id << llendl;
-				worker->addWork(0, LLWorkerThread::PRIORITY_HIGH | worker->mWorkPriority);
-			}
-		}
-		else if (worker->checkWork())
-		{
-			worker->lockWorkMutex();
-			discard_level = worker->mDecodedDiscard;
-			raw = worker->mRawImage;
-			aux = worker->mAuxImage;
-			res = true;
-			LL_DEBUGS("Texture") << id << ": Request Finished. State: " << worker->mState << " Discard: " << discard_level << LL_ENDL;
-			worker->unlockWorkMutex();
-		}
-		else
-		{
-			worker->lockWorkMutex();
-			if ((worker->mDecodedDiscard >= 0) &&
-				(worker->mDecodedDiscard < discard_level || discard_level < 0) &&
-				(worker->mState >= LLTextureFetchWorker::WAIT_ON_WRITE))
-			{
-				// Not finished, but data is ready
-				discard_level = worker->mDecodedDiscard;
-				raw = worker->mRawImage;
-				aux = worker->mAuxImage;
-			}
-			worker->unlockWorkMutex();
-		}
-	}
-	else
-	{
-		res = true;
-	}
-	return res;
-}
-
-bool LLTextureFetch::updateRequestPriority(const LLUUID& id, F32 priority)
-{
-	bool res = false;
-	LLTextureFetchWorker* worker = getWorker(id);
-	if (worker)
-	{
-		worker->lockWorkMutex();
-		worker->setImagePriority(priority);
-		worker->unlockWorkMutex();
-		res = true;
-	}
-	return res;
-}
-
-// Replicates and expands upon the base class's
-// getPending() implementation.  getPending() and
-// runCondition() replicate one another's logic to
-// an extent and are sometimes used for the same
-// function (deciding whether or not to sleep/pause
-// a thread).  So the implementations need to stay
-// in step, at least until this can be refactored and
-// the redundancy eliminated.
-//
-// May be called from any thread
-
-//virtual
-S32 LLTextureFetch::getPending()
-{
-	S32 res;
-	lockData();
-    {
-        LLMutexLock lock(&mQueueMutex);
-        
-        res = mRequestQueue.size();
-        res += mCurlPOSTRequestCount;
-        res += mCommands.size();
-    }
-	unlockData();
-	return res;
-}
-
-// virtual
-bool LLTextureFetch::runCondition()
-{
-	// Caller is holding the lock on LLThread's condition variable.
-	
-	// LLQueuedThread, unlike its base class LLThread, makes this a
-	// private method which is unfortunate.  I want to use it directly
-	// but I'm going to have to re-implement the logic here (or change
-	// declarations, which I don't want to do right now).
-	//
-	// Changes here may need to be reflected in getPending().
-	
-	bool have_no_commands(false);
-	{
-		LLMutexLock lock(&mQueueMutex);
-		
-		have_no_commands = mCommands.empty();
-	}
-	
-    bool have_no_curl_requests(0 == mCurlPOSTRequestCount);
-	
-	return ! (have_no_commands
-			  && have_no_curl_requests
-			  && (mRequestQueue.empty() && mIdleThread));		// From base class
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-// MAIN THREAD (unthreaded envs), WORKER THREAD (threaded envs)
-void LLTextureFetch::commonUpdate()
-{
-	// Run a cross-thread command, if any.
-	cmdDoWork();
-	
-	// Update Curl on same thread as mCurlGetRequest was constructed
-	S32 processed = mCurlGetRequest->process();
-	if (processed > 0)
-	{
-		lldebugs << "processed: " << processed << " messages." << llendl;
-	}
-}
-
-
-// MAIN THREAD
-//virtual
-S32 LLTextureFetch::update(U32 max_time_ms)
-{
-	static LLCachedControl<F32> band_width(gSavedSettings,"ThrottleBandwidthKBPS");
-
-	{
-		mNetworkQueueMutex.lock() ;
-		mMaxBandwidth = band_width ;
-
-		gTextureList.sTextureBits += mHTTPTextureBits ;
-		mHTTPTextureBits = 0 ;
-
-		mNetworkQueueMutex.unlock() ;
-	}
-
-	S32 res = LLWorkerThread::update(max_time_ms);
-	
-	if (!mDebugPause)
-	{
-		sendRequestListToSimulators();
-	}
-
-	if (!mThreaded)
-	{
-		commonUpdate();
-	}
-
-	return res;
-}
-
-//called in the MAIN thread after the TextureCacheThread shuts down.
-void LLTextureFetch::shutDownTextureCacheThread() 
-{
-	if(mTextureCache)
-	{
-		llassert_always(mTextureCache->isQuitting() || mTextureCache->isStopped()) ;
-		mTextureCache = NULL ;
-	}
-}
-	
-//called in the MAIN thread after the ImageDecodeThread shuts down.
-void LLTextureFetch::shutDownImageDecodeThread() 
-{
-	if(mImageDecodeThread)
-	{
-		llassert_always(mImageDecodeThread->isQuitting() || mImageDecodeThread->isStopped()) ;
-		mImageDecodeThread = NULL ;
-	}
-}
-
-// WORKER THREAD
-void LLTextureFetch::startThread()
-{
-	// Construct mCurlGetRequest from Worker Thread
-	mCurlGetRequest = new LLCurlRequest();
-}
-
-// WORKER THREAD
-void LLTextureFetch::endThread()
-{
-	// Destroy mCurlGetRequest from Worker Thread
-	delete mCurlGetRequest;
-	mCurlGetRequest = NULL;
-}
-
-// WORKER THREAD
-void LLTextureFetch::threadedUpdate()
-{
-	llassert_always(mCurlGetRequest);
-	
-	// Limit update frequency
-	const F32 PROCESS_TIME = 0.05f; 
-	static LLFrameTimer process_timer;
-	if (process_timer.getElapsedTimeF32() < PROCESS_TIME)
-	{
-		return;
-	}
-	process_timer.reset();
-	
-	commonUpdate();
-
-#if 0
-	const F32 INFO_TIME = 1.0f; 
-	static LLFrameTimer info_timer;
-	if (info_timer.getElapsedTimeF32() >= INFO_TIME)
-	{
-		S32 q = mCurlGetRequest->getQueued();
-		if (q > 0)
-		{
-			llinfos << "Queued gets: " << q << llendl;
-			info_timer.reset();
-		}
-	}
-#endif
-	
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-void LLTextureFetch::sendRequestListToSimulators()
-{
-	// All requests
-	const F32 REQUEST_DELTA_TIME = 0.10f; // 10 fps
-	
-	// Sim requests
-	const S32 IMAGES_PER_REQUEST = 50;
-	const F32 SIM_LAZY_FLUSH_TIMEOUT = 10.0f; // temp
-	const F32 MIN_REQUEST_TIME = 1.0f;
-	const F32 MIN_DELTA_PRIORITY = 1000.f;
-
-	// Periodically, gather the list of textures that need data from the network
-	// And send the requests out to the simulators
-	static LLFrameTimer timer;
-	if (timer.getElapsedTimeF32() < REQUEST_DELTA_TIME)
-	{
-		return;
-	}
-	timer.reset();
-	
-	// Send requests
-	typedef std::set<LLTextureFetchWorker*,LLTextureFetchWorker::Compare> request_list_t;
-	typedef std::map< LLHost, request_list_t > work_request_map_t;
-	work_request_map_t requests;
-	{
-	LLMutexLock lock2(&mNetworkQueueMutex);
-	for (queue_t::iterator iter = mNetworkQueue.begin(); iter != mNetworkQueue.end(); )
-	{
-		queue_t::iterator curiter = iter++;
-		LLTextureFetchWorker* req = getWorker(*curiter);
-		if (!req)
-		{
-			mNetworkQueue.erase(curiter);
-			continue; // paranoia
-		}
-		if ((req->mState != LLTextureFetchWorker::LOAD_FROM_NETWORK) &&
-			(req->mState != LLTextureFetchWorker::LOAD_FROM_SIMULATOR))
-		{
-			// We already received our URL, remove from the queue
-			llwarns << "Worker: " << req->mID << " in mNetworkQueue but in wrong state: " << req->mState << llendl;
-			mNetworkQueue.erase(curiter);
-			continue;
-		}
-		if (req->mID == mDebugID)
-		{
-			mDebugCount++; // for setting breakpoints
-		}
-		if (req->mSentRequest == LLTextureFetchWorker::SENT_SIM &&
-			req->mTotalPackets > 0 &&
-			req->mLastPacket >= req->mTotalPackets-1)
-		{
-			// We have all the packets... make sure this is high priority
-// 			req->setPriority(LLWorkerThread::PRIORITY_HIGH | req->mWorkPriority);
-			continue;
-		}
-		F32 elapsed = req->mRequestedTimer.getElapsedTimeF32();
-		{
-			F32 delta_priority = llabs(req->mRequestedPriority - req->mImagePriority);
-			if ((req->mSimRequestedDiscard != req->mDesiredDiscard) ||
-				(delta_priority > MIN_DELTA_PRIORITY && elapsed >= MIN_REQUEST_TIME) ||
-				(elapsed >= SIM_LAZY_FLUSH_TIMEOUT))
-			{
-				requests[req->mHost].insert(req);
-			}
-		}
-	}
-	}
-
-	for (work_request_map_t::iterator iter1 = requests.begin();
-		 iter1 != requests.end(); ++iter1)
-	{
-		LLHost host = iter1->first;
-		// invalid host = use agent host
-		if (host == LLHost::invalid)
-		{
-			host = gAgent.getRegionHost();
-		}
-
-		S32 sim_request_count = 0;
-		
-		for (request_list_t::iterator iter2 = iter1->second.begin();
-			 iter2 != iter1->second.end(); ++iter2)
-		{
-			LLTextureFetchWorker* req = *iter2;
-			if (gMessageSystem)
-			{
-				if (req->mSentRequest != LLTextureFetchWorker::SENT_SIM)
-				{
-					// Initialize packet data based on data read from cache
-					req->lockWorkMutex();
-					req->setupPacketData();
-					req->unlockWorkMutex();
-				}
-				if (0 == sim_request_count)
-				{
-					gMessageSystem->newMessageFast(_PREHASH_RequestImage);
-					gMessageSystem->nextBlockFast(_PREHASH_AgentData);
-					gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-					gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-				}
-				S32 packet = req->mLastPacket + 1;
-				gMessageSystem->nextBlockFast(_PREHASH_RequestImage);
-				gMessageSystem->addUUIDFast(_PREHASH_Image, req->mID);
-				gMessageSystem->addS8Fast(_PREHASH_DiscardLevel, (S8)req->mDesiredDiscard);
-				gMessageSystem->addF32Fast(_PREHASH_DownloadPriority, req->mImagePriority);
-				gMessageSystem->addU32Fast(_PREHASH_Packet, packet);
-				gMessageSystem->addU8Fast(_PREHASH_Type, req->mType);
-// 				llinfos << "IMAGE REQUEST: " << req->mID << " Discard: " << req->mDesiredDiscard
-// 						<< " Packet: " << packet << " Priority: " << req->mImagePriority << llendl;
-
-				static LLCachedControl<bool> log_to_viewer_log(gSavedSettings,"LogTextureDownloadsToViewerLog");
-				static LLCachedControl<bool> log_to_sim(gSavedSettings,"LogTextureDownloadsToSimulator");
-				if (log_to_viewer_log || log_to_sim)
-				{
-					mTextureInfo.setRequestStartTime(req->mID, LLTimer::getTotalTime());
-					mTextureInfo.setRequestOffset(req->mID, 0);
-					mTextureInfo.setRequestSize(req->mID, 0);
-					mTextureInfo.setRequestType(req->mID, LLTextureInfoDetails::REQUEST_TYPE_UDP);
-				}
-
-				req->lockWorkMutex();
-				req->mSentRequest = LLTextureFetchWorker::SENT_SIM;
-				req->mSimRequestedDiscard = req->mDesiredDiscard;
-				req->mRequestedPriority = req->mImagePriority;
-				req->mRequestedTimer.reset();
-				req->unlockWorkMutex();
-				sim_request_count++;
-				if (sim_request_count >= IMAGES_PER_REQUEST)
-				{
-// 					llinfos << "REQUESTING " << sim_request_count << " IMAGES FROM HOST: " << host.getIPString() << llendl;
-
-					gMessageSystem->sendSemiReliable(host, NULL, NULL);
-					sim_request_count = 0;
-				}
-			}
-		}
-		if (gMessageSystem && sim_request_count > 0 && sim_request_count < IMAGES_PER_REQUEST)
-		{
-// 			llinfos << "REQUESTING " << sim_request_count << " IMAGES FROM HOST: " << host.getIPString() << llendl;
-			gMessageSystem->sendSemiReliable(host, NULL, NULL);
-			sim_request_count = 0;
-		}
-	}
-	
-	// Send cancelations
-	{
-	LLMutexLock lock2(&mNetworkQueueMutex);
-	if (gMessageSystem && !mCancelQueue.empty())
-	{
-		for (cancel_queue_t::iterator iter1 = mCancelQueue.begin();
-			 iter1 != mCancelQueue.end(); ++iter1)
-		{
-			LLHost host = iter1->first;
-			if (host == LLHost::invalid)
-			{
-				host = gAgent.getRegionHost();
-			}
-			S32 request_count = 0;
-			for (queue_t::iterator iter2 = iter1->second.begin();
-				 iter2 != iter1->second.end(); ++iter2)
-			{
-				if (0 == request_count)
-				{
-					gMessageSystem->newMessageFast(_PREHASH_RequestImage);
-					gMessageSystem->nextBlockFast(_PREHASH_AgentData);
-					gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-					gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-				}
-				gMessageSystem->nextBlockFast(_PREHASH_RequestImage);
-				gMessageSystem->addUUIDFast(_PREHASH_Image, *iter2);
-				gMessageSystem->addS8Fast(_PREHASH_DiscardLevel, -1);
-				gMessageSystem->addF32Fast(_PREHASH_DownloadPriority, 0);
-				gMessageSystem->addU32Fast(_PREHASH_Packet, 0);
-				gMessageSystem->addU8Fast(_PREHASH_Type, 0);
-// 				llinfos << "CANCELING IMAGE REQUEST: " << (*iter2) << llendl;
-
-				request_count++;
-				if (request_count >= IMAGES_PER_REQUEST)
-				{
-					gMessageSystem->sendSemiReliable(host, NULL, NULL);
-					request_count = 0;
-				}
-			}
-			if (request_count > 0 && request_count < IMAGES_PER_REQUEST)
-			{
-				gMessageSystem->sendSemiReliable(host, NULL, NULL);
-			}
-		}
-		mCancelQueue.clear();
-	}
-	}
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-bool LLTextureFetchWorker::insertPacket(S32 index, U8* data, S32 size)
-{
-	mRequestedTimer.reset();
-	if (index >= mTotalPackets)
-	{
-// 		llwarns << "Received Image Packet " << index << " > max: " << mTotalPackets << " for image: " << mID << llendl;
-		return false;
-	}
-	if (index > 0 && index < mTotalPackets-1 && size != MAX_IMG_PACKET_SIZE)
-	{
-// 		llwarns << "Received bad sized packet: " << index << ", " << size << " != " << MAX_IMG_PACKET_SIZE << " for image: " << mID << llendl;
-		return false;
-	}
-	
-	if (index >= (S32)mPackets.size())
-	{
-		mPackets.resize(index+1, (PacketData*)NULL); // initializes v to NULL pointers
-	}
-	else if (mPackets[index] != NULL)
-	{
-// 		llwarns << "Received duplicate packet: " << index << " for image: " << mID << llendl;
-		return false;
-	}
-
-	mPackets[index] = new PacketData(data, size);
-	while (mLastPacket+1 < (S32)mPackets.size() && mPackets[mLastPacket+1] != NULL)
-	{
-		++mLastPacket;
-	}
-	return true;
-}
-
-bool LLTextureFetch::receiveImageHeader(const LLHost& host, const LLUUID& id, U8 codec, U16 packets, U32 totalbytes,
-										U16 data_size, U8* data)
-{
-	LLTextureFetchWorker* worker = getWorker(id);
-	bool res = true;
-
-	++mPacketCount;
-	
-	if (!worker)
-	{
-// 		llwarns << "Received header for non active worker: " << id << llendl;
-		res = false;
-	}
-	else if (worker->mState != LLTextureFetchWorker::LOAD_FROM_NETWORK ||
-			 worker->mSentRequest != LLTextureFetchWorker::SENT_SIM)
-	{
-// 		llwarns << "receiveImageHeader for worker: " << id
-// 				<< " in state: " << LLTextureFetchWorker::sStateDescs[worker->mState]
-// 				<< " sent: " << worker->mSentRequest << llendl;
-		res = false;
-	}
-	else if (worker->mLastPacket != -1)
-	{
-		// check to see if we've gotten this packet before
-// 		llwarns << "Received duplicate header for: " << id << llendl;
-		res = false;
-	}
-	else if (!data_size)
-	{
-// 		llwarns << "Img: " << id << ":" << " Empty Image Header" << llendl;
-		res = false;
-	}
-	if (!res)
-	{
-		++mBadPacketCount;
-		mNetworkQueueMutex.lock() ;
-		mCancelQueue[host].insert(id);
-		mNetworkQueueMutex.unlock() ;
-		return false;
-	}
-
-	worker->lockWorkMutex();
-
-	//	Copy header data into image object
-	worker->mImageCodec = codec;
-	worker->mTotalPackets = packets;
-	worker->mFileSize = (S32)totalbytes;	
-	llassert_always(totalbytes > 0);
-	llassert_always(data_size == FIRST_PACKET_SIZE || data_size == worker->mFileSize);
-	res = worker->insertPacket(0, data, data_size);
-	worker->setPriority(LLWorkerThread::PRIORITY_HIGH | worker->mWorkPriority);
-	worker->mState = LLTextureFetchWorker::LOAD_FROM_SIMULATOR;
-	worker->unlockWorkMutex();
-	return res;
-}
-
-bool LLTextureFetch::receiveImagePacket(const LLHost& host, const LLUUID& id, U16 packet_num, U16 data_size, U8* data)
-{
-	LLTextureFetchWorker* worker = getWorker(id);
-	bool res = true;
-
-	++mPacketCount;
-	
-	if (!worker)
-	{
-// 		llwarns << "Received packet " << packet_num << " for non active worker: " << id << llendl;
-		res = false;
-	}
-	else if (worker->mLastPacket == -1)
-	{
-// 		llwarns << "Received packet " << packet_num << " before header for: " << id << llendl;
-		res = false;
-	}
-	else if (!data_size)
-	{
-// 		llwarns << "Img: " << id << ":" << " Empty Image Header" << llendl;
-		res = false;
-	}
-	if (!res)
-	{
-		++mBadPacketCount;
-		mNetworkQueueMutex.lock() ;
-		mCancelQueue[host].insert(id);
-		mNetworkQueueMutex.unlock() ;
-		return false;
-	}
-
-	worker->lockWorkMutex();
-	
-	res = worker->insertPacket(packet_num, data, data_size);
-	
-	if ((worker->mState == LLTextureFetchWorker::LOAD_FROM_SIMULATOR) ||
-		(worker->mState == LLTextureFetchWorker::LOAD_FROM_NETWORK))
-	{
-		worker->setPriority(LLWorkerThread::PRIORITY_HIGH | worker->mWorkPriority);
-		worker->mState = LLTextureFetchWorker::LOAD_FROM_SIMULATOR;
-	}
-	else
-	{
-// 		llwarns << "receiveImagePacket " << packet_num << "/" << worker->mLastPacket << " for worker: " << id
-// 				<< " in state: " << LLTextureFetchWorker::sStateDescs[worker->mState] << llendl;
-		removeFromNetworkQueue(worker, true); // failsafe
-	}
-
-	if(packet_num >= (worker->mTotalPackets - 1))
-	{
-		static LLCachedControl<bool> log_to_viewer_log(gSavedSettings,"LogTextureDownloadsToViewerLog");
-		static LLCachedControl<bool> log_to_sim(gSavedSettings,"LogTextureDownloadsToSimulator");
-
-		if (log_to_viewer_log || log_to_sim)
-		{
-			U64 timeNow = LLTimer::getTotalTime();
-			mTextureInfo.setRequestSize(id, worker->mFileSize);
-			mTextureInfo.setRequestCompleteTimeAndLog(id, timeNow);
-		}
-	}
-	worker->unlockWorkMutex();
-
-	return res;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-BOOL LLTextureFetch::isFromLocalCache(const LLUUID& id)
-{
-	BOOL from_cache = FALSE ;
-
-	LLTextureFetchWorker* worker = getWorker(id);
-	if (worker)
-	{
-		worker->lockWorkMutex() ;
-		from_cache = worker->mInLocalCache ;
-		worker->unlockWorkMutex() ;
-	}
-
-	return from_cache ;
-}
-
-S32 LLTextureFetch::getFetchState(const LLUUID& id, F32& data_progress_p, F32& requested_priority_p,
-								  U32& fetch_priority_p, F32& fetch_dtime_p, F32& request_dtime_p, bool& can_use_http)
-{
-	S32 state = LLTextureFetchWorker::INVALID;
-	F32 data_progress = 0.0f;
-	F32 requested_priority = 0.0f;
-	F32 fetch_dtime = 999999.f;
-	F32 request_dtime = 999999.f;
-	U32 fetch_priority = 0;
-	
-	LLTextureFetchWorker* worker = getWorker(id);
-	if (worker && worker->haveWork())
-	{
-		worker->lockWorkMutex();
-		state = worker->mState;
-		fetch_dtime = worker->mFetchTimer.getElapsedTimeF32();
-		request_dtime = worker->mRequestedTimer.getElapsedTimeF32();
-		if (worker->mFileSize > 0)
-		{
-			if (state == LLTextureFetchWorker::LOAD_FROM_SIMULATOR)
-			{
-				S32 data_size = FIRST_PACKET_SIZE + (worker->mLastPacket-1) * MAX_IMG_PACKET_SIZE;
-				data_size = llmax(data_size, 0);
-				data_progress = (F32)data_size / (F32)worker->mFileSize;
-			}
-			else if (worker->mFormattedImage.notNull())
-			{
-				data_progress = (F32)worker->mFormattedImage->getDataSize() / (F32)worker->mFileSize;
-			}
-		}
-		if (state >= LLTextureFetchWorker::LOAD_FROM_NETWORK && state <= LLTextureFetchWorker::WAIT_HTTP_REQ)
-		{
-			requested_priority = worker->mRequestedPriority;
-		}
-		else
-		{
-			requested_priority = worker->mImagePriority;
-		}
-		fetch_priority = worker->getPriority();
-		can_use_http = worker->getCanUseHTTP() ;
-		worker->unlockWorkMutex();
-	}
-	data_progress_p = data_progress;
-	requested_priority_p = requested_priority;
-	fetch_priority_p = fetch_priority;
-	fetch_dtime_p = fetch_dtime;
-	request_dtime_p = request_dtime;
-	return state;
-}
-
-void LLTextureFetch::dump()
-{
-	llinfos << "LLTextureFetch REQUESTS:" << llendl;
-	for (request_queue_t::iterator iter = mRequestQueue.begin();
-		 iter != mRequestQueue.end(); ++iter)
-	{
-		LLQueuedThread::QueuedRequest* qreq = *iter;
-		LLWorkerThread::WorkRequest* wreq = (LLWorkerThread::WorkRequest*)qreq;
-		LLTextureFetchWorker* worker = (LLTextureFetchWorker*)wreq->getWorkerClass();
-		llinfos << " ID: " << worker->mID
-				<< " PRI: " << llformat("0x%08x",wreq->getPriority())
-				<< " STATE: " << worker->sStateDescs[worker->mState]
-				<< llendl;
-	}
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-// cross-thread command methods
-
-void LLTextureFetch::commandSetRegion(U64 region_handle)
-{
-	TFReqSetRegion * req = new TFReqSetRegion(region_handle);
-
-	cmdEnqueue(req);
-}
-
-void LLTextureFetch::commandSendMetrics(const std::string & caps_url,
-										const LLUUID & session_id,
-										const LLUUID & agent_id,
-										LLViewerAssetStats * main_stats)
-{
-	TFReqSendMetrics * req = new TFReqSendMetrics(caps_url, session_id, agent_id, main_stats);
-
-	cmdEnqueue(req);
-}
-
-void LLTextureFetch::commandDataBreak()
-{
-	// The pedantically correct way to implement this is to create a command
-	// request object in the above fashion and enqueue it.  However, this is
-	// simple data of an advisorial not operational nature and this case
-	// of shared-write access is tolerable.
-
-	LLTextureFetch::svMetricsDataBreak = true;
-}
-
-void LLTextureFetch::cmdEnqueue(TFRequest * req)
-{
-	lockQueue();
-	mCommands.push_back(req);
-	unlockQueue();
-
-	unpause();
-}
-
-LLTextureFetch::TFRequest * LLTextureFetch::cmdDequeue()
-{
-	TFRequest * ret = 0;
-	
-	lockQueue();
-	if (! mCommands.empty())
-	{
-		ret = mCommands.front();
-		mCommands.erase(mCommands.begin());
-	}
-	unlockQueue();
-
-	return ret;
-}
-
-void LLTextureFetch::cmdDoWork()
-{
-	if (mDebugPause)
-	{
-		return;  // debug: don't do any work
-	}
-
-	TFRequest * req = cmdDequeue();
-	if (req)
-	{
-		// One request per pass should really be enough for this.
-		req->doWork(this);
-		delete req;
-	}
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-
-// Private (anonymous) class methods implementing the command scheme.
-
-namespace
-{
-
-/**
- * Implements the 'Set Region' command.
- *
- * Thread:  Thread1 (TextureFetch)
- */
-bool
-TFReqSetRegion::doWork(LLTextureFetch *)
-{
-	LLViewerAssetStatsFF::set_region_thread1(mRegionHandle);
-
-	return true;
-}
-
-
-TFReqSendMetrics::~TFReqSendMetrics()
-{
-	delete mMainStats;
-	mMainStats = 0;
-}
-
-
-/**
- * Implements the 'Send Metrics' command.  Takes over
- * ownership of the passed LLViewerAssetStats pointer.
- *
- * Thread:  Thread1 (TextureFetch)
- */
-bool
-TFReqSendMetrics::doWork(LLTextureFetch * fetcher)
-{
-	/*
-	 * HTTP POST responder.  Doesn't do much but tries to
-	 * detect simple breaks in recording the metrics stream.
-	 *
-	 * The 'volatile' modifiers don't indicate signals,
-	 * mmap'd memory or threads, really.  They indicate that
-	 * the referenced data is part of a pseudo-closure for
-	 * this responder rather than being required for correct
-	 * operation.
-     *
-     * We don't try very hard with the POST request.  We give
-     * it one shot and that's more-or-less it.  With a proper
-     * refactoring of the LLQueuedThread usage, these POSTs
-     * could be put in a request object and made more reliable.
-	 */
-	class lcl_responder : public LLCurl::Responder
-	{
-	public:
-		lcl_responder(LLTextureFetch * fetcher,
-					  S32 expected_sequence,
-                      volatile const S32 & live_sequence,
-                      volatile bool & reporting_break,
-					  volatile bool & reporting_started)
-			: LLCurl::Responder(),
-			  mFetcher(fetcher),
-              mExpectedSequence(expected_sequence),
-              mLiveSequence(live_sequence),
-			  mReportingBreak(reporting_break),
-			  mReportingStarted(reporting_started)
-			{
-                mFetcher->incrCurlPOSTCount();
-            }
-        
-        ~lcl_responder()
-            {
-                mFetcher->decrCurlPOSTCount();
-            }
-
-		// virtual
-		void error(U32 status_num, const std::string & reason)
-			{
-                if (mLiveSequence == mExpectedSequence)
-                {
-                    mReportingBreak = true;
-                }
-				LL_WARNS("Texture") << "Break in metrics stream due to POST failure to metrics collection service.  Reason:  "
-									<< reason << LL_ENDL;
-			}
-
-		// virtual
-		void result(const LLSD & content)
-			{
-                if (mLiveSequence == mExpectedSequence)
-                {
-                    mReportingBreak = false;
-                    mReportingStarted = true;
-                }
-			}
-
-	private:
-		LLTextureFetch * mFetcher;
-        S32 mExpectedSequence;
-        volatile const S32 & mLiveSequence;
-		volatile bool & mReportingBreak;
-		volatile bool & mReportingStarted;
-
-	}; // class lcl_responder
-	
-	if (! gViewerAssetStatsThread1)
-		return true;
-
-	static volatile bool reporting_started(false);
-	static volatile S32 report_sequence(0);
-    
-	// We've taken over ownership of the stats copy at this
-	// point.  Get a working reference to it for merging here
-	// but leave it in 'this'.  Destructor will rid us of it.
-	LLViewerAssetStats & main_stats = *mMainStats;
-
-	// Merge existing stats into those from main, convert to LLSD
-	main_stats.merge(*gViewerAssetStatsThread1);
-	LLSD merged_llsd = main_stats.asLLSD(true);
-
-	// Add some additional meta fields to the content
-	merged_llsd["session_id"] = mSessionID;
-	merged_llsd["agent_id"] = mAgentID;
-	merged_llsd["message"] = "ViewerAssetMetrics";					// Identifies the type of metrics
-	merged_llsd["sequence"] = report_sequence;						// Sequence number
-	merged_llsd["initial"] = ! reporting_started;					// Initial data from viewer
-	merged_llsd["break"] = LLTextureFetch::svMetricsDataBreak;		// Break in data prior to this report
-		
-	// Update sequence number
-	if (S32_MAX == ++report_sequence)
-		report_sequence = 0;
-
-	// Limit the size of the stats report if necessary.
-	merged_llsd["truncated"] = truncate_viewer_metrics(10, merged_llsd);
-
-	if (! mCapsURL.empty())
-	{
-		LLCurlRequest::headers_t headers;
-		fetcher->getCurlRequest().post(mCapsURL,
-									   headers,
-									   merged_llsd,
-									   new lcl_responder(fetcher,
-														 report_sequence,
-                                                         report_sequence,
-                                                         LLTextureFetch::svMetricsDataBreak,
-														 reporting_started));
-	}
-	else
-	{
-		LLTextureFetch::svMetricsDataBreak = true;
-	}
-
-	// In QA mode, Metrics submode, log the result for ease of testing
-	if (fetcher->isQAMode())
-	{
-		LL_INFOS("Textures") << merged_llsd << LL_ENDL;
-	}
-
-	gViewerAssetStatsThread1->reset();
-
-	return true;
-}
-
-
-bool
-truncate_viewer_metrics(int max_regions, LLSD & metrics)
-{
-	static const LLSD::String reg_tag("regions");
-	static const LLSD::String duration_tag("duration");
-	
-	LLSD & reg_map(metrics[reg_tag]);
-	if (reg_map.size() <= max_regions)
-	{
-		return false;
-	}
-
-	// Build map of region hashes ordered by duration
-	typedef std::multimap<LLSD::Real, int> reg_ordered_list_t;
-	reg_ordered_list_t regions_by_duration;
-
-	int ind(0);
-	LLSD::array_const_iterator it_end(reg_map.endArray());
-	for (LLSD::array_const_iterator it(reg_map.beginArray()); it_end != it; ++it, ++ind)
-	{
-		LLSD::Real duration = (*it)[duration_tag].asReal();
-		regions_by_duration.insert(reg_ordered_list_t::value_type(duration, ind));
-	}
-
-	// Build a replacement regions array with the longest-persistence regions
-	LLSD new_region(LLSD::emptyArray());
-	reg_ordered_list_t::const_reverse_iterator it2_end(regions_by_duration.rend());
-	reg_ordered_list_t::const_reverse_iterator it2(regions_by_duration.rbegin());
-	for (int i(0); i < max_regions && it2_end != it2; ++i, ++it2)
-	{
-		new_region.append(reg_map[it2->second]);
-	}
-	reg_map = new_region;
-	
-	return true;
-}
-
-} // end of anonymous namespace
-
-
-
+/** 
+ * @file lltexturefetch.cpp
+ * @brief Object which fetches textures from the cache and/or network
+ *
+ * $LicenseInfo:firstyear=2000&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, Linden Research, Inc.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * 
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+
+#include <iostream>
+#include <map>
+
+#include "llstl.h"
+
+#include "lltexturefetch.h"
+
+#include "llcurl.h"
+#include "lldir.h"
+#include "llhttpclient.h"
+#include "llhttpstatuscodes.h"
+#include "llimage.h"
+#include "llimagej2c.h"
+#include "llimageworker.h"
+#include "llworkerthread.h"
+#include "message.h"
+
+#include "llagent.h"
+#include "lltexturecache.h"
+#include "llviewercontrol.h"
+#include "llviewertexturelist.h"
+#include "llviewertexture.h"
+#include "llviewerregion.h"
+#include "llviewerstats.h"
+#include "llviewerassetstats.h"
+#include "llworld.h"
+
+//////////////////////////////////////////////////////////////////////////////
+class LLTextureFetchWorker : public LLWorkerClass
+{
+	friend class LLTextureFetch;
+	friend class HTTPGetResponder;
+	
+private:
+	class CacheReadResponder : public LLTextureCache::ReadResponder
+	{
+	public:
+		CacheReadResponder(LLTextureFetch* fetcher, const LLUUID& id, LLImageFormatted* image)
+			: mFetcher(fetcher), mID(id)
+		{
+			setImage(image);
+		}
+		virtual void completed(bool success)
+		{
+			LLTextureFetchWorker* worker = mFetcher->getWorker(mID);
+			if (worker)
+			{
+ 				worker->callbackCacheRead(success, mFormattedImage, mImageSize, mImageLocal);
+			}
+		}
+	private:
+		LLTextureFetch* mFetcher;
+		LLUUID mID;
+	};
+
+	class CacheWriteResponder : public LLTextureCache::WriteResponder
+	{
+	public:
+		CacheWriteResponder(LLTextureFetch* fetcher, const LLUUID& id)
+			: mFetcher(fetcher), mID(id)
+		{
+		}
+		virtual void completed(bool success)
+		{
+			LLTextureFetchWorker* worker = mFetcher->getWorker(mID);
+			if (worker)
+			{
+				worker->callbackCacheWrite(success);
+			}
+		}
+	private:
+		LLTextureFetch* mFetcher;
+		LLUUID mID;
+	};
+	
+	class DecodeResponder : public LLImageDecodeThread::Responder
+	{
+	public:
+		DecodeResponder(LLTextureFetch* fetcher, const LLUUID& id, LLTextureFetchWorker* worker)
+			: mFetcher(fetcher), mID(id), mWorker(worker)
+		{
+		}
+		virtual void completed(bool success, LLImageRaw* raw, LLImageRaw* aux)
+		{
+			LLTextureFetchWorker* worker = mFetcher->getWorker(mID);
+			if (worker)
+			{
+ 				worker->callbackDecoded(success, raw, aux);
+			}
+		}
+	private:
+		LLTextureFetch* mFetcher;
+		LLUUID mID;
+		LLTextureFetchWorker* mWorker; // debug only (may get deleted from under us, use mFetcher/mID)
+	};
+
+	struct Compare
+	{
+		// lhs < rhs
+		bool operator()(const LLTextureFetchWorker* lhs, const LLTextureFetchWorker* rhs) const
+		{
+			// greater priority is "less"
+			const F32 lpriority = lhs->mImagePriority;
+			const F32 rpriority = rhs->mImagePriority;
+			if (lpriority > rpriority) // higher priority
+				return true;
+			else if (lpriority < rpriority)
+				return false;
+			else
+				return lhs < rhs;
+		}
+	};
+	
+public:
+	/*virtual*/ bool doWork(S32 param); // Called from LLWorkerThread::processRequest()
+	/*virtual*/ void finishWork(S32 param, bool completed); // called from finishRequest() (WORK THREAD)
+	/*virtual*/ bool deleteOK(); // called from update() (WORK THREAD)
+
+	~LLTextureFetchWorker();
+	// void relese() { --mActiveCount; }
+
+	S32 callbackHttpGet(const LLChannelDescriptors& channels,
+						 const LLIOPipe::buffer_ptr_t& buffer,
+						 bool partial, bool success);
+	void callbackCacheRead(bool success, LLImageFormatted* image,
+						   S32 imagesize, BOOL islocal);
+	void callbackCacheWrite(bool success);
+	void callbackDecoded(bool success, LLImageRaw* raw, LLImageRaw* aux);
+	
+	void setGetStatus(U32 status, const std::string& reason)
+	{
+		LLMutexLock lock(&mWorkMutex);
+
+		mGetStatus = status;
+		mGetReason = reason;
+	}
+
+	void setCanUseHTTP(bool can_use_http) { mCanUseHTTP = can_use_http; }
+	bool getCanUseHTTP() const { return mCanUseHTTP; }
+
+	LLTextureFetch & getFetcher() { return *mFetcher; }
+	
+protected:
+	LLTextureFetchWorker(LLTextureFetch* fetcher, const std::string& url, const LLUUID& id, const LLHost& host,
+						 F32 priority, S32 discard, S32 size);
+
+private:
+	/*virtual*/ void startWork(S32 param); // called from addWork() (MAIN THREAD)
+	/*virtual*/ void endWork(S32 param, bool aborted); // called from doWork() (MAIN THREAD)
+
+	void resetFormattedData();
+	
+	void setImagePriority(F32 priority);
+	void setDesiredDiscard(S32 discard, S32 size);
+	bool insertPacket(S32 index, U8* data, S32 size);
+	void clearPackets();
+	void setupPacketData();
+	U32 calcWorkPriority();
+	void removeFromCache();
+	bool processSimulatorPackets();
+	bool writeToCacheComplete();
+	
+	void lockWorkMutex() { mWorkMutex.lock(); }
+	void unlockWorkMutex() { mWorkMutex.unlock(); }
+
+private:
+	enum e_state // mState
+	{
+		// NOTE: Affects LLTextureBar::draw in lltextureview.cpp (debug hack)
+		INVALID = 0,
+		INIT,
+		LOAD_FROM_TEXTURE_CACHE,
+		CACHE_POST,
+		LOAD_FROM_NETWORK,
+		LOAD_FROM_SIMULATOR,
+		SEND_HTTP_REQ,
+		WAIT_HTTP_REQ,
+		DECODE_IMAGE,
+		DECODE_IMAGE_UPDATE,
+		WRITE_TO_CACHE,
+		WAIT_ON_WRITE,
+		DONE
+	};
+	enum e_request_state // mSentRequest
+	{
+		UNSENT = 0,
+		QUEUED = 1,
+		SENT_SIM = 2
+	};
+	enum e_write_to_cache_state //mWriteToCacheState
+	{
+		NOT_WRITE = 0,
+		CAN_WRITE = 1,
+		SHOULD_WRITE = 2
+	};
+	static const char* sStateDescs[];
+	e_state mState;
+	e_write_to_cache_state mWriteToCacheState;
+	LLTextureFetch* mFetcher;
+	LLPointer<LLImageFormatted> mFormattedImage;
+	LLPointer<LLImageRaw> mRawImage;
+	LLPointer<LLImageRaw> mAuxImage;
+	LLUUID mID;
+	LLHost mHost;
+	std::string mUrl;
+	U8 mType;
+	F32 mImagePriority;
+	U32 mWorkPriority;
+	F32 mRequestedPriority;
+	S32 mDesiredDiscard;
+	S32 mSimRequestedDiscard;
+	S32 mRequestedDiscard;
+	S32 mLoadedDiscard;
+	S32 mDecodedDiscard;
+	LLFrameTimer mRequestedTimer;
+	LLFrameTimer mFetchTimer;
+	LLTextureCache::handle_t mCacheReadHandle;
+	LLTextureCache::handle_t mCacheWriteHandle;
+	U8* mBuffer;
+	S32 mBufferSize;
+	S32 mRequestedSize;
+	S32 mDesiredSize;
+	S32 mFileSize;
+	S32 mCachedSize;	
+	e_request_state mSentRequest;
+	handle_t mDecodeHandle;
+	BOOL mLoaded;
+	BOOL mDecoded;
+	BOOL mWritten;
+	BOOL mNeedsAux;
+	BOOL mHaveAllData;
+	BOOL mInLocalCache;
+	bool mCanUseHTTP ;
+	bool mCanUseNET ; //can get from asset server.
+	S32 mHTTPFailCount;
+	S32 mRetryAttempt;
+	S32 mActiveCount;
+	U32 mGetStatus;
+	std::string mGetReason;
+	
+	// Work Data
+	LLMutex mWorkMutex;
+	struct PacketData
+	{
+		PacketData(U8* data, S32 size) { mData = data; mSize = size; }
+		~PacketData() { clearData(); }
+		void clearData() { delete[] mData; mData = NULL; }
+		U8* mData;
+		U32 mSize;
+	};
+	std::vector<PacketData*> mPackets;
+	S32 mFirstPacket;
+	S32 mLastPacket;
+	U16 mTotalPackets;
+	U8 mImageCodec;
+
+	LLViewerAssetStats::duration_t mMetricsStartTime;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+class HTTPGetResponder : public LLCurl::Responder
+{
+	LOG_CLASS(HTTPGetResponder);
+public:
+	HTTPGetResponder(LLTextureFetch* fetcher, const LLUUID& id, U64 startTime, S32 requestedSize, U32 offset, bool redir)
+		: mFetcher(fetcher), mID(id), mStartTime(startTime), mRequestedSize(requestedSize), mOffset(offset), mFollowRedir(redir)
+	{
+	}
+	~HTTPGetResponder()
+	{
+	}
+
+	virtual void completedRaw(U32 status, const std::string& reason,
+							  const LLChannelDescriptors& channels,
+							  const LLIOPipe::buffer_ptr_t& buffer)
+	{
+		static LLCachedControl<bool> log_to_viewer_log(gSavedSettings,"LogTextureDownloadsToViewerLog");
+		static LLCachedControl<bool> log_to_sim(gSavedSettings,"LogTextureDownloadsToSimulator");
+		static LLCachedControl<bool> log_texture_traffic(gSavedSettings,"LogTextureNetworkTraffic") ;
+
+		if (log_to_viewer_log || log_to_sim)
+		{
+			mFetcher->mTextureInfo.setRequestStartTime(mID, mStartTime);
+			U64 timeNow = LLTimer::getTotalTime();
+			mFetcher->mTextureInfo.setRequestType(mID, LLTextureInfoDetails::REQUEST_TYPE_HTTP);
+			mFetcher->mTextureInfo.setRequestSize(mID, mRequestedSize);
+			mFetcher->mTextureInfo.setRequestOffset(mID, mOffset);
+			mFetcher->mTextureInfo.setRequestCompleteTimeAndLog(mID, timeNow);
+		}
+
+		lldebugs << "HTTP COMPLETE: " << mID << llendl;
+		LLTextureFetchWorker* worker = mFetcher->getWorker(mID);
+		if (worker)
+		{
+			bool success = false;
+			bool partial = false;
+			if (HTTP_OK <= status &&  status < HTTP_MULTIPLE_CHOICES)
+			{
+				success = true;
+				if (HTTP_PARTIAL_CONTENT == status) // partial information
+				{
+					partial = true;
+				}
+			}
+
+			if (!success)
+			{
+				worker->setGetStatus(status, reason);
+// 				llwarns << "CURL GET FAILED, status:" << status << " reason:" << reason << llendl;
+			}
+			
+			S32 data_size = worker->callbackHttpGet(channels, buffer, partial, success);
+			
+			if(log_texture_traffic && data_size > 0)
+			{
+				LLViewerTexture* tex = LLViewerTextureManager::findTexture(mID) ;
+				if(tex)
+				{
+					gTotalTextureBytesPerBoostLevel[tex->getBoostLevel()] += data_size ;
+				}
+			}
+
+			mFetcher->removeFromHTTPQueue(mID, data_size);
+
+			if (worker->mMetricsStartTime)
+			{
+				LLViewerAssetStatsFF::record_response_thread1(LLViewerAssetType::AT_TEXTURE,
+															  true,
+															  LLImageBase::TYPE_AVATAR_BAKE == worker->mType,
+															  LLViewerAssetStatsFF::get_timestamp() - worker->mMetricsStartTime);
+				worker->mMetricsStartTime = 0;
+			}
+			LLViewerAssetStatsFF::record_dequeue_thread1(LLViewerAssetType::AT_TEXTURE,
+														 true,
+														 LLImageBase::TYPE_AVATAR_BAKE == worker->mType);
+		}
+		else
+		{
+			mFetcher->removeFromHTTPQueue(mID);
+ 			llwarns << "Worker not found: " << mID << llendl;
+		}
+	}
+
+	virtual bool followRedir()
+	{
+		return mFollowRedir;
+	}
+	
+private:
+	LLTextureFetch* mFetcher;
+	LLUUID mID;
+	U64 mStartTime;
+	S32 mRequestedSize;
+	U32 mOffset;
+	bool mFollowRedir;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+// Cross-thread messaging for asset metrics.
+
+/**
+ * @brief Base class for cross-thread requests made of the fetcher
+ *
+ * I believe the intent of the LLQueuedThread class was to
+ * have these operations derived from LLQueuedThread::QueuedRequest
+ * but the texture fetcher has elected to manage the queue
+ * in its own manner.  So these are free-standing objects which are
+ * managed in simple FIFO order on the mCommands queue of the
+ * LLTextureFetch object.
+ *
+ * What each represents is a simple command sent from an
+ * outside thread into the TextureFetch thread to be processed
+ * in order and in a timely fashion (though not an absolute
+ * higher priority than other operations of the thread).
+ * Each operation derives a new class from the base customizing
+ * members, constructors and the doWork() method to effect
+ * the command.
+ *
+ * The flow is one-directional.  There are two global instances
+ * of the LLViewerAssetStats collector, one for the main program's
+ * thread pointed to by gViewerAssetStatsMain and one for the
+ * TextureFetch thread pointed to by gViewerAssetStatsThread1.
+ * Common operations has each thread recording metrics events
+ * into the respective collector unconcerned with locking and
+ * the state of any other thread.  But when the agent moves into
+ * a different region or the metrics timer expires and a report
+ * needs to be sent back to the grid, messaging across threads
+ * is required to distribute data and perform global actions.
+ * In pseudo-UML, it looks like:
+ *
+ *                       Main                 Thread1
+ *                        .                      .
+ *                        .                      .
+ *                     +-----+                   .
+ *                     | AM  |                   .
+ *                     +--+--+                   .
+ *      +-------+         |                      .
+ *      | Main  |      +--+--+                   .
+ *      |       |      | SRE |---.               .
+ *      | Stats |      +-----+    \              .
+ *      |       |         |        \  (uuid)  +-----+
+ *      | Coll. |      +--+--+      `-------->| SR  |
+ *      +-------+      | MSC |                +--+--+
+ *         | ^         +-----+                   |
+ *         | |  (uuid)  / .                   +-----+ (uuid)
+ *         |  `--------'  .                   | MSC |---------.
+ *         |              .                   +-----+         |
+ *         |           +-----+                   .            v
+ *         |           | TE  |                   .        +-------+
+ *         |           +--+--+                   .        | Thd1  |
+ *         |              |                      .        |       |
+ *         |           +-----+                   .        | Stats |
+ *          `--------->| RSC |                   .        |       |
+ *                     +--+--+                   .        | Coll. |
+ *                        |                      .        +-------+
+ *                     +--+--+                   .            |
+ *                     | SME |---.               .            |
+ *                     +-----+    \              .            |
+ *                        .        \ (clone)  +-----+         |
+ *                        .         `-------->| SM  |         |
+ *                        .                   +--+--+         |
+ *                        .                      |            |
+ *                        .                   +-----+         |
+ *                        .                   | RSC |<--------'
+ *                        .                   +-----+
+ *                        .                      |
+ *                        .                   +-----+
+ *                        .                   | CP  |--> HTTP POST
+ *                        .                   +-----+
+ *                        .                      .
+ *                        .                      .
+ *
+ *
+ * Key:
+ *
+ * SRE - Set Region Enqueued.  Enqueue a 'Set Region' command in
+ *       the other thread providing the new UUID of the region.
+ *       TFReqSetRegion carries the data.
+ * SR  - Set Region.  New region UUID is sent to the thread-local
+ *       collector.
+ * SME - Send Metrics Enqueued.  Enqueue a 'Send Metrics' command
+ *       including an ownership transfer of a cloned LLViewerAssetStats.
+ *       TFReqSendMetrics carries the data.
+ * SM  - Send Metrics.  Global metrics reporting operation.  Takes
+ *       the cloned stats from the command, merges it with the
+ *       thread's local stats, converts to LLSD and sends it on
+ *       to the grid.
+ * AM  - Agent Moved.  Agent has completed some sort of move to a
+ *       new region.
+ * TE  - Timer Expired.  Metrics timer has expired (on the order
+ *       of 10 minutes).
+ * CP  - CURL Post
+ * MSC - Modify Stats Collector.  State change in the thread-local
+ *       collector.  Typically a region change which affects the
+ *       global pointers used to find the 'current stats'.
+ * RSC - Read Stats Collector.  Extract collector data cloning it
+ *       (i.e. deep copy) when necessary.
+ *
+ */
+class LLTextureFetch::TFRequest // : public LLQueuedThread::QueuedRequest
+{
+public:
+	// Default ctors and assignment operator are correct.
+
+	virtual ~TFRequest()
+		{}
+
+	// Patterned after QueuedRequest's method but expected behavior
+	// is different.  Always expected to complete on the first call
+	// and work dispatcher will assume the same and delete the
+	// request after invocation.
+	virtual bool doWork(LLTextureFetch * fetcher) = 0;
+};
+
+namespace 
+{
+
+/**
+ * @brief Implements a 'Set Region' cross-thread command.
+ *
+ * When an agent moves to a new region, subsequent metrics need
+ * to be binned into a new or existing stats collection in 1:1
+ * relationship with the region.  We communicate this region
+ * change across the threads involved in the communication with
+ * this message.
+ *
+ * Corresponds to LLTextureFetch::commandSetRegion()
+ */
+class TFReqSetRegion : public LLTextureFetch::TFRequest
+{
+public:
+	TFReqSetRegion(U64 region_handle)
+		: LLTextureFetch::TFRequest(),
+		  mRegionHandle(region_handle)
+		{}
+	TFReqSetRegion & operator=(const TFReqSetRegion &);	// Not defined
+
+	virtual ~TFReqSetRegion()
+		{}
+
+	virtual bool doWork(LLTextureFetch * fetcher);
+		
+public:
+	const U64 mRegionHandle;
+};
+
+
+/**
+ * @brief Implements a 'Send Metrics' cross-thread command.
+ *
+ * This is the big operation.  The main thread gathers metrics
+ * for a period of minutes into LLViewerAssetStats and other
+ * objects then makes a snapshot of the data by cloning the
+ * collector.  This command transfers the clone, along with a few
+ * additional arguments (UUIDs), handing ownership to the
+ * TextureFetch thread.  It then merges its own data into the
+ * cloned copy, converts to LLSD and kicks off an HTTP POST of
+ * the resulting data to the currently active metrics collector.
+ *
+ * Corresponds to LLTextureFetch::commandSendMetrics()
+ */
+class TFReqSendMetrics : public LLTextureFetch::TFRequest
+{
+public:
+    /**
+	 * Construct the 'Send Metrics' command to have the TextureFetch
+	 * thread add and log metrics data.
+	 *
+	 * @param	caps_url		URL of a "ViewerMetrics" Caps target
+	 *							to receive the data.  Does not have to
+	 *							be associated with a particular region.
+	 *
+	 * @param	session_id		UUID of the agent's session.
+	 *
+	 * @param	agent_id		UUID of the agent.  (Being pure here...)
+	 *
+	 * @param	main_stats		Pointer to a clone of the main thread's
+	 *							LLViewerAssetStats data.  Thread1 takes
+	 *							ownership of the copy and disposes of it
+	 *							when done.
+	 */
+	TFReqSendMetrics(const std::string & caps_url,
+					 const LLUUID & session_id,
+					 const LLUUID & agent_id,
+					 LLViewerAssetStats * main_stats)
+		: LLTextureFetch::TFRequest(),
+		  mCapsURL(caps_url),
+		  mSessionID(session_id),
+		  mAgentID(agent_id),
+		  mMainStats(main_stats)
+		{}
+	TFReqSendMetrics & operator=(const TFReqSendMetrics &);	// Not defined
+
+	virtual ~TFReqSendMetrics();
+
+	virtual bool doWork(LLTextureFetch * fetcher);
+		
+public:
+	const std::string mCapsURL;
+	const LLUUID mSessionID;
+	const LLUUID mAgentID;
+	LLViewerAssetStats * mMainStats;
+};
+
+/*
+ * Examines the merged viewer metrics report and if found to be too long,
+ * will attempt to truncate it in some reasonable fashion.
+ *
+ * @param		max_regions		Limit of regions allowed in report.
+ *
+ * @param		metrics			Full, merged viewer metrics report.
+ *
+ * @returns		If data was truncated, returns true.
+ */
+bool truncate_viewer_metrics(int max_regions, LLSD & metrics);
+
+} // end of anonymous namespace
+
+
+//////////////////////////////////////////////////////////////////////////////
+
+//static
+const char* LLTextureFetchWorker::sStateDescs[] = {
+	"INVALID",
+	"INIT",
+	"LOAD_FROM_TEXTURE_CACHE",
+	"CACHE_POST",
+	"LOAD_FROM_NETWORK",
+	"LOAD_FROM_SIMULATOR",
+	"SEND_HTTP_REQ",
+	"WAIT_HTTP_REQ",
+	"DECODE_IMAGE",
+	"DECODE_IMAGE_UPDATE",
+	"WRITE_TO_CACHE",
+	"WAIT_ON_WRITE",
+	"DONE",
+};
+
+// static
+volatile bool LLTextureFetch::svMetricsDataBreak(true);	// Start with a data break
+
+// called from MAIN THREAD
+
+LLTextureFetchWorker::LLTextureFetchWorker(LLTextureFetch* fetcher,
+										   const std::string& url, // Optional URL
+										   const LLUUID& id,	// Image UUID
+										   const LLHost& host,	// Simulator host
+										   F32 priority,		// Priority
+										   S32 discard,			// Desired discard
+										   S32 size)			// Desired size
+	: LLWorkerClass(fetcher, "TextureFetch"),
+	  mState(INIT),
+	  mWriteToCacheState(NOT_WRITE),
+	  mFetcher(fetcher),
+	  mID(id),
+	  mHost(host),
+	  mUrl(url),
+	  mImagePriority(priority),
+	  mWorkPriority(0),
+	  mRequestedPriority(0.f),
+	  mDesiredDiscard(-1),
+	  mSimRequestedDiscard(-1),
+	  mRequestedDiscard(-1),
+	  mLoadedDiscard(-1),
+	  mDecodedDiscard(-1),
+	  mCacheReadHandle(LLTextureCache::nullHandle()),
+	  mCacheWriteHandle(LLTextureCache::nullHandle()),
+	  mBuffer(NULL),
+	  mBufferSize(0),
+	  mRequestedSize(0),
+	  mDesiredSize(TEXTURE_CACHE_ENTRY_SIZE),
+	  mFileSize(0),
+	  mCachedSize(0),
+	  mLoaded(FALSE),
+	  mSentRequest(UNSENT),
+	  mDecodeHandle(0),
+	  mDecoded(FALSE),
+	  mWritten(FALSE),
+	  mNeedsAux(FALSE),
+	  mHaveAllData(FALSE),
+	  mInLocalCache(FALSE),
+	  mCanUseHTTP(true),
+	  mHTTPFailCount(0),
+	  mRetryAttempt(0),
+	  mActiveCount(0),
+	  mGetStatus(0),
+	  mWorkMutex(NULL),
+	  mFirstPacket(0),
+	  mLastPacket(-1),
+	  mTotalPackets(0),
+	  mImageCodec(IMG_CODEC_INVALID),
+	  mMetricsStartTime(0)
+{
+	mCanUseNET = mUrl.empty() ;
+
+	calcWorkPriority();
+	mType = host.isOk() ? LLImageBase::TYPE_AVATAR_BAKE : LLImageBase::TYPE_NORMAL;
+// 	llinfos << "Create: " << mID << " mHost:" << host << " Discard=" << discard << llendl;
+	if (!mFetcher->mDebugPause)
+	{
+		U32 work_priority = mWorkPriority | LLWorkerThread::PRIORITY_HIGH;
+		addWork(0, work_priority );
+	}
+	setDesiredDiscard(discard, size);
+}
+
+LLTextureFetchWorker::~LLTextureFetchWorker()
+{
+// 	llinfos << "Destroy: " << mID
+// 			<< " Decoded=" << mDecodedDiscard
+// 			<< " Requested=" << mRequestedDiscard
+// 			<< " Desired=" << mDesiredDiscard << llendl;
+	llassert_always(!haveWork());
+	lockWorkMutex();
+	if (mCacheReadHandle != LLTextureCache::nullHandle() && mFetcher->mTextureCache)
+	{
+		mFetcher->mTextureCache->readComplete(mCacheReadHandle, true);
+	}
+	if (mCacheWriteHandle != LLTextureCache::nullHandle() && mFetcher->mTextureCache)
+	{
+		mFetcher->mTextureCache->writeComplete(mCacheWriteHandle, true);
+	}
+	mFormattedImage = NULL;
+	clearPackets();
+	unlockWorkMutex();
+	mFetcher->removeFromHTTPQueue(mID);
+}
+
+void LLTextureFetchWorker::clearPackets()
+{
+	for_each(mPackets.begin(), mPackets.end(), DeletePointer());
+	mPackets.clear();
+	mTotalPackets = 0;
+	mLastPacket = -1;
+	mFirstPacket = 0;
+}
+
+void LLTextureFetchWorker::setupPacketData()
+{
+	S32 data_size = 0;
+	if (mFormattedImage.notNull())
+	{
+		data_size = mFormattedImage->getDataSize();
+	}
+	if (data_size > 0)
+	{
+		// Only used for simulator requests
+		mFirstPacket = (data_size - FIRST_PACKET_SIZE) / MAX_IMG_PACKET_SIZE + 1;
+		if (FIRST_PACKET_SIZE + (mFirstPacket-1) * MAX_IMG_PACKET_SIZE != data_size)
+		{
+			llwarns << "Bad CACHED TEXTURE size: " << data_size << " removing." << llendl;
+			removeFromCache();
+			resetFormattedData();
+			clearPackets();
+		}
+		else if (mFileSize > 0)
+		{
+			mLastPacket = mFirstPacket-1;
+			mTotalPackets = (mFileSize - FIRST_PACKET_SIZE + MAX_IMG_PACKET_SIZE-1) / MAX_IMG_PACKET_SIZE + 1;
+		}
+		else
+		{
+			// This file was cached using HTTP so we have to refetch the first packet
+			resetFormattedData();
+			clearPackets();
+		}
+	}
+}
+
+U32 LLTextureFetchWorker::calcWorkPriority()
+{
+ 	//llassert_always(mImagePriority >= 0 && mImagePriority <= LLViewerFetchedTexture::maxDecodePriority());
+	static const F32 PRIORITY_SCALE = (F32)LLWorkerThread::PRIORITY_LOWBITS / LLViewerFetchedTexture::maxDecodePriority();
+
+	mWorkPriority = llmin((U32)LLWorkerThread::PRIORITY_LOWBITS, (U32)(mImagePriority * PRIORITY_SCALE));
+	return mWorkPriority;
+}
+
+// mWorkMutex is locked
+void LLTextureFetchWorker::setDesiredDiscard(S32 discard, S32 size)
+{
+	bool prioritize = false;
+	if (mDesiredDiscard != discard)
+	{
+		if (!haveWork())
+		{
+			calcWorkPriority();
+			if (!mFetcher->mDebugPause)
+			{
+				U32 work_priority = mWorkPriority | LLWorkerThread::PRIORITY_HIGH;
+				addWork(0, work_priority);
+			}
+		}
+		else if (mDesiredDiscard < discard)
+		{
+			prioritize = true;
+		}
+		mDesiredDiscard = discard;
+		mDesiredSize = size;
+	}
+	else if (size > mDesiredSize)
+	{
+		mDesiredSize = size;
+		prioritize = true;
+	}
+	mDesiredSize = llmax(mDesiredSize, TEXTURE_CACHE_ENTRY_SIZE);
+	if ((prioritize && mState == INIT) || mState == DONE)
+	{
+		mState = INIT;
+		U32 work_priority = mWorkPriority | LLWorkerThread::PRIORITY_HIGH;
+		setPriority(work_priority);
+	}
+}
+
+void LLTextureFetchWorker::setImagePriority(F32 priority)
+{
+// 	llassert_always(priority >= 0 && priority <= LLViewerTexture::maxDecodePriority());
+	F32 delta = fabs(priority - mImagePriority);
+	if (delta > (mImagePriority * .05f) || mState == DONE)
+	{
+		mImagePriority = priority;
+		calcWorkPriority();
+		U32 work_priority = mWorkPriority | (getPriority() & LLWorkerThread::PRIORITY_HIGHBITS);
+		setPriority(work_priority);
+	}
+}
+
+void LLTextureFetchWorker::resetFormattedData()
+{
+	delete[] mBuffer;
+	mBuffer = NULL;
+	mBufferSize = 0;
+	if (mFormattedImage.notNull())
+	{
+		mFormattedImage->deleteData();
+	}
+	mHaveAllData = FALSE;
+}
+
+// Called from MAIN thread
+void LLTextureFetchWorker::startWork(S32 param)
+{
+	llassert(mFormattedImage.isNull());
+}
+
+#include "llviewertexturelist.h" // debug
+
+// Called from LLWorkerThread::processRequest()
+bool LLTextureFetchWorker::doWork(S32 param)
+{
+	LLMutexLock lock(&mWorkMutex);
+
+	if ((mFetcher->isQuitting() || getFlags(LLWorkerClass::WCF_DELETE_REQUESTED)))
+	{
+		if (mState < DECODE_IMAGE)
+		{
+			return true; // abort
+		}
+	}
+
+	if(mImagePriority < F_ALMOST_ZERO)
+	{
+		if (mState == INIT || mState == LOAD_FROM_NETWORK || mState == LOAD_FROM_SIMULATOR)
+		{
+			return true; // abort
+		}
+	}
+	if(mState > CACHE_POST && !mCanUseNET && !mCanUseHTTP)
+	{
+		//nowhere to get data, abort.
+		return true ;
+	}
+
+	if (mFetcher->mDebugPause)
+	{
+		return false; // debug: don't do any work
+	}
+	if (mID == mFetcher->mDebugID)
+	{
+		mFetcher->mDebugCount++; // for setting breakpoints
+	}
+
+	if (mState != DONE)
+	{
+		mFetchTimer.reset();
+	}
+
+	if (mState == INIT)
+	{		
+		mRawImage = NULL ;
+		mRequestedDiscard = -1;
+		mLoadedDiscard = -1;
+		mDecodedDiscard = -1;
+		mRequestedSize = 0;
+		mFileSize = 0;
+		mCachedSize = 0;
+		mLoaded = FALSE;
+		mSentRequest = UNSENT;
+		mDecoded  = FALSE;
+		mWritten  = FALSE;
+		delete[] mBuffer;
+		mBuffer = NULL;
+		mBufferSize = 0;
+		mHaveAllData = FALSE;
+		clearPackets(); // TODO: Shouldn't be necessary
+		mCacheReadHandle = LLTextureCache::nullHandle();
+		mCacheWriteHandle = LLTextureCache::nullHandle();
+		mState = LOAD_FROM_TEXTURE_CACHE;
+		mDesiredSize = llmax(mDesiredSize, TEXTURE_CACHE_ENTRY_SIZE); // min desired size is TEXTURE_CACHE_ENTRY_SIZE
+		LL_DEBUGS("Texture") << mID << ": Priority: " << llformat("%8.0f",mImagePriority)
+							 << " Desired Discard: " << mDesiredDiscard << " Desired Size: " << mDesiredSize << LL_ENDL;
+		// fall through
+	}
+
+	if (mState == LOAD_FROM_TEXTURE_CACHE)
+	{
+		if (mCacheReadHandle == LLTextureCache::nullHandle())
+		{
+			U32 cache_priority = mWorkPriority;
+			S32 offset = mFormattedImage.notNull() ? mFormattedImage->getDataSize() : 0;
+			S32 size = mDesiredSize - offset;
+			if (size <= 0)
+			{
+				mState = CACHE_POST;
+				return false;
+			}
+			mFileSize = 0;
+			mLoaded = FALSE;			
+			
+			if (mUrl.compare(0, 7, "file://") == 0)
+			{
+				setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); // Set priority first since Responder may change it
+
+				// read file from local disk
+				std::string filename = mUrl.substr(7, std::string::npos);
+				CacheReadResponder* responder = new CacheReadResponder(mFetcher, mID, mFormattedImage);
+				mCacheReadHandle = mFetcher->mTextureCache->readFromCache(filename, mID, cache_priority,
+																		  offset, size, responder);
+			}
+			else if (mUrl.empty())
+			{
+				setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); // Set priority first since Responder may change it
+
+				CacheReadResponder* responder = new CacheReadResponder(mFetcher, mID, mFormattedImage);
+				mCacheReadHandle = mFetcher->mTextureCache->readFromCache(mID, cache_priority,
+																		  offset, size, responder);
+			}
+			else if(mCanUseHTTP)
+			{
+				if (!(mUrl.compare(0, 7, "http://") == 0))
+				{
+					// *TODO:?remove this warning
+					llwarns << "Unknown URL Type: " << mUrl << llendl;
+				}
+				setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
+				mState = SEND_HTTP_REQ;
+			}
+			else
+			{
+				setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
+				mState = LOAD_FROM_NETWORK;
+			}
+		}
+
+		if (mLoaded)
+		{
+			// Make sure request is complete. *TODO: make this auto-complete
+			if (mFetcher->mTextureCache->readComplete(mCacheReadHandle, false))
+			{
+				mCacheReadHandle = LLTextureCache::nullHandle();
+				mState = CACHE_POST;
+				// fall through
+			}
+			else
+			{
+				return false;
+			}
+		}
+		else
+		{
+			return false;
+		}
+	}
+
+	if (mState == CACHE_POST)
+	{
+		mCachedSize = mFormattedImage.notNull() ? mFormattedImage->getDataSize() : 0;
+		// Successfully loaded
+		if ((mCachedSize >= mDesiredSize) || mHaveAllData)
+		{
+			// we have enough data, decode it
+			llassert_always(mFormattedImage->getDataSize() > 0);
+			mLoadedDiscard = mDesiredDiscard;
+			mState = DECODE_IMAGE;
+			mWriteToCacheState = NOT_WRITE ;
+			LL_DEBUGS("Texture") << mID << ": Cached. Bytes: " << mFormattedImage->getDataSize()
+								 << " Size: " << llformat("%dx%d",mFormattedImage->getWidth(),mFormattedImage->getHeight())
+								 << " Desired Discard: " << mDesiredDiscard << " Desired Size: " << mDesiredSize << LL_ENDL;
+			// fall through
+		}
+		else
+		{
+			if (mUrl.compare(0, 7, "file://") == 0)
+			{
+				// failed to load local file, we're done.
+				return true;
+			}
+			// need more data
+			else
+			{
+				LL_DEBUGS("Texture") << mID << ": Not in Cache" << LL_ENDL;
+				mState = LOAD_FROM_NETWORK;
+			}
+			// fall through
+		}
+	}
+
+	if (mState == LOAD_FROM_NETWORK)
+	{
+		static LLCachedControl<bool> use_http(gSavedSettings,"ImagePipelineUseHTTP");
+
+// 		if (mHost != LLHost::invalid) get_url = false;
+		if ( use_http && mCanUseHTTP && mUrl.empty())//get http url.
+		{
+			LLViewerRegion* region = NULL;
+			if (mHost == LLHost::invalid)
+				region = gAgent.getRegion();
+			else
+				region = LLWorld::getInstance()->getRegion(mHost);
+
+			if (region)
+			{
+				std::string http_url = region->getHttpUrl() ;
+				if (!http_url.empty())
+				{
+					mUrl = http_url + "/?texture_id=" + mID.asString().c_str();
+					mWriteToCacheState = CAN_WRITE ; //because this texture has a fixed texture id.
+				}
+				else
+				{
+					mCanUseHTTP = false ;
+				}
+			}
+			else
+			{
+				// This will happen if not logged in or if a region deoes not have HTTP Texture enabled
+				//llwarns << "Region not found for host: " << mHost << llendl;
+				mCanUseHTTP = false;
+			}
+		}
+		if (mCanUseHTTP && !mUrl.empty())
+		{
+			mState = LLTextureFetchWorker::SEND_HTTP_REQ;
+			setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
+			if(mWriteToCacheState != NOT_WRITE)
+			{
+				mWriteToCacheState = CAN_WRITE ;
+			}
+			// don't return, fall through to next state
+		}
+		else if (mSentRequest == UNSENT && mCanUseNET)
+		{
+			// Add this to the network queue and sit here.
+			// LLTextureFetch::update() will send off a request which will change our state
+			mWriteToCacheState = CAN_WRITE ;
+			mRequestedSize = mDesiredSize;
+			mRequestedDiscard = mDesiredDiscard;
+			mSentRequest = QUEUED;
+			mFetcher->addToNetworkQueue(this);
+			if (! mMetricsStartTime)
+			{
+				mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp();
+			}
+			LLViewerAssetStatsFF::record_enqueue_thread1(LLViewerAssetType::AT_TEXTURE,
+														 false,
+														 LLImageBase::TYPE_AVATAR_BAKE == mType);
+			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
+			
+			return false;
+		}
+		else
+		{
+			// Shouldn't need to do anything here
+			//llassert_always(mFetcher->mNetworkQueue.find(mID) != mFetcher->mNetworkQueue.end());
+			// Make certain this is in the network queue
+			//mFetcher->addToNetworkQueue(this);
+			//if (! mMetricsStartTime)
+			//{
+			//   mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp();
+			//}
+			//LLViewerAssetStatsFF::record_enqueue_thread1(LLViewerAssetType::AT_TEXTURE, false,
+			//                                             LLImageBase::TYPE_AVATAR_BAKE == mType);
+			//setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
+			return false;
+		}
+	}
+	
+	if (mState == LOAD_FROM_SIMULATOR)
+	{
+		if (mFormattedImage.isNull())
+		{
+			mFormattedImage = new LLImageJ2C;
+		}
+		if (processSimulatorPackets())
+		{
+			LL_DEBUGS("Texture") << mID << ": Loaded from Sim. Bytes: " << mFormattedImage->getDataSize() << LL_ENDL;
+			mFetcher->removeFromNetworkQueue(this, false);
+			if (mFormattedImage.isNull() || !mFormattedImage->getDataSize())
+			{
+				// processSimulatorPackets() failed
+// 				llwarns << "processSimulatorPackets() failed to load buffer" << llendl;
+				return true; // failed
+			}
+			setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
+			mState = DECODE_IMAGE;
+			mWriteToCacheState = SHOULD_WRITE;
+
+			if (mMetricsStartTime)
+			{
+				LLViewerAssetStatsFF::record_response_thread1(LLViewerAssetType::AT_TEXTURE,
+															  false,
+															  LLImageBase::TYPE_AVATAR_BAKE == mType,
+															  LLViewerAssetStatsFF::get_timestamp() - mMetricsStartTime);
+				mMetricsStartTime = 0;
+			}
+			LLViewerAssetStatsFF::record_dequeue_thread1(LLViewerAssetType::AT_TEXTURE,
+														 false,
+														 LLImageBase::TYPE_AVATAR_BAKE == mType);
+		}
+		else
+		{
+			mFetcher->addToNetworkQueue(this); // failsafe
+			if (! mMetricsStartTime)
+			{
+				mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp();
+			}
+			LLViewerAssetStatsFF::record_enqueue_thread1(LLViewerAssetType::AT_TEXTURE,
+														 false,
+														 LLImageBase::TYPE_AVATAR_BAKE == mType);
+			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
+		}
+		return false;
+	}
+	
+	if (mState == SEND_HTTP_REQ)
+	{
+		if(mCanUseHTTP)
+		{
+			//NOTE:
+			//control the number of the http requests issued for:
+			//1, not openning too many file descriptors at the same time;
+			//2, control the traffic of http so udp gets bandwidth.
+			//
+			static const S32 MAX_NUM_OF_HTTP_REQUESTS_IN_QUEUE = 8 ;
+			if(mFetcher->getNumHTTPRequests() > MAX_NUM_OF_HTTP_REQUESTS_IN_QUEUE)
+			{
+				return false ; //wait.
+			}
+
+			mFetcher->removeFromNetworkQueue(this, false);
+			
+			S32 cur_size = 0;
+			if (mFormattedImage.notNull())
+			{
+				cur_size = mFormattedImage->getDataSize(); // amount of data we already have
+				if (mFormattedImage->getDiscardLevel() == 0)
+				{
+					if(cur_size > 0)
+					{
+						// We already have all the data, just decode it
+						mLoadedDiscard = mFormattedImage->getDiscardLevel();
+						mState = DECODE_IMAGE;
+						return false;
+					}
+					else
+					{
+						return true ; //abort.
+					}
+				}
+			}
+			mRequestedSize = mDesiredSize;
+			mRequestedDiscard = mDesiredDiscard;
+			mRequestedSize -= cur_size;
+			S32 offset = cur_size;
+			mBufferSize = cur_size; // This will get modified by callbackHttpGet()
+			
+			bool res = false;
+			if (!mUrl.empty())
+			{
+				mLoaded = FALSE;
+				mGetStatus = 0;
+				mGetReason.clear();
+				LL_DEBUGS("Texture") << "HTTP GET: " << mID << " Offset: " << offset
+									 << " Bytes: " << mRequestedSize
+									 << " Bandwidth(kbps): " << mFetcher->getTextureBandwidth() << "/" << mFetcher->mMaxBandwidth
+									 << LL_ENDL;
+				setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
+				mState = WAIT_HTTP_REQ;	
+
+				mFetcher->addToHTTPQueue(mID);
+				if (! mMetricsStartTime)
+				{
+					mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp();
+				}
+				LLViewerAssetStatsFF::record_enqueue_thread1(LLViewerAssetType::AT_TEXTURE,
+															 true,
+															 LLImageBase::TYPE_AVATAR_BAKE == mType);
+
+				// Will call callbackHttpGet when curl request completes
+				std::vector<std::string> headers;
+				headers.push_back("Accept: image/x-j2c");
+				res = mFetcher->mCurlGetRequest->getByteRange(mUrl, headers, offset, mRequestedSize,
+															  new HTTPGetResponder(mFetcher, mID, LLTimer::getTotalTime(), mRequestedSize, offset, true));
+			}
+			if (!res)
+			{
+				llwarns << "HTTP GET request failed for " << mID << llendl;
+				resetFormattedData();
+				++mHTTPFailCount;
+				return true; // failed
+			}
+			// fall through
+		}
+		else //can not use http fetch.
+		{
+			return true ; //abort
+		}
+	}
+	
+	if (mState == WAIT_HTTP_REQ)
+	{
+		if (mLoaded)
+		{
+			S32 cur_size = mFormattedImage.notNull() ? mFormattedImage->getDataSize() : 0;
+			if (mRequestedSize < 0)
+			{
+				S32 max_attempts;
+				if (mGetStatus == HTTP_NOT_FOUND)
+				{
+					mHTTPFailCount = max_attempts = 1; // Don't retry
+					llwarns << "Texture missing from server (404): " << mUrl << llendl;
+
+					//roll back to try UDP
+					if(mCanUseNET)
+					{
+						mState = INIT ;
+						mCanUseHTTP = false ;
+						setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
+						return false ;
+					}
+				}
+				else if (mGetStatus == HTTP_SERVICE_UNAVAILABLE)
+				{
+					// *TODO: Should probably introduce a timer here to delay future HTTP requsts
+					// for a short time (~1s) to ease server load? Ideally the server would queue
+					// requests instead of returning 503... we already limit the number pending.
+					++mHTTPFailCount;
+					max_attempts = mHTTPFailCount+1; // Keep retrying
+					LL_INFOS_ONCE("Texture") << "Texture server busy (503): " << mUrl << LL_ENDL;
+				}
+				else
+				{
+					const S32 HTTP_MAX_RETRY_COUNT = 3;
+					max_attempts = HTTP_MAX_RETRY_COUNT + 1;
+					++mHTTPFailCount;
+					llinfos << "HTTP GET failed for: " << mUrl
+							<< " Status: " << mGetStatus << " Reason: '" << mGetReason << "'"
+							<< " Attempt:" << mHTTPFailCount+1 << "/" << max_attempts << llendl;
+				}
+
+				if (mHTTPFailCount >= max_attempts)
+				{
+					if (cur_size > 0)
+					{
+						// Use available data
+						mLoadedDiscard = mFormattedImage->getDiscardLevel();
+						mState = DECODE_IMAGE;
+						return false; 
+					}
+					else
+					{
+						resetFormattedData();
+						mState = DONE;
+						return true; // failed
+					}
+				}
+				else
+				{
+					mState = SEND_HTTP_REQ;
+					return false; // retry
+				}
+			}
+			
+			llassert_always(mBufferSize == cur_size + mRequestedSize);
+			if(!mBufferSize)//no data received.
+			{
+				delete[] mBuffer; 
+				mBuffer = NULL;
+
+				//abort.
+				mState = DONE;
+				return true;
+			}
+
+			if (mFormattedImage.isNull())
+			{
+				// For now, create formatted image based on extension
+				std::string extension = gDirUtilp->getExtension(mUrl);
+				mFormattedImage = LLImageFormatted::createFromType(LLImageBase::getCodecFromExtension(extension));
+				if (mFormattedImage.isNull())
+				{
+					mFormattedImage = new LLImageJ2C; // default
+				}
+			}
+						
+			if (mHaveAllData && mRequestedDiscard == 0) //the image file is fully loaded.
+			{
+				mFileSize = mBufferSize;
+			}
+			else //the file size is unknown.
+			{
+				mFileSize = mBufferSize + 1 ; //flag the file is not fully loaded.
+			}
+			
+			U8* buffer = new U8[mBufferSize];
+			if (cur_size > 0)
+			{
+				memcpy(buffer, mFormattedImage->getData(), cur_size);
+			}
+			memcpy(buffer + cur_size, mBuffer, mRequestedSize); // append
+			// NOTE: setData releases current data and owns new data (buffer)
+			mFormattedImage->setData(buffer, mBufferSize);
+			// delete temp data
+			delete[] mBuffer; // Note: not 'buffer' (assigned in setData())
+			mBuffer = NULL;
+			mBufferSize = 0;
+			mLoadedDiscard = mRequestedDiscard;
+			mState = DECODE_IMAGE;
+			if(mWriteToCacheState != NOT_WRITE)
+			{
+				mWriteToCacheState = SHOULD_WRITE ;
+			}
+			setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
+			return false;
+		}
+		else
+		{
+			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
+			return false;
+		}
+	}
+	
+	if (mState == DECODE_IMAGE)
+	{
+		static LLCachedControl<bool> textures_decode_disabled(gSavedSettings,"TextureDecodeDisabled");
+		if(textures_decode_disabled)
+		{
+			// for debug use, don't decode
+			mState = DONE;
+			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
+			return true;
+		}
+
+		if (mDesiredDiscard < 0)
+		{
+			// We aborted, don't decode
+			mState = DONE;
+			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
+			return true;
+		}
+		
+		if (mFormattedImage->getDataSize() <= 0)
+		{
+			//llerrs << "Decode entered with invalid mFormattedImage. ID = " << mID << llendl;
+			
+			//abort, don't decode
+			mState = DONE;
+			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
+			return true;
+		}
+		if (mLoadedDiscard < 0)
+		{
+			//llerrs << "Decode entered with invalid mLoadedDiscard. ID = " << mID << llendl;
+
+			//abort, don't decode
+			mState = DONE;
+			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
+			return true;
+		}
+		setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); // Set priority first since Responder may change it
+		mRawImage = NULL;
+		mAuxImage = NULL;
+		llassert_always(mFormattedImage.notNull());
+		S32 discard = mHaveAllData ? 0 : mLoadedDiscard;
+		U32 image_priority = LLWorkerThread::PRIORITY_NORMAL | mWorkPriority;
+		mDecoded  = FALSE;
+		mState = DECODE_IMAGE_UPDATE;
+		LL_DEBUGS("Texture") << mID << ": Decoding. Bytes: " << mFormattedImage->getDataSize() << " Discard: " << discard
+				<< " All Data: " << mHaveAllData << LL_ENDL;
+		mDecodeHandle = mFetcher->mImageDecodeThread->decodeImage(mFormattedImage, image_priority, discard, mNeedsAux,
+																  new DecodeResponder(mFetcher, mID, this));
+		// fall though
+	}
+	
+	if (mState == DECODE_IMAGE_UPDATE)
+	{
+		if (mDecoded)
+		{
+			if (mDecodedDiscard < 0)
+			{
+				LL_DEBUGS("Texture") << mID << ": Failed to Decode." << LL_ENDL;
+				if (mCachedSize > 0 && !mInLocalCache && mRetryAttempt == 0)
+				{
+					// Cache file should be deleted, try again
+// 					llwarns << mID << ": Decode of cached file failed (removed), retrying" << llendl;
+					llassert_always(mDecodeHandle == 0);
+					mFormattedImage = NULL;
+					++mRetryAttempt;
+					setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
+					mState = INIT;
+					return false;
+				}
+				else
+				{
+// 					llwarns << "UNABLE TO LOAD TEXTURE: " << mID << " RETRIES: " << mRetryAttempt << llendl;
+					mState = DONE; // failed
+				}
+			}
+			else
+			{
+				llassert_always(mRawImage.notNull());
+				LL_DEBUGS("Texture") << mID << ": Decoded. Discard: " << mDecodedDiscard
+						<< " Raw Image: " << llformat("%dx%d",mRawImage->getWidth(),mRawImage->getHeight()) << LL_ENDL;
+				setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
+				mState = WRITE_TO_CACHE;
+			}
+			// fall through
+		}
+		else
+		{
+			return false;
+		}
+	}
+
+	if (mState == WRITE_TO_CACHE)
+	{
+		if (mWriteToCacheState != SHOULD_WRITE || mFormattedImage.isNull())
+		{
+			// If we're in a local cache or we didn't actually receive any new data,
+			// or we failed to load anything, skip
+			mState = DONE;
+			return false;
+		}
+		S32 datasize = mFormattedImage->getDataSize();
+		if(mFileSize < datasize)//This could happen when http fetching and sim fetching mixed.
+		{
+			if(mHaveAllData)
+			{
+				mFileSize = datasize ;
+			}
+			else
+			{
+				mFileSize = datasize + 1 ; //flag not fully loaded.
+			}
+		}
+		llassert_always(datasize);
+		setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); // Set priority first since Responder may change it
+		U32 cache_priority = mWorkPriority;
+		mWritten = FALSE;
+		mState = WAIT_ON_WRITE;
+		CacheWriteResponder* responder = new CacheWriteResponder(mFetcher, mID);
+		mCacheWriteHandle = mFetcher->mTextureCache->writeToCache(mID, cache_priority,
+																  mFormattedImage->getData(), datasize,
+																  mFileSize, responder);
+		// fall through
+	}
+	
+	if (mState == WAIT_ON_WRITE)
+	{
+		if (writeToCacheComplete())
+		{
+			mState = DONE;
+			// fall through
+		}
+		else
+		{
+			if (mDesiredDiscard < mDecodedDiscard)
+			{
+				// We're waiting for this write to complete before we can receive more data
+				// (we can't touch mFormattedImage until the write completes)
+				// Prioritize the write
+				mFetcher->mTextureCache->prioritizeWrite(mCacheWriteHandle);
+			}
+			return false;
+		}
+	}
+
+	if (mState == DONE)
+	{
+		if (mDecodedDiscard >= 0 && mDesiredDiscard < mDecodedDiscard)
+		{
+			// More data was requested, return to INIT
+			mState = INIT;
+			setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
+			return false;
+		}
+		else
+		{
+			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
+			return true;
+		}
+	}
+	
+	return false;
+}
+
+// Called from MAIN thread
+void LLTextureFetchWorker::endWork(S32 param, bool aborted)
+{
+	if (mDecodeHandle != 0)
+	{
+		mFetcher->mImageDecodeThread->abortRequest(mDecodeHandle, false);
+		mDecodeHandle = 0;
+	}
+	mFormattedImage = NULL;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+// virtual
+void LLTextureFetchWorker::finishWork(S32 param, bool completed)
+{
+	// The following are required in case the work was aborted
+	if (mCacheReadHandle != LLTextureCache::nullHandle())
+	{
+		mFetcher->mTextureCache->readComplete(mCacheReadHandle, true);
+		mCacheReadHandle = LLTextureCache::nullHandle();
+	}
+	if (mCacheWriteHandle != LLTextureCache::nullHandle())
+	{
+		mFetcher->mTextureCache->writeComplete(mCacheWriteHandle, true);
+		mCacheWriteHandle = LLTextureCache::nullHandle();
+	}
+}
+
+// virtual
+bool LLTextureFetchWorker::deleteOK()
+{
+	bool delete_ok = true;
+	// Allow any pending reads or writes to complete
+	if (mCacheReadHandle != LLTextureCache::nullHandle())
+	{
+		if (mFetcher->mTextureCache->readComplete(mCacheReadHandle, true))
+		{
+			mCacheReadHandle = LLTextureCache::nullHandle();
+		}
+		else
+		{
+			delete_ok = false;
+		}
+	}
+	if (mCacheWriteHandle != LLTextureCache::nullHandle())
+	{
+		if (mFetcher->mTextureCache->writeComplete(mCacheWriteHandle))
+		{
+			mCacheWriteHandle = LLTextureCache::nullHandle();
+		}
+		else
+		{
+			delete_ok = false;
+		}
+	}
+
+	if ((haveWork() &&
+		 // not ok to delete from these states
+		 ((mState >= WRITE_TO_CACHE && mState <= WAIT_ON_WRITE))))
+	{
+		delete_ok = false;
+	}
+	
+	return delete_ok;
+}
+
+void LLTextureFetchWorker::removeFromCache()
+{
+	if (!mInLocalCache)
+	{
+		mFetcher->mTextureCache->removeFromCache(mID);
+	}
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+
+bool LLTextureFetchWorker::processSimulatorPackets()
+{
+	if (mFormattedImage.isNull() || mRequestedSize < 0)
+	{
+		// not sure how we got here, but not a valid state, abort!
+		llassert_always(mDecodeHandle == 0);
+		mFormattedImage = NULL;
+		return true;
+	}
+	
+	if (mLastPacket >= mFirstPacket)
+	{
+		S32 buffer_size = mFormattedImage->getDataSize();
+		for (S32 i = mFirstPacket; i<=mLastPacket; i++)
+		{
+			llassert_always(mPackets[i]);
+			buffer_size += mPackets[i]->mSize;
+		}
+		bool have_all_data = mLastPacket >= mTotalPackets-1;
+		if (mRequestedSize <= 0)
+		{
+			// We received a packed but haven't requested anything yet (edge case)
+			// Return true (we're "done") since we didn't request anything
+			return true;
+		}
+		if (buffer_size >= mRequestedSize || have_all_data)
+		{
+			/// We have enough (or all) data
+			if (have_all_data)
+			{
+				mHaveAllData = TRUE;
+			}
+			S32 cur_size = mFormattedImage->getDataSize();
+			if (buffer_size > cur_size)
+			{
+				/// We have new data
+				U8* buffer = new U8[buffer_size];
+				S32 offset = 0;
+				if (cur_size > 0 && mFirstPacket > 0)
+				{
+					memcpy(buffer, mFormattedImage->getData(), cur_size);
+					offset = cur_size;
+				}
+				for (S32 i=mFirstPacket; i<=mLastPacket; i++)
+				{
+					memcpy(buffer + offset, mPackets[i]->mData, mPackets[i]->mSize);
+					offset += mPackets[i]->mSize;
+				}
+				// NOTE: setData releases current data
+				mFormattedImage->setData(buffer, buffer_size);
+			}
+			mLoadedDiscard = mRequestedDiscard;
+			return true;
+		}
+	}
+	return false;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+S32 LLTextureFetchWorker::callbackHttpGet(const LLChannelDescriptors& channels,
+										   const LLIOPipe::buffer_ptr_t& buffer,
+										   bool partial, bool success)
+{
+	S32 data_size = 0 ;
+
+	LLMutexLock lock(&mWorkMutex);
+
+	if (mState != WAIT_HTTP_REQ)
+	{
+		llwarns << "callbackHttpGet for unrequested fetch worker: " << mID
+				<< " req=" << mSentRequest << " state= " << mState << llendl;
+		return data_size;
+	}
+	if (mLoaded)
+	{
+		llwarns << "Duplicate callback for " << mID.asString() << llendl;
+		return data_size ; // ignore duplicate callback
+	}
+	if (success)
+	{
+		// get length of stream:
+		data_size = buffer->countAfter(channels.in(), NULL);		
+	
+		LL_DEBUGS("Texture") << "HTTP RECEIVED: " << mID.asString() << " Bytes: " << data_size << LL_ENDL;
+		if (data_size > 0)
+		{
+			// *TODO: set the formatted image data here directly to avoid the copy
+			mBuffer = new U8[data_size];
+			buffer->readAfter(channels.in(), NULL, mBuffer, data_size);
+			mBufferSize += data_size;
+			if (data_size < mRequestedSize && mRequestedDiscard == 0)
+			{
+				mHaveAllData = TRUE;
+			}
+			else if (data_size > mRequestedSize)
+			{
+				// *TODO: This shouldn't be happening any more
+				llwarns << "data_size = " << data_size << " > requested: " << mRequestedSize << llendl;
+				mHaveAllData = TRUE;
+				llassert_always(mDecodeHandle == 0);
+				mFormattedImage = NULL; // discard any previous data we had
+				mBufferSize = data_size;
+			}
+		}
+		else
+		{
+			// We requested data but received none (and no error),
+			// so presumably we have all of it
+			mHaveAllData = TRUE;
+		}
+		mRequestedSize = data_size;
+	}
+	else
+	{
+		mRequestedSize = -1; // error
+	}
+	mLoaded = TRUE;
+	setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
+
+	return data_size ;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+void LLTextureFetchWorker::callbackCacheRead(bool success, LLImageFormatted* image,
+											 S32 imagesize, BOOL islocal)
+{
+	LLMutexLock lock(&mWorkMutex);
+	if (mState != LOAD_FROM_TEXTURE_CACHE)
+	{
+// 		llwarns << "Read callback for " << mID << " with state = " << mState << llendl;
+		return;
+	}
+	if (success)
+	{
+		llassert_always(imagesize >= 0);
+		mFileSize = imagesize;
+		mFormattedImage = image;
+		mImageCodec = image->getCodec();
+		mInLocalCache = islocal;
+		if (mFileSize != 0 && mFormattedImage->getDataSize() >= mFileSize)
+		{
+			mHaveAllData = TRUE;
+		}
+	}
+	mLoaded = TRUE;
+	setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
+}
+
+void LLTextureFetchWorker::callbackCacheWrite(bool success)
+{
+	LLMutexLock lock(&mWorkMutex);
+	if (mState != WAIT_ON_WRITE)
+	{
+// 		llwarns << "Write callback for " << mID << " with state = " << mState << llendl;
+		return;
+	}
+	mWritten = TRUE;
+	setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+void LLTextureFetchWorker::callbackDecoded(bool success, LLImageRaw* raw, LLImageRaw* aux)
+{
+	LLMutexLock lock(&mWorkMutex);
+	if (mDecodeHandle == 0)
+	{
+		return; // aborted, ignore
+	}
+	if (mState != DECODE_IMAGE_UPDATE)
+	{
+// 		llwarns << "Decode callback for " << mID << " with state = " << mState << llendl;
+		mDecodeHandle = 0;
+		return;
+	}
+	llassert_always(mFormattedImage.notNull());
+	
+	mDecodeHandle = 0;
+	if (success)
+	{
+		llassert_always(raw);
+		mRawImage = raw;
+		mAuxImage = aux;
+		mDecodedDiscard = mFormattedImage->getDiscardLevel();
+ 		LL_DEBUGS("Texture") << mID << ": Decode Finished. Discard: " << mDecodedDiscard
+							 << " Raw Image: " << llformat("%dx%d",mRawImage->getWidth(),mRawImage->getHeight()) << LL_ENDL;
+	}
+	else
+	{
+		llwarns << "DECODE FAILED: " << mID << " Discard: " << (S32)mFormattedImage->getDiscardLevel() << llendl;
+		removeFromCache();
+		mDecodedDiscard = -1; // Redundant, here for clarity and paranoia
+	}
+	mDecoded = TRUE;
+// 	llinfos << mID << " : DECODE COMPLETE " << llendl;
+	setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+bool LLTextureFetchWorker::writeToCacheComplete()
+{
+	// Complete write to cache
+	if (mCacheWriteHandle != LLTextureCache::nullHandle())
+	{
+		if (!mWritten)
+		{
+			return false;
+		}
+		if (mFetcher->mTextureCache->writeComplete(mCacheWriteHandle))
+		{
+			mCacheWriteHandle = LLTextureCache::nullHandle();
+		}
+		else
+		{
+			return false;
+		}
+	}
+	return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+// public
+
+LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* imagedecodethread, bool threaded, bool qa_mode)
+	: LLWorkerThread("TextureFetch", threaded),
+	  mDebugCount(0),
+	  mDebugPause(FALSE),
+	  mPacketCount(0),
+	  mBadPacketCount(0),
+	  mQueueMutex(getAPRPool()),
+	  mNetworkQueueMutex(getAPRPool()),
+	  mTextureCache(cache),
+	  mImageDecodeThread(imagedecodethread),
+	  mTextureBandwidth(0),
+	  mHTTPTextureBits(0),
+	  mTotalHTTPRequests(0),
+	  mCurlGetRequest(NULL),
+	  mQAMode(qa_mode)
+{
+	mCurlPOSTRequestCount = 0;
+	mMaxBandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS");
+	mTextureInfo.setUpLogging(gSavedSettings.getBOOL("LogTextureDownloadsToViewerLog"), gSavedSettings.getBOOL("LogTextureDownloadsToSimulator"), gSavedSettings.getU32("TextureLoggingThreshold"));
+}
+
+LLTextureFetch::~LLTextureFetch()
+{
+	clearDeleteList() ;
+
+	while (! mCommands.empty())
+	{
+		TFRequest * req(mCommands.front());
+		mCommands.erase(mCommands.begin());
+		delete req;
+	}
+	
+	// ~LLQueuedThread() called here
+}
+
+bool LLTextureFetch::createRequest(const std::string& url, const LLUUID& id, const LLHost& host, F32 priority,
+								   S32 w, S32 h, S32 c, S32 desired_discard, bool needs_aux, bool can_use_http)
+{
+	if (mDebugPause)
+	{
+		return false;
+	}
+	
+	LLTextureFetchWorker* worker = getWorker(id) ;
+	if (worker)
+	{
+		if (worker->mHost != host)
+		{
+			llwarns << "LLTextureFetch::createRequest " << id << " called with multiple hosts: "
+					<< host << " != " << worker->mHost << llendl;
+			removeRequest(worker, true);
+			worker = NULL;
+			return false;
+		}
+	}
+
+	S32 desired_size;
+	std::string exten = gDirUtilp->getExtension(url);
+	if (!url.empty() && (!exten.empty() && LLImageBase::getCodecFromExtension(exten) != IMG_CODEC_J2C))
+	{
+		// Only do partial requests for J2C at the moment
+		desired_size = MAX_IMAGE_DATA_SIZE;
+		desired_discard = 0;
+	}
+	else if (desired_discard == 0)
+	{
+		// if we want the entire image, and we know its size, then get it all
+		// (calcDataSizeJ2C() below makes assumptions about how the image
+		// was compressed - this code ensures that when we request the entire image,
+		// we really do get it.)
+		desired_size = MAX_IMAGE_DATA_SIZE;
+	}
+	else if (w*h*c > 0)
+	{
+		// If the requester knows the dimensions of the image,
+		// this will calculate how much data we need without having to parse the header
+
+		desired_size = LLImageJ2C::calcDataSizeJ2C(w, h, c, desired_discard);
+	}
+	else
+	{
+		desired_size = TEXTURE_CACHE_ENTRY_SIZE;
+		desired_discard = MAX_DISCARD_LEVEL;
+	}
+
+	
+	if (worker)
+	{
+		if (worker->wasAborted())
+		{
+			return false; // need to wait for previous aborted request to complete
+		}
+		worker->lockWorkMutex();
+		worker->mActiveCount++;
+		worker->mNeedsAux = needs_aux;
+		worker->setImagePriority(priority);
+		worker->setDesiredDiscard(desired_discard, desired_size);
+		worker->setCanUseHTTP(can_use_http) ;
+		if (!worker->haveWork())
+		{
+			worker->mState = LLTextureFetchWorker::INIT;
+			worker->unlockWorkMutex();
+
+			worker->addWork(0, LLWorkerThread::PRIORITY_HIGH | worker->mWorkPriority);
+		}
+		else
+		{
+			worker->unlockWorkMutex();
+		}
+	}
+	else
+	{
+		worker = new LLTextureFetchWorker(this, url, id, host, priority, desired_discard, desired_size);
+		lockQueue() ;
+		mRequestMap[id] = worker;
+		unlockQueue() ;
+
+		worker->lockWorkMutex();
+		worker->mActiveCount++;
+		worker->mNeedsAux = needs_aux;
+		worker->setCanUseHTTP(can_use_http) ;
+		worker->unlockWorkMutex();
+	}
+	
+// 	llinfos << "REQUESTED: " << id << " Discard: " << desired_discard << llendl;
+	return true;
+}
+
+// protected
+void LLTextureFetch::addToNetworkQueue(LLTextureFetchWorker* worker)
+{
+	lockQueue() ;
+	bool in_request_map = (mRequestMap.find(worker->mID) != mRequestMap.end()) ;
+	unlockQueue() ;
+
+	LLMutexLock lock(&mNetworkQueueMutex);
+	if (in_request_map)
+	{
+		// only add to the queue if in the request map
+		// i.e. a delete has not been requested
+		mNetworkQueue.insert(worker->mID);
+	}
+	for (cancel_queue_t::iterator iter1 = mCancelQueue.begin();
+		 iter1 != mCancelQueue.end(); ++iter1)
+	{
+		iter1->second.erase(worker->mID);
+	}
+}
+
+void LLTextureFetch::removeFromNetworkQueue(LLTextureFetchWorker* worker, bool cancel)
+{
+	LLMutexLock lock(&mNetworkQueueMutex);
+	size_t erased = mNetworkQueue.erase(worker->mID);
+	if (cancel && erased > 0)
+	{
+		mCancelQueue[worker->mHost].insert(worker->mID);
+	}
+}
+
+// protected
+void LLTextureFetch::addToHTTPQueue(const LLUUID& id)
+{
+	LLMutexLock lock(&mNetworkQueueMutex);
+	mHTTPTextureQueue.insert(id);
+	mTotalHTTPRequests++;
+}
+
+void LLTextureFetch::removeFromHTTPQueue(const LLUUID& id, S32 received_size)
+{
+	LLMutexLock lock(&mNetworkQueueMutex);
+	mHTTPTextureQueue.erase(id);
+	mHTTPTextureBits += received_size * 8; // Approximate - does not include header bits	
+}
+
+void LLTextureFetch::deleteRequest(const LLUUID& id, bool cancel)
+{
+	lockQueue() ;
+	LLTextureFetchWorker* worker = getWorkerAfterLock(id);
+	if (worker)
+	{		
+		size_t erased_1 = mRequestMap.erase(worker->mID);
+		unlockQueue() ;
+
+		llassert_always(erased_1 > 0) ;
+
+		removeFromNetworkQueue(worker, cancel);
+		llassert_always(!(worker->getFlags(LLWorkerClass::WCF_DELETE_REQUESTED))) ;
+
+		worker->scheduleDelete();	
+	}
+	else
+	{
+		unlockQueue() ;
+	}
+}
+
+void LLTextureFetch::removeRequest(LLTextureFetchWorker* worker, bool cancel)
+{
+	lockQueue() ;
+	size_t erased_1 = mRequestMap.erase(worker->mID);
+	unlockQueue() ;
+
+	llassert_always(erased_1 > 0) ;
+	removeFromNetworkQueue(worker, cancel);
+	llassert_always(!(worker->getFlags(LLWorkerClass::WCF_DELETE_REQUESTED))) ;
+
+	worker->scheduleDelete();	
+}
+
+S32 LLTextureFetch::getNumRequests() 
+{ 
+	lockQueue() ;
+	S32 size = (S32)mRequestMap.size(); 
+	unlockQueue() ;
+
+	return size ;
+}
+
+S32 LLTextureFetch::getNumHTTPRequests() 
+{ 
+	mNetworkQueueMutex.lock() ;
+	S32 size = (S32)mHTTPTextureQueue.size(); 
+	mNetworkQueueMutex.unlock() ;
+
+	return size ;
+}
+
+U32 LLTextureFetch::getTotalNumHTTPRequests()
+{
+	mNetworkQueueMutex.lock() ;
+	U32 size = mTotalHTTPRequests ;
+	mNetworkQueueMutex.unlock() ;
+
+	return size ;
+}
+
+// call lockQueue() first!
+LLTextureFetchWorker* LLTextureFetch::getWorkerAfterLock(const LLUUID& id)
+{
+	LLTextureFetchWorker* res = NULL;
+	map_t::iterator iter = mRequestMap.find(id);
+	if (iter != mRequestMap.end())
+	{
+		res = iter->second;
+	}
+	return res;
+}
+
+LLTextureFetchWorker* LLTextureFetch::getWorker(const LLUUID& id)
+{
+	LLMutexLock lock(&mQueueMutex) ;
+
+	return getWorkerAfterLock(id) ;
+}
+
+
+bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level,
+										LLPointer<LLImageRaw>& raw, LLPointer<LLImageRaw>& aux)
+{
+	bool res = false;
+	LLTextureFetchWorker* worker = getWorker(id);
+	if (worker)
+	{
+		if (worker->wasAborted())
+		{
+			res = true;
+		}
+		else if (!worker->haveWork())
+		{
+			// Should only happen if we set mDebugPause...
+			if (!mDebugPause)
+			{
+// 				llwarns << "Adding work for inactive worker: " << id << llendl;
+				worker->addWork(0, LLWorkerThread::PRIORITY_HIGH | worker->mWorkPriority);
+			}
+		}
+		else if (worker->checkWork())
+		{
+			worker->lockWorkMutex();
+			discard_level = worker->mDecodedDiscard;
+			raw = worker->mRawImage;
+			aux = worker->mAuxImage;
+			res = true;
+			LL_DEBUGS("Texture") << id << ": Request Finished. State: " << worker->mState << " Discard: " << discard_level << LL_ENDL;
+			worker->unlockWorkMutex();
+		}
+		else
+		{
+			worker->lockWorkMutex();
+			if ((worker->mDecodedDiscard >= 0) &&
+				(worker->mDecodedDiscard < discard_level || discard_level < 0) &&
+				(worker->mState >= LLTextureFetchWorker::WAIT_ON_WRITE))
+			{
+				// Not finished, but data is ready
+				discard_level = worker->mDecodedDiscard;
+				raw = worker->mRawImage;
+				aux = worker->mAuxImage;
+			}
+			worker->unlockWorkMutex();
+		}
+	}
+	else
+	{
+		res = true;
+	}
+	return res;
+}
+
+bool LLTextureFetch::updateRequestPriority(const LLUUID& id, F32 priority)
+{
+	bool res = false;
+	LLTextureFetchWorker* worker = getWorker(id);
+	if (worker)
+	{
+		worker->lockWorkMutex();
+		worker->setImagePriority(priority);
+		worker->unlockWorkMutex();
+		res = true;
+	}
+	return res;
+}
+
+// Replicates and expands upon the base class's
+// getPending() implementation.  getPending() and
+// runCondition() replicate one another's logic to
+// an extent and are sometimes used for the same
+// function (deciding whether or not to sleep/pause
+// a thread).  So the implementations need to stay
+// in step, at least until this can be refactored and
+// the redundancy eliminated.
+//
+// May be called from any thread
+
+//virtual
+S32 LLTextureFetch::getPending()
+{
+	S32 res;
+	lockData();
+    {
+        LLMutexLock lock(&mQueueMutex);
+        
+        res = mRequestQueue.size();
+        res += mCurlPOSTRequestCount;
+        res += mCommands.size();
+    }
+	unlockData();
+	return res;
+}
+
+// virtual
+bool LLTextureFetch::runCondition()
+{
+	// Caller is holding the lock on LLThread's condition variable.
+	
+	// LLQueuedThread, unlike its base class LLThread, makes this a
+	// private method which is unfortunate.  I want to use it directly
+	// but I'm going to have to re-implement the logic here (or change
+	// declarations, which I don't want to do right now).
+	//
+	// Changes here may need to be reflected in getPending().
+	
+	bool have_no_commands(false);
+	{
+		LLMutexLock lock(&mQueueMutex);
+		
+		have_no_commands = mCommands.empty();
+	}
+	
+    bool have_no_curl_requests(0 == mCurlPOSTRequestCount);
+	
+	return ! (have_no_commands
+			  && have_no_curl_requests
+			  && (mRequestQueue.empty() && mIdleThread));		// From base class
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+// MAIN THREAD (unthreaded envs), WORKER THREAD (threaded envs)
+void LLTextureFetch::commonUpdate()
+{
+	// Run a cross-thread command, if any.
+	cmdDoWork();
+	
+	// Update Curl on same thread as mCurlGetRequest was constructed
+	S32 processed = mCurlGetRequest->process();
+	if (processed > 0)
+	{
+		lldebugs << "processed: " << processed << " messages." << llendl;
+	}
+}
+
+
+// MAIN THREAD
+//virtual
+S32 LLTextureFetch::update(U32 max_time_ms)
+{
+	static LLCachedControl<F32> band_width(gSavedSettings,"ThrottleBandwidthKBPS");
+
+	{
+		mNetworkQueueMutex.lock() ;
+		mMaxBandwidth = band_width ;
+
+		gTextureList.sTextureBits += mHTTPTextureBits ;
+		mHTTPTextureBits = 0 ;
+
+		mNetworkQueueMutex.unlock() ;
+	}
+
+	S32 res = LLWorkerThread::update(max_time_ms);
+	
+	if (!mDebugPause)
+	{
+		sendRequestListToSimulators();
+	}
+
+	if (!mThreaded)
+	{
+		commonUpdate();
+	}
+
+	return res;
+}
+
+//called in the MAIN thread after the TextureCacheThread shuts down.
+void LLTextureFetch::shutDownTextureCacheThread() 
+{
+	if(mTextureCache)
+	{
+		llassert_always(mTextureCache->isQuitting() || mTextureCache->isStopped()) ;
+		mTextureCache = NULL ;
+	}
+}
+	
+//called in the MAIN thread after the ImageDecodeThread shuts down.
+void LLTextureFetch::shutDownImageDecodeThread() 
+{
+	if(mImageDecodeThread)
+	{
+		llassert_always(mImageDecodeThread->isQuitting() || mImageDecodeThread->isStopped()) ;
+		mImageDecodeThread = NULL ;
+	}
+}
+
+// WORKER THREAD
+void LLTextureFetch::startThread()
+{
+	// Construct mCurlGetRequest from Worker Thread
+	mCurlGetRequest = new LLCurlRequest();
+}
+
+// WORKER THREAD
+void LLTextureFetch::endThread()
+{
+	// Destroy mCurlGetRequest from Worker Thread
+	delete mCurlGetRequest;
+	mCurlGetRequest = NULL;
+}
+
+// WORKER THREAD
+void LLTextureFetch::threadedUpdate()
+{
+	llassert_always(mCurlGetRequest);
+	
+	// Limit update frequency
+	const F32 PROCESS_TIME = 0.05f; 
+	static LLFrameTimer process_timer;
+	if (process_timer.getElapsedTimeF32() < PROCESS_TIME)
+	{
+		return;
+	}
+	process_timer.reset();
+	
+	commonUpdate();
+
+#if 0
+	const F32 INFO_TIME = 1.0f; 
+	static LLFrameTimer info_timer;
+	if (info_timer.getElapsedTimeF32() >= INFO_TIME)
+	{
+		S32 q = mCurlGetRequest->getQueued();
+		if (q > 0)
+		{
+			llinfos << "Queued gets: " << q << llendl;
+			info_timer.reset();
+		}
+	}
+#endif
+	
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+void LLTextureFetch::sendRequestListToSimulators()
+{
+	// All requests
+	const F32 REQUEST_DELTA_TIME = 0.10f; // 10 fps
+	
+	// Sim requests
+	const S32 IMAGES_PER_REQUEST = 50;
+	const F32 SIM_LAZY_FLUSH_TIMEOUT = 10.0f; // temp
+	const F32 MIN_REQUEST_TIME = 1.0f;
+	const F32 MIN_DELTA_PRIORITY = 1000.f;
+
+	// Periodically, gather the list of textures that need data from the network
+	// And send the requests out to the simulators
+	static LLFrameTimer timer;
+	if (timer.getElapsedTimeF32() < REQUEST_DELTA_TIME)
+	{
+		return;
+	}
+	timer.reset();
+	
+	// Send requests
+	typedef std::set<LLTextureFetchWorker*,LLTextureFetchWorker::Compare> request_list_t;
+	typedef std::map< LLHost, request_list_t > work_request_map_t;
+	work_request_map_t requests;
+	{
+	LLMutexLock lock2(&mNetworkQueueMutex);
+	for (queue_t::iterator iter = mNetworkQueue.begin(); iter != mNetworkQueue.end(); )
+	{
+		queue_t::iterator curiter = iter++;
+		LLTextureFetchWorker* req = getWorker(*curiter);
+		if (!req)
+		{
+			mNetworkQueue.erase(curiter);
+			continue; // paranoia
+		}
+		if ((req->mState != LLTextureFetchWorker::LOAD_FROM_NETWORK) &&
+			(req->mState != LLTextureFetchWorker::LOAD_FROM_SIMULATOR))
+		{
+			// We already received our URL, remove from the queue
+			llwarns << "Worker: " << req->mID << " in mNetworkQueue but in wrong state: " << req->mState << llendl;
+			mNetworkQueue.erase(curiter);
+			continue;
+		}
+		if (req->mID == mDebugID)
+		{
+			mDebugCount++; // for setting breakpoints
+		}
+		if (req->mSentRequest == LLTextureFetchWorker::SENT_SIM &&
+			req->mTotalPackets > 0 &&
+			req->mLastPacket >= req->mTotalPackets-1)
+		{
+			// We have all the packets... make sure this is high priority
+// 			req->setPriority(LLWorkerThread::PRIORITY_HIGH | req->mWorkPriority);
+			continue;
+		}
+		F32 elapsed = req->mRequestedTimer.getElapsedTimeF32();
+		{
+			F32 delta_priority = llabs(req->mRequestedPriority - req->mImagePriority);
+			if ((req->mSimRequestedDiscard != req->mDesiredDiscard) ||
+				(delta_priority > MIN_DELTA_PRIORITY && elapsed >= MIN_REQUEST_TIME) ||
+				(elapsed >= SIM_LAZY_FLUSH_TIMEOUT))
+			{
+				requests[req->mHost].insert(req);
+			}
+		}
+	}
+	}
+
+	for (work_request_map_t::iterator iter1 = requests.begin();
+		 iter1 != requests.end(); ++iter1)
+	{
+		LLHost host = iter1->first;
+		// invalid host = use agent host
+		if (host == LLHost::invalid)
+		{
+			host = gAgent.getRegionHost();
+		}
+
+		S32 sim_request_count = 0;
+		
+		for (request_list_t::iterator iter2 = iter1->second.begin();
+			 iter2 != iter1->second.end(); ++iter2)
+		{
+			LLTextureFetchWorker* req = *iter2;
+			if (gMessageSystem)
+			{
+				if (req->mSentRequest != LLTextureFetchWorker::SENT_SIM)
+				{
+					// Initialize packet data based on data read from cache
+					req->lockWorkMutex();
+					req->setupPacketData();
+					req->unlockWorkMutex();
+				}
+				if (0 == sim_request_count)
+				{
+					gMessageSystem->newMessageFast(_PREHASH_RequestImage);
+					gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+					gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+					gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+				}
+				S32 packet = req->mLastPacket + 1;
+				gMessageSystem->nextBlockFast(_PREHASH_RequestImage);
+				gMessageSystem->addUUIDFast(_PREHASH_Image, req->mID);
+				gMessageSystem->addS8Fast(_PREHASH_DiscardLevel, (S8)req->mDesiredDiscard);
+				gMessageSystem->addF32Fast(_PREHASH_DownloadPriority, req->mImagePriority);
+				gMessageSystem->addU32Fast(_PREHASH_Packet, packet);
+				gMessageSystem->addU8Fast(_PREHASH_Type, req->mType);
+// 				llinfos << "IMAGE REQUEST: " << req->mID << " Discard: " << req->mDesiredDiscard
+// 						<< " Packet: " << packet << " Priority: " << req->mImagePriority << llendl;
+
+				static LLCachedControl<bool> log_to_viewer_log(gSavedSettings,"LogTextureDownloadsToViewerLog");
+				static LLCachedControl<bool> log_to_sim(gSavedSettings,"LogTextureDownloadsToSimulator");
+				if (log_to_viewer_log || log_to_sim)
+				{
+					mTextureInfo.setRequestStartTime(req->mID, LLTimer::getTotalTime());
+					mTextureInfo.setRequestOffset(req->mID, 0);
+					mTextureInfo.setRequestSize(req->mID, 0);
+					mTextureInfo.setRequestType(req->mID, LLTextureInfoDetails::REQUEST_TYPE_UDP);
+				}
+
+				req->lockWorkMutex();
+				req->mSentRequest = LLTextureFetchWorker::SENT_SIM;
+				req->mSimRequestedDiscard = req->mDesiredDiscard;
+				req->mRequestedPriority = req->mImagePriority;
+				req->mRequestedTimer.reset();
+				req->unlockWorkMutex();
+				sim_request_count++;
+				if (sim_request_count >= IMAGES_PER_REQUEST)
+				{
+// 					llinfos << "REQUESTING " << sim_request_count << " IMAGES FROM HOST: " << host.getIPString() << llendl;
+
+					gMessageSystem->sendSemiReliable(host, NULL, NULL);
+					sim_request_count = 0;
+				}
+			}
+		}
+		if (gMessageSystem && sim_request_count > 0 && sim_request_count < IMAGES_PER_REQUEST)
+		{
+// 			llinfos << "REQUESTING " << sim_request_count << " IMAGES FROM HOST: " << host.getIPString() << llendl;
+			gMessageSystem->sendSemiReliable(host, NULL, NULL);
+			sim_request_count = 0;
+		}
+	}
+	
+	// Send cancelations
+	{
+	LLMutexLock lock2(&mNetworkQueueMutex);
+	if (gMessageSystem && !mCancelQueue.empty())
+	{
+		for (cancel_queue_t::iterator iter1 = mCancelQueue.begin();
+			 iter1 != mCancelQueue.end(); ++iter1)
+		{
+			LLHost host = iter1->first;
+			if (host == LLHost::invalid)
+			{
+				host = gAgent.getRegionHost();
+			}
+			S32 request_count = 0;
+			for (queue_t::iterator iter2 = iter1->second.begin();
+				 iter2 != iter1->second.end(); ++iter2)
+			{
+				if (0 == request_count)
+				{
+					gMessageSystem->newMessageFast(_PREHASH_RequestImage);
+					gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+					gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+					gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+				}
+				gMessageSystem->nextBlockFast(_PREHASH_RequestImage);
+				gMessageSystem->addUUIDFast(_PREHASH_Image, *iter2);
+				gMessageSystem->addS8Fast(_PREHASH_DiscardLevel, -1);
+				gMessageSystem->addF32Fast(_PREHASH_DownloadPriority, 0);
+				gMessageSystem->addU32Fast(_PREHASH_Packet, 0);
+				gMessageSystem->addU8Fast(_PREHASH_Type, 0);
+// 				llinfos << "CANCELING IMAGE REQUEST: " << (*iter2) << llendl;
+
+				request_count++;
+				if (request_count >= IMAGES_PER_REQUEST)
+				{
+					gMessageSystem->sendSemiReliable(host, NULL, NULL);
+					request_count = 0;
+				}
+			}
+			if (request_count > 0 && request_count < IMAGES_PER_REQUEST)
+			{
+				gMessageSystem->sendSemiReliable(host, NULL, NULL);
+			}
+		}
+		mCancelQueue.clear();
+	}
+	}
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+bool LLTextureFetchWorker::insertPacket(S32 index, U8* data, S32 size)
+{
+	mRequestedTimer.reset();
+	if (index >= mTotalPackets)
+	{
+// 		llwarns << "Received Image Packet " << index << " > max: " << mTotalPackets << " for image: " << mID << llendl;
+		return false;
+	}
+	if (index > 0 && index < mTotalPackets-1 && size != MAX_IMG_PACKET_SIZE)
+	{
+// 		llwarns << "Received bad sized packet: " << index << ", " << size << " != " << MAX_IMG_PACKET_SIZE << " for image: " << mID << llendl;
+		return false;
+	}
+	
+	if (index >= (S32)mPackets.size())
+	{
+		mPackets.resize(index+1, (PacketData*)NULL); // initializes v to NULL pointers
+	}
+	else if (mPackets[index] != NULL)
+	{
+// 		llwarns << "Received duplicate packet: " << index << " for image: " << mID << llendl;
+		return false;
+	}
+
+	mPackets[index] = new PacketData(data, size);
+	while (mLastPacket+1 < (S32)mPackets.size() && mPackets[mLastPacket+1] != NULL)
+	{
+		++mLastPacket;
+	}
+	return true;
+}
+
+bool LLTextureFetch::receiveImageHeader(const LLHost& host, const LLUUID& id, U8 codec, U16 packets, U32 totalbytes,
+										U16 data_size, U8* data)
+{
+	LLTextureFetchWorker* worker = getWorker(id);
+	bool res = true;
+
+	++mPacketCount;
+	
+	if (!worker)
+	{
+// 		llwarns << "Received header for non active worker: " << id << llendl;
+		res = false;
+	}
+	else if (worker->mState != LLTextureFetchWorker::LOAD_FROM_NETWORK ||
+			 worker->mSentRequest != LLTextureFetchWorker::SENT_SIM)
+	{
+// 		llwarns << "receiveImageHeader for worker: " << id
+// 				<< " in state: " << LLTextureFetchWorker::sStateDescs[worker->mState]
+// 				<< " sent: " << worker->mSentRequest << llendl;
+		res = false;
+	}
+	else if (worker->mLastPacket != -1)
+	{
+		// check to see if we've gotten this packet before
+// 		llwarns << "Received duplicate header for: " << id << llendl;
+		res = false;
+	}
+	else if (!data_size)
+	{
+// 		llwarns << "Img: " << id << ":" << " Empty Image Header" << llendl;
+		res = false;
+	}
+	if (!res)
+	{
+		++mBadPacketCount;
+		mNetworkQueueMutex.lock() ;
+		mCancelQueue[host].insert(id);
+		mNetworkQueueMutex.unlock() ;
+		return false;
+	}
+
+	worker->lockWorkMutex();
+
+	//	Copy header data into image object
+	worker->mImageCodec = codec;
+	worker->mTotalPackets = packets;
+	worker->mFileSize = (S32)totalbytes;	
+	llassert_always(totalbytes > 0);
+	llassert_always(data_size == FIRST_PACKET_SIZE || data_size == worker->mFileSize);
+	res = worker->insertPacket(0, data, data_size);
+	worker->setPriority(LLWorkerThread::PRIORITY_HIGH | worker->mWorkPriority);
+	worker->mState = LLTextureFetchWorker::LOAD_FROM_SIMULATOR;
+	worker->unlockWorkMutex();
+	return res;
+}
+
+bool LLTextureFetch::receiveImagePacket(const LLHost& host, const LLUUID& id, U16 packet_num, U16 data_size, U8* data)
+{
+	LLTextureFetchWorker* worker = getWorker(id);
+	bool res = true;
+
+	++mPacketCount;
+	
+	if (!worker)
+	{
+// 		llwarns << "Received packet " << packet_num << " for non active worker: " << id << llendl;
+		res = false;
+	}
+	else if (worker->mLastPacket == -1)
+	{
+// 		llwarns << "Received packet " << packet_num << " before header for: " << id << llendl;
+		res = false;
+	}
+	else if (!data_size)
+	{
+// 		llwarns << "Img: " << id << ":" << " Empty Image Header" << llendl;
+		res = false;
+	}
+	if (!res)
+	{
+		++mBadPacketCount;
+		mNetworkQueueMutex.lock() ;
+		mCancelQueue[host].insert(id);
+		mNetworkQueueMutex.unlock() ;
+		return false;
+	}
+
+	worker->lockWorkMutex();
+	
+	res = worker->insertPacket(packet_num, data, data_size);
+	
+	if ((worker->mState == LLTextureFetchWorker::LOAD_FROM_SIMULATOR) ||
+		(worker->mState == LLTextureFetchWorker::LOAD_FROM_NETWORK))
+	{
+		worker->setPriority(LLWorkerThread::PRIORITY_HIGH | worker->mWorkPriority);
+		worker->mState = LLTextureFetchWorker::LOAD_FROM_SIMULATOR;
+	}
+	else
+	{
+// 		llwarns << "receiveImagePacket " << packet_num << "/" << worker->mLastPacket << " for worker: " << id
+// 				<< " in state: " << LLTextureFetchWorker::sStateDescs[worker->mState] << llendl;
+		removeFromNetworkQueue(worker, true); // failsafe
+	}
+
+	if(packet_num >= (worker->mTotalPackets - 1))
+	{
+		static LLCachedControl<bool> log_to_viewer_log(gSavedSettings,"LogTextureDownloadsToViewerLog");
+		static LLCachedControl<bool> log_to_sim(gSavedSettings,"LogTextureDownloadsToSimulator");
+
+		if (log_to_viewer_log || log_to_sim)
+		{
+			U64 timeNow = LLTimer::getTotalTime();
+			mTextureInfo.setRequestSize(id, worker->mFileSize);
+			mTextureInfo.setRequestCompleteTimeAndLog(id, timeNow);
+		}
+	}
+	worker->unlockWorkMutex();
+
+	return res;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+BOOL LLTextureFetch::isFromLocalCache(const LLUUID& id)
+{
+	BOOL from_cache = FALSE ;
+
+	LLTextureFetchWorker* worker = getWorker(id);
+	if (worker)
+	{
+		worker->lockWorkMutex() ;
+		from_cache = worker->mInLocalCache ;
+		worker->unlockWorkMutex() ;
+	}
+
+	return from_cache ;
+}
+
+S32 LLTextureFetch::getFetchState(const LLUUID& id, F32& data_progress_p, F32& requested_priority_p,
+								  U32& fetch_priority_p, F32& fetch_dtime_p, F32& request_dtime_p, bool& can_use_http)
+{
+	S32 state = LLTextureFetchWorker::INVALID;
+	F32 data_progress = 0.0f;
+	F32 requested_priority = 0.0f;
+	F32 fetch_dtime = 999999.f;
+	F32 request_dtime = 999999.f;
+	U32 fetch_priority = 0;
+	
+	LLTextureFetchWorker* worker = getWorker(id);
+	if (worker && worker->haveWork())
+	{
+		worker->lockWorkMutex();
+		state = worker->mState;
+		fetch_dtime = worker->mFetchTimer.getElapsedTimeF32();
+		request_dtime = worker->mRequestedTimer.getElapsedTimeF32();
+		if (worker->mFileSize > 0)
+		{
+			if (state == LLTextureFetchWorker::LOAD_FROM_SIMULATOR)
+			{
+				S32 data_size = FIRST_PACKET_SIZE + (worker->mLastPacket-1) * MAX_IMG_PACKET_SIZE;
+				data_size = llmax(data_size, 0);
+				data_progress = (F32)data_size / (F32)worker->mFileSize;
+			}
+			else if (worker->mFormattedImage.notNull())
+			{
+				data_progress = (F32)worker->mFormattedImage->getDataSize() / (F32)worker->mFileSize;
+			}
+		}
+		if (state >= LLTextureFetchWorker::LOAD_FROM_NETWORK && state <= LLTextureFetchWorker::WAIT_HTTP_REQ)
+		{
+			requested_priority = worker->mRequestedPriority;
+		}
+		else
+		{
+			requested_priority = worker->mImagePriority;
+		}
+		fetch_priority = worker->getPriority();
+		can_use_http = worker->getCanUseHTTP() ;
+		worker->unlockWorkMutex();
+	}
+	data_progress_p = data_progress;
+	requested_priority_p = requested_priority;
+	fetch_priority_p = fetch_priority;
+	fetch_dtime_p = fetch_dtime;
+	request_dtime_p = request_dtime;
+	return state;
+}
+
+void LLTextureFetch::dump()
+{
+	llinfos << "LLTextureFetch REQUESTS:" << llendl;
+	for (request_queue_t::iterator iter = mRequestQueue.begin();
+		 iter != mRequestQueue.end(); ++iter)
+	{
+		LLQueuedThread::QueuedRequest* qreq = *iter;
+		LLWorkerThread::WorkRequest* wreq = (LLWorkerThread::WorkRequest*)qreq;
+		LLTextureFetchWorker* worker = (LLTextureFetchWorker*)wreq->getWorkerClass();
+		llinfos << " ID: " << worker->mID
+				<< " PRI: " << llformat("0x%08x",wreq->getPriority())
+				<< " STATE: " << worker->sStateDescs[worker->mState]
+				<< llendl;
+	}
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+// cross-thread command methods
+
+void LLTextureFetch::commandSetRegion(U64 region_handle)
+{
+	TFReqSetRegion * req = new TFReqSetRegion(region_handle);
+
+	cmdEnqueue(req);
+}
+
+void LLTextureFetch::commandSendMetrics(const std::string & caps_url,
+										const LLUUID & session_id,
+										const LLUUID & agent_id,
+										LLViewerAssetStats * main_stats)
+{
+	TFReqSendMetrics * req = new TFReqSendMetrics(caps_url, session_id, agent_id, main_stats);
+
+	cmdEnqueue(req);
+}
+
+void LLTextureFetch::commandDataBreak()
+{
+	// The pedantically correct way to implement this is to create a command
+	// request object in the above fashion and enqueue it.  However, this is
+	// simple data of an advisorial not operational nature and this case
+	// of shared-write access is tolerable.
+
+	LLTextureFetch::svMetricsDataBreak = true;
+}
+
+void LLTextureFetch::cmdEnqueue(TFRequest * req)
+{
+	lockQueue();
+	mCommands.push_back(req);
+	unlockQueue();
+
+	unpause();
+}
+
+LLTextureFetch::TFRequest * LLTextureFetch::cmdDequeue()
+{
+	TFRequest * ret = 0;
+	
+	lockQueue();
+	if (! mCommands.empty())
+	{
+		ret = mCommands.front();
+		mCommands.erase(mCommands.begin());
+	}
+	unlockQueue();
+
+	return ret;
+}
+
+void LLTextureFetch::cmdDoWork()
+{
+	if (mDebugPause)
+	{
+		return;  // debug: don't do any work
+	}
+
+	TFRequest * req = cmdDequeue();
+	if (req)
+	{
+		// One request per pass should really be enough for this.
+		req->doWork(this);
+		delete req;
+	}
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+
+// Private (anonymous) class methods implementing the command scheme.
+
+namespace
+{
+
+/**
+ * Implements the 'Set Region' command.
+ *
+ * Thread:  Thread1 (TextureFetch)
+ */
+bool
+TFReqSetRegion::doWork(LLTextureFetch *)
+{
+	LLViewerAssetStatsFF::set_region_thread1(mRegionHandle);
+
+	return true;
+}
+
+
+TFReqSendMetrics::~TFReqSendMetrics()
+{
+	delete mMainStats;
+	mMainStats = 0;
+}
+
+
+/**
+ * Implements the 'Send Metrics' command.  Takes over
+ * ownership of the passed LLViewerAssetStats pointer.
+ *
+ * Thread:  Thread1 (TextureFetch)
+ */
+bool
+TFReqSendMetrics::doWork(LLTextureFetch * fetcher)
+{
+	/*
+	 * HTTP POST responder.  Doesn't do much but tries to
+	 * detect simple breaks in recording the metrics stream.
+	 *
+	 * The 'volatile' modifiers don't indicate signals,
+	 * mmap'd memory or threads, really.  They indicate that
+	 * the referenced data is part of a pseudo-closure for
+	 * this responder rather than being required for correct
+	 * operation.
+     *
+     * We don't try very hard with the POST request.  We give
+     * it one shot and that's more-or-less it.  With a proper
+     * refactoring of the LLQueuedThread usage, these POSTs
+     * could be put in a request object and made more reliable.
+	 */
+	class lcl_responder : public LLCurl::Responder
+	{
+	public:
+		lcl_responder(LLTextureFetch * fetcher,
+					  S32 expected_sequence,
+                      volatile const S32 & live_sequence,
+                      volatile bool & reporting_break,
+					  volatile bool & reporting_started)
+			: LLCurl::Responder(),
+			  mFetcher(fetcher),
+              mExpectedSequence(expected_sequence),
+              mLiveSequence(live_sequence),
+			  mReportingBreak(reporting_break),
+			  mReportingStarted(reporting_started)
+			{
+                mFetcher->incrCurlPOSTCount();
+            }
+        
+        ~lcl_responder()
+            {
+                mFetcher->decrCurlPOSTCount();
+            }
+
+		// virtual
+		void error(U32 status_num, const std::string & reason)
+			{
+                if (mLiveSequence == mExpectedSequence)
+                {
+                    mReportingBreak = true;
+                }
+				LL_WARNS("Texture") << "Break in metrics stream due to POST failure to metrics collection service.  Reason:  "
+									<< reason << LL_ENDL;
+			}
+
+		// virtual
+		void result(const LLSD & content)
+			{
+                if (mLiveSequence == mExpectedSequence)
+                {
+                    mReportingBreak = false;
+                    mReportingStarted = true;
+                }
+			}
+
+	private:
+		LLTextureFetch * mFetcher;
+        S32 mExpectedSequence;
+        volatile const S32 & mLiveSequence;
+		volatile bool & mReportingBreak;
+		volatile bool & mReportingStarted;
+
+	}; // class lcl_responder
+	
+	if (! gViewerAssetStatsThread1)
+		return true;
+
+	static volatile bool reporting_started(false);
+	static volatile S32 report_sequence(0);
+    
+	// We've taken over ownership of the stats copy at this
+	// point.  Get a working reference to it for merging here
+	// but leave it in 'this'.  Destructor will rid us of it.
+	LLViewerAssetStats & main_stats = *mMainStats;
+
+	// Merge existing stats into those from main, convert to LLSD
+	main_stats.merge(*gViewerAssetStatsThread1);
+	LLSD merged_llsd = main_stats.asLLSD(true);
+
+	// Add some additional meta fields to the content
+	merged_llsd["session_id"] = mSessionID;
+	merged_llsd["agent_id"] = mAgentID;
+	merged_llsd["message"] = "ViewerAssetMetrics";					// Identifies the type of metrics
+	merged_llsd["sequence"] = report_sequence;						// Sequence number
+	merged_llsd["initial"] = ! reporting_started;					// Initial data from viewer
+	merged_llsd["break"] = LLTextureFetch::svMetricsDataBreak;		// Break in data prior to this report
+		
+	// Update sequence number
+	if (S32_MAX == ++report_sequence)
+		report_sequence = 0;
+
+	// Limit the size of the stats report if necessary.
+	merged_llsd["truncated"] = truncate_viewer_metrics(10, merged_llsd);
+
+	if (! mCapsURL.empty())
+	{
+		LLCurlRequest::headers_t headers;
+		fetcher->getCurlRequest().post(mCapsURL,
+									   headers,
+									   merged_llsd,
+									   new lcl_responder(fetcher,
+														 report_sequence,
+                                                         report_sequence,
+                                                         LLTextureFetch::svMetricsDataBreak,
+														 reporting_started));
+	}
+	else
+	{
+		LLTextureFetch::svMetricsDataBreak = true;
+	}
+
+	// In QA mode, Metrics submode, log the result for ease of testing
+	if (fetcher->isQAMode())
+	{
+		LL_INFOS("Textures") << merged_llsd << LL_ENDL;
+	}
+
+	gViewerAssetStatsThread1->reset();
+
+	return true;
+}
+
+
+bool
+truncate_viewer_metrics(int max_regions, LLSD & metrics)
+{
+	static const LLSD::String reg_tag("regions");
+	static const LLSD::String duration_tag("duration");
+	
+	LLSD & reg_map(metrics[reg_tag]);
+	if (reg_map.size() <= max_regions)
+	{
+		return false;
+	}
+
+	// Build map of region hashes ordered by duration
+	typedef std::multimap<LLSD::Real, int> reg_ordered_list_t;
+	reg_ordered_list_t regions_by_duration;
+
+	int ind(0);
+	LLSD::array_const_iterator it_end(reg_map.endArray());
+	for (LLSD::array_const_iterator it(reg_map.beginArray()); it_end != it; ++it, ++ind)
+	{
+		LLSD::Real duration = (*it)[duration_tag].asReal();
+		regions_by_duration.insert(reg_ordered_list_t::value_type(duration, ind));
+	}
+
+	// Build a replacement regions array with the longest-persistence regions
+	LLSD new_region(LLSD::emptyArray());
+	reg_ordered_list_t::const_reverse_iterator it2_end(regions_by_duration.rend());
+	reg_ordered_list_t::const_reverse_iterator it2(regions_by_duration.rbegin());
+	for (int i(0); i < max_regions && it2_end != it2; ++i, ++it2)
+	{
+		new_region.append(reg_map[it2->second]);
+	}
+	reg_map = new_region;
+	
+	return true;
+}
+
+} // end of anonymous namespace
+
+
+
diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h
index ad00a7ea36fdb6aec9d13e549e1f26b8bcb25f47..d101da1f4be1697e6221825a3c6cd72d8a7ca150 100644
--- a/indra/newview/lltexturefetch.h
+++ b/indra/newview/lltexturefetch.h
@@ -79,6 +79,7 @@ class LLTextureFetch : public LLWorkerThread
 	void dump();
 	S32 getNumRequests() ;
 	S32 getNumHTTPRequests() ;
+	U32 getTotalNumHTTPRequests() ;
 	
 	// Public for access by callbacks
     S32 getPending();
@@ -183,6 +184,9 @@ class LLTextureFetch : public LLWorkerThread
 
 	U32 mHTTPTextureBits;
 
+	//debug use
+	U32 mTotalHTTPRequests ;
+
 	// Out-of-band cross-thread command queue.  This command queue
 	// is logically tied to LLQueuedThread's list of
 	// QueuedRequest instances and so must be covered by the
diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp
index b9a15fd1f4dd836c757b739118563ef81efb9e22..0115115a230fde1d5a2c5030a8649dd37af0fa02 100644
--- a/indra/newview/lltextureview.cpp
+++ b/indra/newview/lltextureview.cpp
@@ -516,6 +516,7 @@ void LLGLTexMemBar::draw()
 	S32 v_offset = (S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f);
 	F32 total_texture_downloaded = (F32)gTotalTextureBytes / (1024 * 1024);
 	F32 total_object_downloaded = (F32)gTotalObjectBytes / (1024 * 1024);
+	U32 total_http_requests = LLAppViewer::getTextureFetch()->getTotalNumHTTPRequests() ;
 	//----------------------------------------------------------------------------
 	LLGLSUIDefault gls_ui;
 	LLColor4 text_color(1.f, 1.f, 1.f, 0.75f);
@@ -526,13 +527,13 @@ void LLGLTexMemBar::draw()
 	LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*6,
 											 text_color, LLFontGL::LEFT, LLFontGL::TOP);
 
-	text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB Raw Tot: %d MB Bias: %.2f Cache: %.1f/%.1f MB Net Tot Tex: %.1f MB Tot Obj: %.1f MB",
+	text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB Raw Tot: %d MB Bias: %.2f Cache: %.1f/%.1f MB Net Tot Tex: %.1f MB Tot Obj: %.1f MB Tot Htp: %d",
 					total_mem,
 					max_total_mem,
 					bound_mem,
 					max_bound_mem,
 					LLImageRaw::sGlobalRawMemory >> 20,	discard_bias,
-					cache_usage, cache_max_usage, total_texture_downloaded, total_object_downloaded);
+					cache_usage, cache_max_usage, total_texture_downloaded, total_object_downloaded, total_http_requests);
 	//, cache_entries, cache_max_entries
 
 	LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*3,
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index d3b6dcd86f2f937121d61890f9c997ae0869fd08..ed18d67b62067bb428a1e9c2f875005c6358c294 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -1436,9 +1436,12 @@ void LLViewerMedia::proxyWindowClosed(const std::string &uuid)
 // static
 void LLViewerMedia::createSpareBrowserMediaSource()
 {
-	if(!sSpareBrowserMediaSource)
+	// If we don't have a spare browser media source, create one.
+	// However, if PluginAttachDebuggerToPlugins is set then don't spawn a spare
+	// SLPlugin process in order to not be confused by an unrelated gdb terminal
+	// popping up at the moment we start a media plugin.
+	if (!sSpareBrowserMediaSource && !gSavedSettings.getBOOL("PluginAttachDebuggerToPlugins"))
 	{
-		// If we don't have a spare browser media source, create one.
 		// The null owner will keep the browser plugin from fully initializing 
 		// (specifically, it keeps LLPluginClassMedia from negotiating a size change, 
 		// which keeps MediaPluginWebkit::initBrowserWindow from doing anything until we have some necessary data, like the background color)
@@ -1694,7 +1697,8 @@ LLPluginClassMedia* LLViewerMediaImpl::newSourceFromMediaType(std::string media_
 	LLPluginClassMedia* media_source = NULL;
 	
 	// HACK: we always try to keep a spare running webkit plugin around to improve launch times.
-	if(plugin_basename == "media_plugin_webkit")
+	// If a spare was already created before PluginAttachDebuggerToPlugins was set, don't use it.
+	if(plugin_basename == "media_plugin_webkit" && !gSavedSettings.getBOOL("PluginAttachDebuggerToPlugins"))
 	{
 		media_source = LLViewerMedia::getSpareBrowserMediaSource();
 		if(media_source)
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 7dc5d96689d4449471ee7a736ca676137f444bf4..6fc85a39449ac2b44bc13747dd1106802b18bc4d 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -171,31 +171,6 @@ const BOOL SCRIPT_QUESTION_IS_CAUTION[SCRIPT_PERMISSION_EOF] =
 	FALSE	// ControlYourCamera
 };
 
-// Extract channel and version from a string like "SL Web Viewer Beta 10.11.29.215604".
-// (channel: "SL Web Viewer Beta", version: "10.11.29.215604")
-static bool parse_version_info(const std::string& version_info, std::string& channel, std::string& ver)
-{
-	size_t last_space = version_info.rfind(" ");
-	channel = version_info;
-
-	if (last_space != std::string::npos)
-	{
-		try
-		{
-			ver = version_info.substr(last_space + 1);
-			channel.replace(last_space, ver.length() + 1, ""); // strip version
-		}
-		catch (std::out_of_range)
-		{
-			return false;
-		}
-
-		return true;
-	}
-
-	return false;
-}
-
 bool friendship_offer_callback(const LLSD& notification, const LLSD& response)
 {
 	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
@@ -3848,31 +3823,6 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**)
 		return;
 	}
 
-	if (!gLastVersionChannel.empty())
-	{
-		std::string url = regionp->getCapability("ServerReleaseNotes");
-		if (url.empty())
-		{
-			// The capability hasn't arrived yet or is not supported,
-			// fall back to parsing server version channel.
-			std::string channel, ver;
-			if (!parse_version_info(version_channel, channel, ver))
-			{
-				llwarns << "Failed to parse server version channel (" << version_channel << ")" << llendl;
-			}
-
-			url = gSavedSettings.getString("ReleaseNotesURL");
-			LLSD args;
-			args["CHANNEL"] = LLWeb::escapeURL(channel);
-			args["VERSION"] = LLWeb::escapeURL(ver);
-			LLStringUtil::format(url, args);
-		}
-
-		LLSD args;
-		args["URL"] = url;
-		LLNotificationsUtil::add("ServerVersionChanged", args);
-	}
-
 	gLastVersionChannel = version_channel;
 }
 
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 48794c4c9d24b2a917017465aa439e83608f8255..090d3cadd491f90404e9463aa13c3a7f9e816818 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -210,7 +210,6 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
 	mLastInterpUpdateSecs(0.f),
 	mLastMessageUpdateSecs(0.f),
 	mLatestRecvPacketID(0),
-	mCircuitPacketCount(0),
 	mData(NULL),
 	mAudioSourcep(NULL),
 	mAudioGain(1.f),
@@ -1884,7 +1883,6 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 	}
 
 	mLatestRecvPacketID = packet_id;
-	mCircuitPacketCount = 0;
 
 	// Set the change flags for scale
 	if (new_scale != getScale())
@@ -2207,7 +2205,8 @@ void LLViewerObject::interpolateLinearMotion(const F64 & time, const F32 & dt)
 		LLVector3 new_pos = (vel + (0.5f * (dt-PHYSICS_TIMESTEP)) * accel) * dt;	
 		LLVector3 new_v = accel * dt;
 
-		if (time_since_last_update > sPhaseOutUpdateInterpolationTime)
+		if (time_since_last_update > sPhaseOutUpdateInterpolationTime &&
+			sPhaseOutUpdateInterpolationTime > 0.0)
 		{	// Haven't seen a viewer update in a while, check to see if the ciruit is still active
 			if (mRegionp)
 			{	// The simulator will NOT send updates if the object continues normally on the path
@@ -2216,9 +2215,12 @@ void LLViewerObject::interpolateLinearMotion(const F64 & time, const F32 & dt)
 				LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit( mRegionp->getHost() );
 				if (cdp)
 				{
+					// Find out how many seconds since last packet arrived on the circuit
+					F64 time_since_last_packet = LLMessageSystem::getMessageTimeSeconds() - cdp->getLastPacketInTime();
+
 					if (!cdp->isAlive() ||		// Circuit is dead or blocked
 						 cdp->isBlocked() ||	// or doesn't seem to be getting any packets
-						 (mCircuitPacketCount > 0 && mCircuitPacketCount == cdp->getPacketsIn()))
+						 (time_since_last_packet > sPhaseOutUpdateInterpolationTime))
 					{
 						// Start to reduce motion interpolation since we haven't seen a server update in a while
 						F64 time_since_last_interpolation = time - mLastInterpUpdateSecs;
@@ -2249,9 +2251,6 @@ void LLViewerObject::interpolateLinearMotion(const F64 & time, const F32 & dt)
 						new_pos = new_pos * ((F32) phase_out);
 						new_v = new_v * ((F32) phase_out);
 					}
-
-					// Save current circuit packet count to see if it changes 
-					mCircuitPacketCount = cdp->getPacketsIn();
 				}
 			}
 		}
@@ -5105,7 +5104,6 @@ void LLViewerObject::setRegion(LLViewerRegion *regionp)
 	}
 	
 	mLatestRecvPacketID = 0;
-	mCircuitPacketCount = 0;
 	mRegionp = regionp;
 
 	for (child_list_t::iterator i = mChildList.begin(); i != mChildList.end(); ++i)
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 614a5e59fa20d586b083d23560626f1e9fa66c58..7afb7f464bb9cd747f3896812b95467a9c1d907a 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -613,7 +613,6 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	F64				mLastInterpUpdateSecs;			// Last update for purposes of interpolation
 	F64				mLastMessageUpdateSecs;			// Last update from a message from the simulator
 	TPACKETID		mLatestRecvPacketID;			// Latest time stamp on message from simulator
-	U32				mCircuitPacketCount;			// Packet tracking for early detection of a stopped simulator circuit
 
 	// extra data sent from the sim...currently only used for tree species info
 	U8* mData;
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 5849ab4307c016364537d3bac79839daf0f7f768..970cc2e2a784837f282350e5c489cd2bab83e352 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -160,19 +160,13 @@ U64 LLViewerObjectList::getIndex(const U32 local_id,
 	return (((U64)index) << 32) | (U64)local_id;
 }
 
-BOOL LLViewerObjectList::removeFromLocalIDTable(const LLViewerObject &object)
+BOOL LLViewerObjectList::removeFromLocalIDTable(const LLViewerObject* objectp)
 {
-	if(object.getRegion())
+	if(objectp && objectp->getRegion())
 	{
-		U32 local_id = object.mLocalID;
-		LLHost region_host = object.getRegion()->getHost();
-		if(!region_host.isOk())
-		{
-			return FALSE ;
-		}
-
-		U32 ip = region_host.getAddress();
-		U32 port = region_host.getPort();
+		U32 local_id = objectp->mLocalID;		
+		U32 ip = objectp->getRegion()->getHost().getAddress();
+		U32 port = objectp->getRegion()->getHost().getPort();
 		U64 ipport = (((U64)ip) << 32) | (U64)port;
 		U32 index = sIPAndPortToIndex[ipport];
 		
@@ -187,7 +181,7 @@ BOOL LLViewerObjectList::removeFromLocalIDTable(const LLViewerObject &object)
 		}
 		
 		// Found existing entry
-		if (iter->second == object.getID())
+		if (iter->second == objectp->getID())
 		{   // Full UUIDs match, so remove the entry
 			sIndexAndLocalIDToUUID.erase(iter);
 			return TRUE;
@@ -477,7 +471,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			//			<< ", regionp " << (U32) regionp << ", object region " << (U32) objectp->getRegion()
 			//			<< llendl;
 			//}
-			removeFromLocalIDTable(*objectp);
+			removeFromLocalIDTable(objectp);
 			setUUIDAndLocal(fullid,
 							local_id,
 							gMessageSystem->getSenderIP(),
@@ -910,7 +904,7 @@ void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp)
 	//				<< objectp->getRegion()->getHost().getPort() << llendl;
 	//}	
 	
-	removeFromLocalIDTable(*objectp);
+	removeFromLocalIDTable(objectp);
 
 	if (objectp->onActiveList())
 	{
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index 605bac8e89f29fa0bc855bf6859950159e46c696..fda3d6899d577bcd4103c89d8cb2b144d9a54f8b 100644
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -160,7 +160,7 @@ class LLViewerObjectList
 								const U32 ip,
 								const U32 port); // Requires knowledge of message system info!
 
-	static BOOL removeFromLocalIDTable(const LLViewerObject &object);
+	static BOOL removeFromLocalIDTable(const LLViewerObject* objectp);
 	// Used ONLY by the orphaned object code.
 	static U64 getIndex(const U32 local_id, const U32 ip, const U32 port);
 
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index c7649001c5479563dac58a045907b465917fbc55..23b7b921b8ce1ca94a74b0c2953d8ac4cc8ae67d 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -322,6 +322,12 @@ LLViewerRegion::~LLViewerRegion()
 	std::for_each(mObjectPartition.begin(), mObjectPartition.end(), DeletePointer());
 }
 
+/*virtual*/ 
+const LLHost&	LLViewerRegion::getHost() const				
+{ 
+	return mHost; 
+}
+
 void LLViewerRegion::loadObjectCache()
 {
 	if (mCacheLoaded)
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 7c6559203e5fa7606685f67a5cc8b328e1ffdf4a..dd40b876cd4c24173ab0104d8f9374946ff50981 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -245,7 +245,7 @@ class LLViewerRegion: public LLCapabilityProvider // implements this interface
     LLEventPump& getCapAPI() { return mCapabilityListener.getCapAPI(); }
 
     /// implements LLCapabilityProvider
-	virtual LLHost	getHost() const				{ return mHost; }
+	/*virtual*/ const LLHost& getHost() const;
 	const U64 		&getHandle() const 			{ return mHandle; }
 
 	LLSurface		&getLand() const			{ return *mLandp; }
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 0c05a301e6be6e5bda26c09c497a4ca01017c0a9..cd16b15e3ef56cc38e4ef5fb8d2aff053eba8d7b 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -1214,12 +1214,15 @@ void LLViewerFetchedTexture::cleanup()
 
 void LLViewerFetchedTexture::setForSculpt()
 {
+	static const S32 MAX_INTERVAL = 8 ; //frames
+
 	mForSculpt = TRUE ;
 	if(isForSculptOnly() && !getBoundRecently())
 	{
 		destroyGLTexture() ; //sculpt image does not need gl texture.
 	}
 	checkCachedRawSculptImage() ;
+	setMaxVirtualSizeResetInterval(MAX_INTERVAL) ;
 }
 
 BOOL LLViewerFetchedTexture::isForSculptOnly() const
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index c812fcf2daf512d6f8155da23d972ec5b87556d8..166b11041279a1d55109971ab61e8a4d59e77bf5 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -296,13 +296,15 @@ class LLDebugText
 	line_list_t mLineList;
 	LLColor4 mTextColor;
 	
-public:
-	LLDebugText(LLViewerWindow* window) : mWindow(window) {}
-	
 	void addText(S32 x, S32 y, const std::string &text) 
 	{
 		mLineList.push_back(Line(text, x, y));
 	}
+	
+	void clearText() { mLineList.clear(); }
+	
+public:
+	LLDebugText(LLViewerWindow* window) : mWindow(window) {}
 
 	void update()
 	{
@@ -323,6 +325,8 @@ class LLDebugText
 		U32 ypos = 64;
 		const U32 y_inc = 20;
 
+		clearText();
+		
 		if (gSavedSettings.getBOOL("DebugShowTime"))
 		{
 			const U32 y_inc2 = 15;
@@ -601,6 +605,50 @@ class LLDebugText
 				ypos += y_inc;
 			}
 		}
+		
+		if (gSavedSettings.getBOOL("DebugShowTextureInfo"))
+		{
+			LLViewerObject* objectp = NULL ;
+			//objectp = = gAgentCamera.getFocusObject();
+			
+			LLSelectNode* nodep = LLSelectMgr::instance().getHoverNode();
+			if (nodep)
+			{
+				objectp = nodep->getObject();			
+			}
+			if (objectp && !objectp->isDead())
+			{
+				S32 num_faces = objectp->mDrawable->getNumFaces() ;
+				
+				for(S32 i = 0 ; i < num_faces; i++)
+				{
+					LLFace* facep = objectp->mDrawable->getFace(i) ;
+					if(facep)
+					{
+						//addText(xpos, ypos, llformat("ts_min: %.3f ts_max: %.3f tt_min: %.3f tt_max: %.3f", facep->mTexExtents[0].mV[0], facep->mTexExtents[1].mV[0],
+						//		facep->mTexExtents[0].mV[1], facep->mTexExtents[1].mV[1]));
+						//ypos += y_inc;
+						
+						addText(xpos, ypos, llformat("v_size: %.3f:  p_size: %.3f", facep->getVirtualSize(), facep->getPixelArea()));
+						ypos += y_inc;
+						
+						//const LLTextureEntry *tep = facep->getTextureEntry();
+						//if(tep)
+						//{
+						//	addText(xpos, ypos, llformat("scale_s: %.3f:  scale_t: %.3f", tep->mScaleS, tep->mScaleT)) ;
+						//	ypos += y_inc;
+						//}
+						
+						LLViewerTexture* tex = facep->getTexture() ;
+						if(tex)
+						{
+							addText(xpos, ypos, llformat("ID: %s v_size: %.3f", tex->getID().asString().c_str(), tex->getMaxVirtualSize()));
+							ypos += y_inc;
+						}
+					}
+				}
+			}
+		}
 	}
 
 	void draw()
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index c26008d6406dcb71d9b313267576689b463cfea7..b3312db4a0bde3f591125f7b78508481017f900c 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -225,8 +225,9 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const
 // Format string used to construct filename for the object cache
 static const char OBJECT_CACHE_FILENAME[] = "objects_%d_%d.slc";
 
-// Throw out 1/20 (5%) of our cache entries if we run out of room.
-const U32 ENTRIES_PURGE_FACTOR = 20;
+const U32 MAX_NUM_OBJECT_ENTRIES = 128 ;
+const U32 MIN_ENTRIES_TO_PURGE = 16 ;
+const U32 INVALID_TIME = 0 ;
 const char* object_cache_dirname = "objectcache";
 const char* header_filename = "object.cache";
 
@@ -261,6 +262,7 @@ void LLVOCache::destroyClass()
 LLVOCache::LLVOCache():
 	mInitialized(FALSE),
 	mReadOnly(TRUE),
+	mNumEntries(0),
 	mCacheSize(1)
 {
 	mEnabled = gSavedSettings.getBOOL("ObjectCacheEnabled");
@@ -298,17 +300,16 @@ void LLVOCache::initCache(ELLPath location, U32 size, U32 cache_version)
 		llwarns << "Cache already initialized." << llendl;
 		return ;
 	}
+	mInitialized = TRUE ;
 
 	setDirNames(location);
 	if (!mReadOnly)
 	{
 		LLFile::mkdir(mObjectCacheDirName);
 	}
-
-	mCacheSize = size;
-
-	readCacheHeader();
-	mInitialized = TRUE ;
+	mCacheSize = llclamp(size, MIN_ENTRIES_TO_PURGE, MAX_NUM_OBJECT_ENTRIES);
+	mMetaInfo.mVersion = cache_version;
+	readCacheHeader();	
 
 	if(mMetaInfo.mVersion != cache_version) 
 	{
@@ -332,6 +333,8 @@ void LLVOCache::removeCache(ELLPath location)
 		return ;
 	}
 
+	llinfos << "about to remove the object cache due to settings." << llendl ;
+
 	std::string delem = gDirUtilp->getDirDelimiter();
 	std::string mask = delem + "*";
 	std::string cache_dir = gDirUtilp->getExpandedFilename(location, object_cache_dirname);
@@ -352,6 +355,8 @@ void LLVOCache::removeCache()
 		return ;
 	}
 
+	llinfos << "about to remove the object cache due to some error." << llendl ;
+
 	std::string delem = gDirUtilp->getDirDelimiter();
 	std::string mask = delem + "*";
 	llinfos << "Removing cache at " << mObjectCacheDirName << llendl;
@@ -361,62 +366,80 @@ void LLVOCache::removeCache()
 	writeCacheHeader();
 }
 
-void LLVOCache::clearCacheInMemory()
-{
-	std::for_each(mHandleEntryMap.begin(), mHandleEntryMap.end(), DeletePairedPointer());
-	mHandleEntryMap.clear();
-}
-
-void LLVOCache::getObjectCacheFilename(U64 handle, std::string& filename) 
+void LLVOCache::removeEntry(HeaderEntryInfo* entry) 
 {
-	U32 region_x, region_y;
+	llassert_always(mInitialized) ;
+	if(mReadOnly)
+	{
+		return ;
+	}
+	if(!entry)
+	{
+		return ;
+	}
 
-	grid_from_region_handle(handle, &region_x, &region_y);
-	filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, object_cache_dirname,
-			   llformat(OBJECT_CACHE_FILENAME, region_x, region_y));
+	header_entry_queue_t::iterator iter = mHeaderEntryQueue.find(entry) ;
+	if(iter != mHeaderEntryQueue.end())
+	{		
+		mHandleEntryMap.erase(entry->mHandle) ;		
+		mHeaderEntryQueue.erase(iter) ;
+		removeFromCache(entry) ;
+		delete entry ;
 
-	return ;
+		mNumEntries = mHandleEntryMap.size() ;
+	}
 }
 
-void LLVOCache::removeFromCache(U64 handle)
+void LLVOCache::removeEntry(U64 handle) 
 {
-	if(mReadOnly)
+	handle_entry_map_t::iterator iter = mHandleEntryMap.find(handle) ;
+	if(iter == mHandleEntryMap.end()) //no cache
 	{
-		llwarns << "Not removing cache for handle " << handle << ": Cache is currently in read-only mode." << llendl;
 		return ;
 	}
-
-	std::string filename;
-	getObjectCacheFilename(handle, filename);
-	LLAPRFile::remove(filename, mLocalAPRFilePoolp);	
+	HeaderEntryInfo* entry = iter->second ;
+	removeEntry(entry) ;
 }
 
-BOOL LLVOCache::checkRead(LLAPRFile* apr_file, void* src, S32 n_bytes, bool remove_cache_on_error)
+void LLVOCache::clearCacheInMemory()
 {
-	if(!check_read(apr_file, src, n_bytes))
+	if(!mHeaderEntryQueue.empty()) 
 	{
-		if (remove_cache_on_error)
+		for(header_entry_queue_t::iterator iter = mHeaderEntryQueue.begin(); iter != mHeaderEntryQueue.end(); ++iter)
 		{
-			removeCache() ;
+			delete *iter ;
 		}
-		return FALSE ;
+		mHeaderEntryQueue.clear();
+		mHandleEntryMap.clear();
+		mNumEntries = 0 ;
 	}
 
-	return TRUE ;
 }
 
-BOOL LLVOCache::checkWrite(LLAPRFile* apr_file, void* src, S32 n_bytes, bool remove_cache_on_error) 
+void LLVOCache::getObjectCacheFilename(U64 handle, std::string& filename) 
+{
+	U32 region_x, region_y;
+
+	grid_from_region_handle(handle, &region_x, &region_y);
+	filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, object_cache_dirname,
+			   llformat(OBJECT_CACHE_FILENAME, region_x, region_y));
+
+	return ;
+}
+
+void LLVOCache::removeFromCache(HeaderEntryInfo* entry)
 {
-	if(!check_write(apr_file, src, n_bytes))
+	if(mReadOnly)
 	{
-		if (remove_cache_on_error)
-		{
-			removeCache() ;
-		}
-		return FALSE ;
+		llwarns << "Not removing cache for handle " << entry->mHandle << ": Cache is currently in read-only mode." << llendl;
+		return ;
 	}
 
-	return TRUE ;
+	std::string filename;
+	getObjectCacheFilename(entry->mHandle, filename);
+	LLAPRFile::remove(filename, mLocalAPRFilePoolp);
+	entry->mTime = INVALID_TIME ;
+	updateEntry(entry) ; //update the head file.
 }
 
 void LLVOCache::readCacheHeader()
@@ -430,45 +453,76 @@ void LLVOCache::readCacheHeader()
 	//clear stale info.
 	clearCacheInMemory();	
 
+	bool success = true ;
 	if (LLAPRFile::isExist(mHeaderFileName, mLocalAPRFilePoolp))
 	{
-		LLAPRFile* apr_file = new LLAPRFile(mHeaderFileName, APR_FOPEN_READ|APR_FOPEN_BINARY, mLocalAPRFilePoolp);		
+		LLAPRFile apr_file(mHeaderFileName, APR_READ|APR_BINARY, mLocalAPRFilePoolp);		
 		
 		//read the meta element
-		bool remove_cache_on_error = false;
-		if(!checkRead(apr_file, &mMetaInfo, sizeof(HeaderMetaInfo), remove_cache_on_error))
-		{
-			llwarns << "Error reading meta information from cache header." << llendl;
-			delete apr_file;
-			return;
-		}
-
-		HeaderEntryInfo* entry ;
-		for(U32 entry_index = 0; entry_index < mCacheSize; ++entry_index)
+		success = check_read(&apr_file, &mMetaInfo, sizeof(HeaderMetaInfo)) ;
+		
+		if(success)
 		{
-			entry = new HeaderEntryInfo() ;
-			if(!checkRead(apr_file, entry, sizeof(HeaderEntryInfo), remove_cache_on_error))
+			HeaderEntryInfo* entry = NULL ;
+			mNumEntries = 0 ;
+			U32 num_read = 0 ;
+			while(num_read++ < MAX_NUM_OBJECT_ENTRIES)
 			{
-				llwarns << "Error reading cache header entry. (entry_index=" << entry_index << ")" << llendl;
-				delete entry ;			
-				break;
+				if(!entry)
+				{
+					entry = new HeaderEntryInfo() ;
+				}
+				success = check_read(&apr_file, entry, sizeof(HeaderEntryInfo));
+								
+				if(!success) //failed
+				{
+					llwarns << "Error reading cache header entry. (entry_index=" << mNumEntries << ")" << llendl;
+					delete entry ;
+					entry = NULL ;
+					break ;
+				}
+				else if(entry->mTime == INVALID_TIME)
+				{
+					continue ; //an empty entry
+				}
+
+				entry->mIndex = mNumEntries++ ;
+				mHeaderEntryQueue.insert(entry) ;
+				mHandleEntryMap[entry->mHandle] = entry ;
+				entry = NULL ;
 			}
-			else if(!entry->mTime) //end of the cache.
+			if(entry)
 			{
 				delete entry ;
-				break;
 			}
-
-			entry->mIndex = entry_index;
-			mHandleEntryMap[entry->mHandle] = entry;
 		}
 
-		delete apr_file ;
+		//---------
+		//debug code
+		//----------
+		//std::string name ;
+		//for(header_entry_queue_t::iterator iter = mHeaderEntryQueue.begin() ; success && iter != mHeaderEntryQueue.end(); ++iter)
+		//{
+		//	getObjectCacheFilename((*iter)->mHandle, name) ;
+		//	llinfos << name << llendl ;
+		//}
+		//-----------
 	}
 	else
 	{
 		writeCacheHeader() ;
 	}
+
+	if(!success)
+	{
+		removeCache() ; //failed to read header, clear the cache
+	}
+	else if(mNumEntries >= mCacheSize)
+	{
+		purgeEntries(mCacheSize) ;
+	}
+
+	return ;
 }
 
 void LLVOCache::writeCacheHeader()
@@ -485,60 +539,50 @@ void LLVOCache::writeCacheHeader()
 		return;
 	}
 
-	LLAPRFile* apr_file = new LLAPRFile(mHeaderFileName, APR_FOPEN_CREATE|APR_FOPEN_WRITE|APR_FOPEN_BINARY|APR_FOPEN_TRUNCATE, mLocalAPRFilePoolp);
-
-	//write the meta element
-	if(!checkWrite(apr_file, &mMetaInfo, sizeof(HeaderMetaInfo)))
+	bool success = true ;
 	{
-		llwarns << "Error writing meta information to cache header." << llendl;
-		delete apr_file;
-		return;
-	}
+		LLAPRFile apr_file(mHeaderFileName, APR_CREATE|APR_WRITE|APR_BINARY, mLocalAPRFilePoolp);
 
-	U32 entry_index = 0;
-	handle_entry_map_t::iterator iter_end = mHandleEntryMap.end();
-	for(handle_entry_map_t::iterator iter = mHandleEntryMap.begin();
-		iter != iter_end;
-		++iter)
-	{
-		HeaderEntryInfo* entry = iter->second;
-		entry->mIndex = entry_index++;
-		if(!checkWrite(apr_file, (void*)entry, sizeof(HeaderEntryInfo)))
+		//write the meta element
+		success = check_write(&apr_file, &mMetaInfo, sizeof(HeaderMetaInfo)) ;
+
+
+		mNumEntries = 0 ;	
+		for(header_entry_queue_t::iterator iter = mHeaderEntryQueue.begin() ; success && iter != mHeaderEntryQueue.end(); ++iter)
 		{
-			llwarns << "Failed to write cache header for entry " << entry->mHandle << " (entry_index = " << entry_index << ")" << llendl;
-			delete apr_file;
-			return;
+			(*iter)->mIndex = mNumEntries++ ;
+			success = check_write(&apr_file, (void*)*iter, sizeof(HeaderEntryInfo));
 		}
-	}
-
-	// Why do we need to fill the cache header with default entries?  DK 2010-12-14
-	// It looks like we currently rely on the file being pre-allocated so we can seek during updateEntry().
-	if(entry_index < mCacheSize)
-	{
-		HeaderEntryInfo* entry = new HeaderEntryInfo() ;
-		for(; entry_index < mCacheSize; ++entry_index)
+	
+		mNumEntries = mHeaderEntryQueue.size() ;
+		if(success && mNumEntries < MAX_NUM_OBJECT_ENTRIES)
 		{
-			//fill the cache with the default entry.
-			if(!checkWrite(apr_file, entry, sizeof(HeaderEntryInfo)))
+			HeaderEntryInfo* entry = new HeaderEntryInfo() ;
+			entry->mTime = INVALID_TIME ;
+			for(S32 i = mNumEntries ; success && i < MAX_NUM_OBJECT_ENTRIES ; i++)
 			{
-				llwarns << "Failed to fill cache header with default entries (entry_index = " << entry_index << ").  Switching to read-only mode." << llendl;
-				mReadOnly = TRUE ; //disable the cache.
-				break;
+				//fill the cache with the default entry.
+				success = check_write(&apr_file, entry, sizeof(HeaderEntryInfo)) ;			
+
 			}
+			delete entry ;
 		}
-		delete entry ;
 	}
-	delete apr_file ;
+
+	if(!success)
+	{
+		clearCacheInMemory() ;
+		mReadOnly = TRUE ; //disable the cache.
+	}
+	return ;
 }
 
 BOOL LLVOCache::updateEntry(const HeaderEntryInfo* entry)
 {
-	LLAPRFile* apr_file = new LLAPRFile(mHeaderFileName, APR_FOPEN_WRITE|APR_FOPEN_BINARY, mLocalAPRFilePoolp);
-	apr_file->seek(APR_SET, entry->mIndex * sizeof(HeaderEntryInfo) + sizeof(HeaderMetaInfo)) ;
+	LLAPRFile apr_file(mHeaderFileName, APR_WRITE|APR_BINARY, mLocalAPRFilePoolp);
+	apr_file.seek(APR_SET, entry->mIndex * sizeof(HeaderEntryInfo) + sizeof(HeaderMetaInfo)) ;
 
-	BOOL result = checkWrite(apr_file, (void*)entry, sizeof(HeaderEntryInfo)) ;
-	delete apr_file;
-	return result;
+	return check_write(&apr_file, (void*)entry, sizeof(HeaderEntryInfo)) ;
 }
 
 void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::vocache_entry_map_t& cache_entry_map) 
@@ -557,76 +601,66 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca
 		return ;
 	}
 
-	std::string filename;
-	getObjectCacheFilename(handle, filename);
-	LLAPRFile* apr_file = new LLAPRFile(filename, APR_FOPEN_READ|APR_FOPEN_BINARY, mLocalAPRFilePoolp);
-
-	LLUUID cache_id ;
-	if(!checkRead(apr_file, cache_id.mData, UUID_BYTES))
-	{
-		llwarns << "Error reading cache_id from " << filename << llendl;
-		delete apr_file;
-		return ;
-	}
-	if(cache_id != id)
+	bool success = true ;
 	{
-		llwarns << "Cache ID (" << cache_id << ") doesn't match id for this region (" << id << "), discarding.  handle = " << handle << llendl;
-		delete apr_file ;
-		return ;
-	}
+		std::string filename;
+		getObjectCacheFilename(handle, filename);
+		LLAPRFile apr_file(filename, APR_READ|APR_BINARY, mLocalAPRFilePoolp);
+	
+		LLUUID cache_id ;
+		success = check_read(&apr_file, cache_id.mData, UUID_BYTES) ;
+	
+		if(success)
+		{		
+			if(cache_id != id)
+			{
+				llinfos << "Cache ID doesn't match for this region, discarding"<< llendl;
+				success = false ;
+			}
 
-	S32 num_entries;
-	if(!checkRead(apr_file, &num_entries, sizeof(S32)))
-	{
-		llwarns << "Error reading num_entries from " << filename << llendl;
-		delete apr_file;
-		return ;
+			if(success)
+			{
+				S32 num_entries;
+				success = check_read(&apr_file, &num_entries, sizeof(S32)) ;
+	
+				for (S32 i = 0; success && i < num_entries; i++)
+				{
+					LLVOCacheEntry* entry = new LLVOCacheEntry(&apr_file);
+					if (!entry->getLocalID())
+					{
+						llwarns << "Aborting cache file load for " << filename << ", cache file corruption!" << llendl;
+						delete entry ;
+						success = false ;
+					}
+					cache_entry_map[entry->getLocalID()] = entry;
+				}
+			}
+		}		
 	}
 	
-	for (S32 i = 0; i < num_entries; i++)
+	if(!success)
 	{
-		LLVOCacheEntry* entry = new LLVOCacheEntry(apr_file);
-		if (!entry->getLocalID())
+		if(cache_entry_map.empty())
 		{
-			llwarns << "Aborting cache file load for " << filename << ", cache file corruption! (entry number = " << i << ")" << llendl;
-			delete entry ;
-			break;
+			removeEntry(iter->second) ;
 		}
-		cache_entry_map[entry->getLocalID()] = entry;
 	}
 
-	delete apr_file ;
 	return ;
 }
 	
-void LLVOCache::purgeEntries()
+void LLVOCache::purgeEntries(U32 size)
 {
-	U32 limit = mCacheSize - (mCacheSize / ENTRIES_PURGE_FACTOR);
-	limit = llclamp(limit, (U32)1, mCacheSize);
-	// Construct a vector of entries out of the map so we can sort by time.
-	std::vector<HeaderEntryInfo*> header_vector;
-	handle_entry_map_t::iterator iter_end = mHandleEntryMap.end();
-	for (handle_entry_map_t::iterator iter = mHandleEntryMap.begin();
-		iter != iter_end;
-		++iter)
-	{
-		header_vector.push_back(iter->second);
-	}
-	// Sort by time, oldest first.
-	std::sort(header_vector.begin(), header_vector.end(), header_entry_less());
-	while(header_vector.size() > limit)
-	{
-		HeaderEntryInfo* entry = header_vector.front();
-		
-		removeFromCache(entry->mHandle);
+	while(mHeaderEntryQueue.size() >= size)
+	{
+		header_entry_queue_t::iterator iter = mHeaderEntryQueue.begin() ;
+		HeaderEntryInfo* entry = *iter ;			
 		mHandleEntryMap.erase(entry->mHandle);
-		header_vector.erase(header_vector.begin());
+		mHeaderEntryQueue.erase(iter) ;
+		removeFromCache(entry) ;
 		delete entry;
 	}
-
-	writeCacheHeader() ;
-	// *TODO: Verify that we can avoid re-reading the cache header.  DK 2010-12-14
-	readCacheHeader() ;
+	mNumEntries = mHandleEntryMap.size() ;
 }
 
 void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache) 
@@ -642,31 +676,34 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry:
 	{
 		llwarns << "Not writing cache for handle " << handle << "): Cache is currently in read-only mode." << llendl;
 		return ;
-	}
+	}	
 
-	U32 num_handle_entries = mHandleEntryMap.size();
-	
 	HeaderEntryInfo* entry;
 	handle_entry_map_t::iterator iter = mHandleEntryMap.find(handle) ;
 	if(iter == mHandleEntryMap.end()) //new entry
-	{
-		if(num_handle_entries >= mCacheSize)
+	{				
+		if(mNumEntries >= mCacheSize - 1)
 		{
-			purgeEntries() ;
-			num_handle_entries = mHandleEntryMap.size();
+			purgeEntries(mCacheSize - 1) ;
 		}
-		
+
 		entry = new HeaderEntryInfo();
 		entry->mHandle = handle ;
 		entry->mTime = time(NULL) ;
-		entry->mIndex = num_handle_entries++;
+		entry->mIndex = mNumEntries++;
+		mHeaderEntryQueue.insert(entry) ;
 		mHandleEntryMap[handle] = entry ;
 	}
 	else
 	{
 		// Update access time.
-		entry = iter->second ;
+		entry = iter->second ;		
+
+		//resort
+		mHeaderEntryQueue.erase(entry) ;
+		
 		entry->mTime = time(NULL) ;
+		mHeaderEntryQueue.insert(entry) ;
 	}
 
 	//update cache header
@@ -683,37 +720,33 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry:
 	}
 
 	//write to cache file
-	std::string filename;
-	getObjectCacheFilename(handle, filename);
-	LLAPRFile* apr_file = new LLAPRFile(filename, APR_FOPEN_CREATE|APR_FOPEN_WRITE|APR_FOPEN_BINARY|APR_FOPEN_TRUNCATE, mLocalAPRFilePoolp);
-	
-	if(!checkWrite(apr_file, (void*)id.mData, UUID_BYTES))
+	bool success = true ;
 	{
-		llwarns << "Error writing id to " << filename << llendl;
-		delete apr_file;
-		return ;
-	}
+		std::string filename;
+		getObjectCacheFilename(handle, filename);
+		LLAPRFile apr_file(filename, APR_CREATE|APR_WRITE|APR_BINARY, mLocalAPRFilePoolp);
+	
+		success = check_write(&apr_file, (void*)id.mData, UUID_BYTES) ;
 
-	S32 num_entries = cache_entry_map.size() ;
-	if(!checkWrite(apr_file, &num_entries, sizeof(S32)))
-	{
-		llwarns << "Error writing num_entries to " << filename << llendl;
-		delete apr_file;
-		return ;
+	
+		if(success)
+		{
+			S32 num_entries = cache_entry_map.size() ;
+			success = check_write(&apr_file, &num_entries, sizeof(S32));
+	
+			for (LLVOCacheEntry::vocache_entry_map_t::const_iterator iter = cache_entry_map.begin(); success && iter != cache_entry_map.end(); ++iter)
+			{
+				success = iter->second->writeToFile(&apr_file) ;
+			}
+		}
 	}
 
-	for (LLVOCacheEntry::vocache_entry_map_t::const_iterator iter = cache_entry_map.begin(); iter != cache_entry_map.end(); ++iter)
+	if(!success)
 	{
-		if(!iter->second->writeToFile(apr_file))
-		{
-			llwarns << "Aborting cache file write for " << filename << ", error writing to file!" << llendl;
-			//failed
-			removeCache() ;
-			break;
-		}
+		removeEntry(entry) ;
+
 	}
 
-	delete apr_file ;
 	return ;
 }
 
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index e1030079793a01a91e36c9c9cee9f670ae69dc57..14e3b4c79355a94b23827c9b29be224c13a085e7 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -95,13 +95,15 @@ class LLVOCache
 	{
 		bool operator()(const HeaderEntryInfo* lhs, const HeaderEntryInfo* rhs) const
 		{
-			if (lhs->mTime == rhs->mTime)
+			if(lhs->mTime == rhs->mTime) 
 			{
-				return lhs->mHandle < rhs->mHandle;
+				return lhs < rhs ;
 			}
-			return lhs->mTime < rhs->mTime; // older entry in front
+			
+			return lhs->mTime < rhs->mTime ; // older entry in front of queue (set)
 		}
 	};
+	typedef std::set<HeaderEntryInfo*, header_entry_less> header_entry_queue_t;
 	typedef std::map<U64, HeaderEntryInfo*> handle_entry_map_t;
 private:
 	LLVOCache() ;
@@ -114,6 +116,7 @@ class LLVOCache
 
 	void readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::vocache_entry_map_t& cache_entry_map) ;
 	void writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache) ;
+	void removeEntry(U64 handle) ;
 
 	void setReadOnly(BOOL read_only) {mReadOnly = read_only;} 
 
@@ -121,15 +124,14 @@ class LLVOCache
 	void setDirNames(ELLPath location);	
 	// determine the cache filename for the region from the region handle	
 	void getObjectCacheFilename(U64 handle, std::string& filename);
-	void removeFromCache(U64 handle);
+	void removeFromCache(HeaderEntryInfo* entry);
 	void readCacheHeader();
 	void writeCacheHeader();
 	void clearCacheInMemory();
 	void removeCache() ;
-	void purgeEntries();
+	void removeEntry(HeaderEntryInfo* entry) ;
+	void purgeEntries(U32 size);
 	BOOL updateEntry(const HeaderEntryInfo* entry);
-	BOOL checkRead(LLAPRFile* apr_file, void* src, S32 n_bytes, bool remove_cache_on_error = true) ;
-	BOOL checkWrite(LLAPRFile* apr_file, void* src, S32 n_bytes, bool remove_cache_on_error = true) ;
 	
 private:
 	BOOL                 mEnabled;
@@ -137,9 +139,11 @@ class LLVOCache
 	BOOL                 mReadOnly ;
 	HeaderMetaInfo       mMetaInfo;
 	U32                  mCacheSize;
+	U32                  mNumEntries;
 	std::string          mHeaderFileName ;
 	std::string          mObjectCacheDirName;
 	LLVolatileAPRPool*   mLocalAPRFilePoolp ; 	
+	header_entry_queue_t mHeaderEntryQueue;
 	handle_entry_map_t   mHandleEntryMap;	
 
 	static LLVOCache* sInstance ;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 761e12020bb3ed36776c6acb351a08a4a32d0fa2..f67e3a97700aecc9f24a82028a94ecff775bee3c 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -388,10 +388,12 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys,
 				// There's something bogus in the data that we're unpacking.
 				dp->dumpBufferToLog();
 				llwarns << "Flushing cache files" << llendl;
-				std::string mask;
-				mask = gDirUtilp->getDirDelimiter() + "*.slc";
-				gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,""), mask);
-// 				llerrs << "Bogus TE data in " << getID() << ", crashing!" << llendl;
+
+				if(LLVOCache::hasInstance() && getRegion())
+				{
+					LLVOCache::getInstance()->removeEntry(getRegion()->getHandle()) ;
+				}
+				
 				llwarns << "Bogus TE data in " << getID() << llendl;
 			}
 			else 
@@ -667,11 +669,32 @@ void LLVOVolume::updateTextures()
 	}
 }
 
+BOOL LLVOVolume::isVisible() const 
+{
+	if(mDrawable.notNull() && mDrawable->isVisible())
+	{
+		return TRUE ;
+	}
+
+	if(isAttachment())
+	{
+		LLViewerObject* objp = (LLViewerObject*)getParent() ;
+		while(objp && !objp->isAvatar())
+		{
+			objp = (LLViewerObject*)objp->getParent() ;
+		}
+
+		return objp && objp->mDrawable.notNull() && objp->mDrawable->isVisible() ;
+	}
+
+	return FALSE ;
+}
+
 void LLVOVolume::updateTextureVirtualSize()
 {
 	// Update the pixel area of all faces
 
-	if(mDrawable.isNull() || !mDrawable->isVisible())
+	if(!isVisible())
 	{
 		return ;
 	}
@@ -2738,14 +2761,7 @@ void LLVOVolume::updateRadius()
 
 BOOL LLVOVolume::isAttachment() const
 {
-	if (mState == 0)
-	{
-		return FALSE;
-	}
-	else
-	{
-		return TRUE;
-	}
+	return mState != 0 ;
 }
 
 BOOL LLVOVolume::isHUDAttachment() const
diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h
index 1e9b9737b166ee810552297384f37d0c9a5e121a..8b68e7c78a109cfa216b0dd54cd72cea30026539 100644
--- a/indra/newview/llvovolume.h
+++ b/indra/newview/llvovolume.h
@@ -102,6 +102,7 @@ class LLVOVolume : public LLViewerObject
 				void	animateTextures();
 	/*virtual*/ BOOL	idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
 
+	            BOOL    isVisible() const ;
 	/*virtual*/ BOOL	isActive() const;
 	/*virtual*/ BOOL	isAttachment() const;
 	/*virtual*/ BOOL	isRootEdit() const; // overridden for sake of attachments treating themselves as a root object
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 15477e0a803eff1aec8b0d5f33e6449a13231e2f..59b526059b367b06c948977cbbc7114db09440e1 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1967,12 +1967,12 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 
 	if(drawablep && !drawablep->isDead())
 	{
-	if (drawablep->isSpatialBridge())
-	{
+		if (drawablep->isSpatialBridge())
+		{
 			const LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable;
 			llassert(root); // trying to catch a bad assumption
 			if (root && //  // this test may not be needed, see above
-			    root->getVObj()->isAttachment())
+					root->getVObj()->isAttachment())
 			{
 				LLDrawable* rootparent = root->getParent();
 				if (rootparent) // this IS sometimes NULL
@@ -1980,24 +1980,24 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 					LLViewerObject *vobj = rootparent->getVObj();
 					llassert(vobj); // trying to catch a bad assumption
 					if (vobj) // this test may not be needed, see above
-		{
+					{
 						const LLVOAvatar* av = vobj->asAvatar();
-			if (av && av->isImpostor())
-			{
-				return;
-			}
-		}
+						if (av && av->isImpostor())
+						{
+							return;
+						}
+					}
 				}
 			}
-		sCull->pushBridge((LLSpatialBridge*) drawablep);
-	}
-	else
-	{
-		sCull->pushDrawable(drawablep);
-	}
+			sCull->pushBridge((LLSpatialBridge*) drawablep);
+		}
+		else
+		{
+			sCull->pushDrawable(drawablep);
+		}
 
-	drawablep->setVisible(camera);
-}
+		drawablep->setVisible(camera);
+	}
 }
 
 void LLPipeline::markMoved(LLDrawable *drawablep, BOOL damped_motion)
diff --git a/indra/newview/skins/default/xui/da/notifications.xml b/indra/newview/skins/default/xui/da/notifications.xml
index 593e686d4c126da89574cedc0946567e368c84ee..27024f4eaaf4d443fe82af5702af5e2e7975aeae 100644
--- a/indra/newview/skins/default/xui/da/notifications.xml
+++ b/indra/newview/skins/default/xui/da/notifications.xml
@@ -1580,9 +1580,6 @@ Klik på Acceptér for at deltage eller Afvis for at afvise invitationen. Klik p
 	<notification name="VoiceCallGenericError">
 		En fejl er opstået under forsøget på at koble sig på stemme chatten [VOICE_CHANNEL_NAME].  Pråv venligst senere.
 	</notification>
-	<notification name="ServerVersionChanged">
-		Du er netop ankommet til en region der benytter en anden server version, hvilket kan influere på hastigheden. [[URL] For at se yderligere.]
-	</notification>
 	<notification name="UnsupportedCommandSLURL">
 		Den SLurl du klikkede på understøttes ikke.
 	</notification>
diff --git a/indra/newview/skins/default/xui/de/floater_web_content.xml b/indra/newview/skins/default/xui/de/floater_web_content.xml
new file mode 100644
index 0000000000000000000000000000000000000000..6ab119eeab2b9a54049181e2b9af2a198e87019d
--- /dev/null
+++ b/indra/newview/skins/default/xui/de/floater_web_content.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<floater name="floater_web_content" title="">
+	<layout_stack name="stack1">
+		<layout_panel name="nav_controls">
+			<button name="back" tool_tip="Rückwärts"/>
+			<button name="forward" tool_tip="Vorwärts"/>
+			<button name="stop" tool_tip="Navigation stoppen"/>
+			<button name="reload" tool_tip="Seite neu laden"/>
+			<combo_box name="address" tool_tip="URL hier eingeben"/>
+			<icon name="media_secure_lock_flag" tool_tip="Sicheres Browsen"/>
+			<button name="popexternal" tool_tip="Aktuelle URL im Desktop-Browser öffnen"/>
+		</layout_panel>
+	</layout_stack>
+</floater>
diff --git a/indra/newview/skins/default/xui/de/menu_login.xml b/indra/newview/skins/default/xui/de/menu_login.xml
index 70d31f93ded08edf0cd94ae9e5b779f1eca699bf..a373e15338cfbf48542d28af416d46d167ffc902 100644
--- a/indra/newview/skins/default/xui/de/menu_login.xml
+++ b/indra/newview/skins/default/xui/de/menu_login.xml
@@ -17,7 +17,8 @@
 		<menu_item_call label="Fenstergröße einstellen..." name="Set Window Size..."/>
 		<menu_item_call label="Servicebedingungen anzeigen" name="TOS"/>
 		<menu_item_call label="Wichtige Meldung anzeigen" name="Critical"/>
-		<menu_item_call label="Web-Browser-Test" name="Web Browser Test"/>
+		<menu_item_call label="Test Medienbrowser" name="Web Browser Test"/>
+		<menu_item_call label="Test Webinhalt-Floater" name="Web Content Floater Test"/>
 		<menu_item_check label="Grid-Auswahl anzeigen" name="Show Grid Picker"/>
 		<menu_item_call label="Benachrichtigungs-Konsole anzeigen" name="Show Notifications Console"/>
 	</menu>
diff --git a/indra/newview/skins/default/xui/de/menu_mini_map.xml b/indra/newview/skins/default/xui/de/menu_mini_map.xml
index bec79be34da21a192f33187c335f0aa7900164e1..2e0d72c40c0d0420e0ba43cd9f81c02408b8c862 100644
--- a/indra/newview/skins/default/xui/de/menu_mini_map.xml
+++ b/indra/newview/skins/default/xui/de/menu_mini_map.xml
@@ -3,6 +3,7 @@
 	<menu_item_call label="Zoom Nah" name="Zoom Close"/>
 	<menu_item_call label="Zoom Mittel" name="Zoom Medium"/>
 	<menu_item_call label="Zoom Weit" name="Zoom Far"/>
+	<menu_item_call label="Zoom-Standard" name="Zoom Default"/>
 	<menu_item_check label="Karte drehen" name="Rotate Map"/>
 	<menu_item_check label="Automatisch zentrieren" name="Auto Center"/>
 	<menu_item_call label="Verfolgung abschalten" name="Stop Tracking"/>
diff --git a/indra/newview/skins/default/xui/de/menu_viewer.xml b/indra/newview/skins/default/xui/de/menu_viewer.xml
index 9eeeaccdea417d298dca89217e56c728bab57d82..4a043e1233ff30b15cc47b1fd333c009217b488b 100644
--- a/indra/newview/skins/default/xui/de/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/de/menu_viewer.xml
@@ -121,13 +121,15 @@
 			<menu_item_call label="Animation ([COST] L$)..." name="Upload Animation"/>
 			<menu_item_call label="Mehrfach-Upload ([COST] L$ pro Datei)..." name="Bulk Upload"/>
 		</menu>
+		<menu_item_call label="Rückgängig" name="Undo"/>
+		<menu_item_call label="Wiederholen" name="Redo"/>
 	</menu>
 	<menu label="Hilfe" name="Help">
 		<menu_item_call label="[SECOND_LIFE]-Hilfe" name="Second Life Help"/>
+		<menu_item_check label="Hinweise aktivieren" name="Enable Hints"/>
 		<menu_item_call label="Missbrauch melden" name="Report Abuse"/>
 		<menu_item_call label="Fehler melden" name="Report Bug"/>
 		<menu_item_call label="INFO ÃœBER [APP_NAME]" name="About Second Life"/>
-		<menu_item_check label="Hinweise aktivieren" name="Enable Hints"/>
 	</menu>
 	<menu label="Erweitert" name="Advanced">
 		<menu_item_call label="Textur neu laden" name="Rebake Texture"/>
@@ -308,7 +310,8 @@
 			<menu_item_call label="Regionsobjekt-Cache ausgeben" name="Dump Region Object Cache"/>
 		</menu>
 		<menu label="UI" name="UI">
-			<menu_item_call label="Web-Browser-Test" name="Web Browser Test"/>
+			<menu_item_call label="Test Medienbrowser" name="Web Browser Test"/>
+			<menu_item_call label="Webinhaltsbrowser" name="Web Content Browser"/>
 			<menu_item_call label="SelectMgr ausgeben" name="Dump SelectMgr"/>
 			<menu_item_call label="Inventarinfo ausgeben" name="Dump Inventory"/>
 			<menu_item_call label="Timer ausgeben" name="Dump Timers"/>
diff --git a/indra/newview/skins/default/xui/de/notifications.xml b/indra/newview/skins/default/xui/de/notifications.xml
index a2d0b5a1702394375b508705f78c376017549bfd..b0ad989a59bc801675bec7cf355bacaa16c0e042 100644
--- a/indra/newview/skins/default/xui/de/notifications.xml
+++ b/indra/newview/skins/default/xui/de/notifications.xml
@@ -109,6 +109,10 @@ Wählen Sie ein einzelnes Objekt aus und versuchen Sie es erneut.
 		Leute, die nicht auf Ihrer Freundesliste stehen, werden nicht wissen, dass Sie deren Anrufe oder Sofortnachrichten ignoriert haben.
 		<usetemplate name="okbutton" yestext="Ja"/>
 	</notification>
+	<notification name="FavoritesOnLogin">
+		Hinweis: Bei Aktivierung dieser Option sehen alle Personen, die diesen Computer benutzen, Ihre Lieblingsorte.
+		<usetemplate name="okbutton" yestext="OK"/>
+	</notification>
 	<notification name="GrantModifyRights">
 		Wenn Sie einem anderen Einwohner Änderungsrechte gewähren, dann kann dieser JEDES Objekt, das Sie inworld besitzen, ändern, löschen oder an sich nehmen. Seien Sie daher beim Gewähren dieser Rechte sehr vorsichtig!
 Möchten Sie [NAME] Änderungsrechte gewähren?
@@ -957,7 +961,7 @@ Sie sind nicht berechtigt, Land für die aktive Gruppe zu kaufen.
 			<input name="message">
 				[DESC] (neu)
 			</input>
-			<button name="Offer" text="OK"/>
+			<button name="OK" text="OK"/>
 			<button name="Cancel" text="Abbrechen"/>
 		</form>
 	</notification>
@@ -967,7 +971,7 @@ Sie sind nicht berechtigt, Land für die aktive Gruppe zu kaufen.
 			<input name="message">
 				[DESC] (neu)
 			</input>
-			<button name="Offer" text="OK"/>
+			<button name="OK" text="OK"/>
 			<button name="Cancel" text="Abbrechen"/>
 		</form>
 	</notification>
@@ -977,7 +981,7 @@ Sie sind nicht berechtigt, Land für die aktive Gruppe zu kaufen.
 			<input name="new_name">
 				[NAME]
 			</input>
-			<button name="Offer" text="OK"/>
+			<button name="OK" text="OK"/>
 			<button name="Cancel" text="Abbrechen"/>
 		</form>
 	</notification>
@@ -1355,9 +1359,39 @@ In Ihren Anwendungsordner herunterladen?
 Laden Sie den neuesten Viewer von http://secondlife.com/download herunter und installieren Sie ihn.
 		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
-	<notification name="DownloadBackground">
-		Eine aktualisierte Version von [APP_NAME] wurde heruntergeladen.
-Sie wird beim nächsten Neustart von [APP_NAME] verwendet.
+	<notification name="FailedRequiredUpdateInstall">
+		Ein erforderliches Update konnte nicht installiert werden. 
+Sie können sich erst anmelden, wenn [APP_NAME] aktualisiert wurde.
+
+Laden Sie den neuesten Viewer von http://secondlife.com/download herunter und installieren Sie ihn.
+		<usetemplate name="okbutton" yestext="Beenden"/>
+	</notification>
+	<notification name="UpdaterServiceNotRunning">
+		Für Ihre SecondLife-Installation ist ein Update erforderlich.
+
+Sie können dieses Update von http://www.secondlife.com/downloads herunterladen oder jetzt installieren.
+		<usetemplate name="okcancelbuttons" notext="Second Life beenden" yestext="Jetzt herunterladen und installieren"/>
+	</notification>
+	<notification name="DownloadBackgroundTip">
+		Für Ihre [APP_NAME]-Installation wurde ein Update heruntergeladen.
+Version [VERSION] [[RELEASE_NOTES_FULL_URL] Informationen zu diesem Update]
+		<usetemplate name="okcancelbuttons" notext="Später..." yestext="Jetzt installieren und [APP_NAME] neu starten"/>
+	</notification>
+	<notification name="DownloadBackgroundDialog">
+		Für Ihre [APP_NAME]-Installation wurde ein Update heruntergeladen.
+Version [VERSION] [[RELEASE_NOTES_FULL_URL] Informationen zu diesem Update]
+		<usetemplate name="okcancelbuttons" notext="Später..." yestext="Jetzt installieren und [APP_NAME] neu starten"/>
+	</notification>
+	<notification name="RequiredUpdateDownloadedVerboseDialog">
+		Ein erforderliches Softwareupdate wurde heruntergeladen.
+Version [VERSION]
+
+Zur Installation des Updates muss [APP_NAME] neu gestartet werden.
+		<usetemplate name="okbutton" yestext="OK"/>
+	</notification>
+	<notification name="RequiredUpdateDownloadedDialog">
+		Zur Installation des Updates muss [APP_NAME] neu gestartet werden.
+		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="DeedObjectToGroup">
 		Bei Übertragung dieses Objekts erhält die Gruppe:
@@ -2225,14 +2259,6 @@ Wählen Sie eine kleinere Landfläche.
 	<notification name="NoContentToSearch">
 		Bitte wählen Sie mindestens eine Inhaltsart für die Suche aus (Generell, Moderat oder Adult).
 	</notification>
-	<notification name="GroupVote">
-		[NAME] hat eine Abstimmung vorgeschlagen über:
-[MESSAGE]
-		<form name="form">
-			<button name="VoteNow" text="Abstimmen"/>
-			<button name="Later" text="Später"/>
-		</form>
-	</notification>
 	<notification name="SystemMessage">
 		[MESSAGE]
 	</notification>
@@ -2691,9 +2717,6 @@ Klicken Sie auf  &apos;Akzeptieren &apos;, um dem Chat beizutreten, oder auf  &a
 	<notification name="VoiceCallGenericError">
 		Fehler beim Versuch, eine Voice-Chat-Verbindung zu [VOICE_CHANNEL_NAME] herzustellen.  Bitte versuchen Sie es erneut.
 	</notification>
-	<notification name="ServerVersionChanged">
-		Sie haben eine Region betreten, die eine andere Server-Version verwendet. Dies kann sich auf die Leistung auswirken. [[URL] Versionshinweise anzeigen.]
-	</notification>
 	<notification name="UnsupportedCommandSLURL">
 		Die SLurl, auf die Sie geklickt haben, wird nicht unterstützt.
 	</notification>
@@ -2796,9 +2819,7 @@ Avatar &apos;[NAME]&apos; hat Modus „Aussehen bearbeiten&quot; verlassen.
 	<notification name="NoConnect">
 		Es gibt Probleme mit der Verbindung mit [PROTOCOL] [HOSTID].
 Bitte überprüfen Sie Ihre Netzwerk- und Firewalleinstellungen.
-		<form name="form">
-			<button name="OK" text="OK"/>
-		</form>
+		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="NoVoiceConnect">
 		Verbindung mit Voice-Server ist leider nicht möglich:
@@ -2807,9 +2828,7 @@ Bitte überprüfen Sie Ihre Netzwerk- und Firewalleinstellungen.
 
 Voice-Kommunikation ist leider nicht verfügbar.
 Bitte überprüfen Sie Ihr Netzwerk- und Firewall-Setup.
-		<form name="form">
-			<button name="OK" text="OK"/>
-		</form>
+		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="AvatarRezLeftNotification">
 		(Seit [EXISTENCE] Sekunden inworld )
@@ -2844,6 +2863,9 @@ Alle stummschalten?
 	<notification label="Welt erkunden" name="HintDestinationGuide">
 		Im Reiseführer finden Sie Tausende von interessanten Orten. Wählen Sie einfach einen Ort aus und klicken Sie auf „Teleportieren“.
 	</notification>
+	<notification label="Aussehen ändern" name="HintAvatarPicker">
+		Möchten Sie einen neuen Look ausprobieren? Klicken Sie auf die Schaltfläche unten, um mehr Avatare zu sehen.
+	</notification>
 	<notification label="Seitenleiste" name="HintSidePanel">
 		In der Seitenleiste können Sie schnell auf Ihr Inventar, Ihre Outfits, Ihre Profile u. ä. zugreifen.
 	</notification>
@@ -2853,6 +2875,12 @@ Alle stummschalten?
 	<notification label="Anzeigename" name="HintDisplayName">
 		Hier können Sie Ihren anpassbaren Anzeigenamen festlegen. Der Anzeigename unterscheidet sich von Ihrem eindeutigen Benutzernamen, der nicht geändert werden kann. In den Einstellungen können Sie festlegen, welcher Name von anderen Einwohnern angezeigt wird.
 	</notification>
+	<notification label="Bewegen" name="HintMoveArrows">
+		Verwenden Sie zum Gehen die Pfeiltasten auf Ihrer Tastatur. Drücken Sie die Nach-oben-Taste zweimal, um zu rennen.
+	</notification>
+	<notification label="Ansicht" name="HintView">
+		Um die Kameraansicht zu ändern, verwenden Sie die Schwenk- und Kreissteuerungen. Um die Ansicht zurückzusetzen, drücken Sie die Esc-Taste oder laufen Sie einfach.
+	</notification>
 	<notification label="Inventar" name="HintInventory">
 		In Ihrem Inventar befinden sich verschiedene Objekte. Die neuesten Objekte finden Sie in der Registerkarte „Aktuell“.
 	</notification>
@@ -2866,6 +2894,15 @@ Alle stummschalten?
 			<button name="open" text="Popup-Fenster öffnen"/>
 		</form>
 	</notification>
+	<notification name="AuthRequest">
+		Für die Site „&lt;nolink&gt;[HOST_NAME]&lt;/nolink&gt;“ in der Domäne „[REALM]“ ist ein Benutzername und Kennwort erforderlich.
+		<form name="form">
+			<input name="username" text="Benutzername"/>
+			<input name="password" text="Kennwort"/>
+			<button name="ok" text="Senden"/>
+			<button name="cancel" text="Abbrechen"/>
+		</form>
+	</notification>
 	<global name="UnsupportedCPU">
 		- Ihre CPU-Geschwindigkeit entspricht nicht den Mindestanforderungen.
 	</global>
diff --git a/indra/newview/skins/default/xui/de/panel_avatar_list_item.xml b/indra/newview/skins/default/xui/de/panel_avatar_list_item.xml
index 2db8cf7c0910796a7313742b7ddbd577fdd274b2..dcfcffa6e2f076730d3d7ddc030b68771d26a9ad 100644
--- a/indra/newview/skins/default/xui/de/panel_avatar_list_item.xml
+++ b/indra/newview/skins/default/xui/de/panel_avatar_list_item.xml
@@ -21,7 +21,7 @@
 	<string name="FormatYears">
 		[COUNT]J
 	</string>
-	<text name="avatar_name" value="Unbekannt"/>
+	<text name="avatar_name" value="(laden)"/>
 	<text name="last_interaction" value="0s"/>
 	<icon name="permission_edit_theirs_icon" tool_tip="Sie können die Objekte dieses Freunds bearbeiten"/>
 	<icon name="permission_edit_mine_icon" tool_tip="Dieser Freund kann Ihre Objekte bearbeiten, löschen und an sich nehmen"/>
diff --git a/indra/newview/skins/default/xui/de/panel_edit_alpha.xml b/indra/newview/skins/default/xui/de/panel_edit_alpha.xml
index 4b48950341771110c8840ce498248cfb9d475757..4c6facf5e33d8ca2eaffd1496c608c432fed8a28 100644
--- a/indra/newview/skins/default/xui/de/panel_edit_alpha.xml
+++ b/indra/newview/skins/default/xui/de/panel_edit_alpha.xml
@@ -1,10 +1,12 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel name="edit_alpha_panel">
-	<panel name="avatar_alpha_color_panel">
-		<texture_picker label="Alpha: Unten" name="Lower Alpha" tool_tip="Zum Auswählen eines Bildes hier klicken"/>
-		<texture_picker label="Alpha: Oben" name="Upper Alpha" tool_tip="Zum Auswählen eines Bildes hier klicken"/>
-		<texture_picker label="Kopf: Alpha" name="Head Alpha" tool_tip="Zum Auswählen eines Bildes hier klicken"/>
-		<texture_picker label="Alpha: Augen" name="Eye Alpha" tool_tip="Zum Auswählen eines Bildes hier klicken"/>
-		<texture_picker label="Alpha: Haare" name="Hair Alpha" tool_tip="Zum Auswählen eines Bildes hier klicken"/>
-	</panel>
+	<scroll_container name="avatar_alpha_color_panel_scroll">
+		<panel name="avatar_alpha_color_panel">
+			<texture_picker label="Alpha: Unten" name="Lower Alpha" tool_tip="Klicken, um ein Bild auszuwählen"/>
+			<texture_picker label="Alpha: Oben" name="Upper Alpha" tool_tip="Klicken, um ein Bild auszuwählen"/>
+			<texture_picker label="Alpha: Kopf" name="Head Alpha" tool_tip="Klicken, um ein Bild auszuwählen"/>
+			<texture_picker label="Alpha: Augen" name="Eye Alpha" tool_tip="Klicken, um ein Bild auszuwählen"/>
+			<texture_picker label="Alpha: Haare" name="Hair Alpha" tool_tip="Klicken, um ein Bild auszuwählen"/>
+		</panel>
+	</scroll_container>
 </panel>
diff --git a/indra/newview/skins/default/xui/de/panel_login.xml b/indra/newview/skins/default/xui/de/panel_login.xml
index 0fc4fa71175c8b333d432dd15342e56a2cab3020..1bee6b1ead257819e50dd818d3249d460d1ce014 100644
--- a/indra/newview/skins/default/xui/de/panel_login.xml
+++ b/indra/newview/skins/default/xui/de/panel_login.xml
@@ -11,7 +11,7 @@
 			<text name="username_text">
 				Benutzername:
 			</text>
-			<line_editor label="berndschmidt12 oder Liebe Sonne" name="username_edit" tool_tip="Bei der Registrierung gewählter Benutzername wie „berndschmidt12“ oder „Liebe Sonne“"/>
+			<combo_box name="username_combo" tool_tip="Bei der Registrierung gewählter Benutzername wie „berndschmidt12“ oder „Liebe Sonne“"/>
 			<text name="password_text">
 				Kennwort:
 			</text>
diff --git a/indra/newview/skins/default/xui/de/panel_my_profile.xml b/indra/newview/skins/default/xui/de/panel_my_profile.xml
index aea87cc2c4c5596f9238afc169bb188b0612be7f..89a4dfdabae25de398e5d4582486055035acf2d2 100644
--- a/indra/newview/skins/default/xui/de/panel_my_profile.xml
+++ b/indra/newview/skins/default/xui/de/panel_my_profile.xml
@@ -16,34 +16,27 @@
 	<string name="RegisterDateFormat">
 		[REG_DATE] ([AGE])
 	</string>
+	<string name="name_text_args">
+		[NAME]
+	</string>
+	<string name="display_name_text_args">
+		[DISPLAY_NAME]
+	</string>
 	<layout_stack name="layout">
 		<layout_panel name="profile_stack">
 			<scroll_container name="profile_scroll">
 				<panel name="scroll_content_panel">
 					<panel name="second_life_image_panel">
-						<icon label="" name="2nd_life_edit_icon" tool_tip="Klicken Sie unten auf die Schaltfläche Profil bearbeiten, um das Bild zu ändern."/>
-						<text name="title_sl_descr_text" value="[SECOND_LIFE]:"/>
-					</panel>
-					<panel name="first_life_image_panel">
-						<icon label="" name="real_world_edit_icon" tool_tip="Klicken Sie unten auf die Schaltfläche Profil bearbeiten, um das Bild zu ändern."/>
-						<text name="title_rw_descr_text" value="Echtes Leben:"/>
-					</panel>
-					<text name="title_member_text" value="Einwohner seit:"/>
-					<text name="title_acc_status_text" value="Kontostatus:"/>
-					<text_editor name="acc_status_text">
-						Einwohner. Keine Zahlungsinfo archiviert.
-              Linden.
-					</text_editor>
-					<text name="title_partner_text" value="Partner:"/>
-					<panel name="partner_data_panel">
-						<name_box initial_value="(wird in Datenbank gesucht)" name="partner_text"/>
+						<text name="display_name_descr_text">
+							Benutzername
+						</text>
+						<text name="name_descr_text">
+							Anzeigename
+						</text>
+						<button label="Profil" name="see_profile_btn" tool_tip="Profil zu diesem Avatar anzeigen"/>
 					</panel>
-					<text name="title_groups_text" value="Gruppen:"/>
 				</panel>
 			</scroll_container>
 		</layout_panel>
 	</layout_stack>
-	<panel name="profile_me_buttons_panel">
-		<button label="Profil bearbeiten" name="edit_profile_btn" tool_tip="Ihre persönlichen Informationen bearbeiten"/>
-	</panel>
 </panel>
diff --git a/indra/newview/skins/default/xui/de/panel_notify_textbox.xml b/indra/newview/skins/default/xui/de/panel_notify_textbox.xml
index 7187be570ce0e2cc3b503be99a56d28bda08b433..da672a03092b2d18b230336253b5967ae08cb47a 100644
--- a/indra/newview/skins/default/xui/de/panel_notify_textbox.xml
+++ b/indra/newview/skins/default/xui/de/panel_notify_textbox.xml
@@ -3,8 +3,9 @@
 	<string name="message_max_lines_count" value="7"/>
 	<panel label="info_panel" name="info_panel">
 		<text_editor name="message" value="message"/>
-		parse_urls=&quot;false&quot;
+	</panel>
+	<panel label="control_panel" name="control_panel">
 		<button label="Senden" name="btn_submit"/>
+		<button label="Ignorieren" name="ignore_btn"/>
 	</panel>
-	<panel label="control_panel" name="control_panel"/>
 </panel>
diff --git a/indra/newview/skins/default/xui/de/panel_preferences_colors.xml b/indra/newview/skins/default/xui/de/panel_preferences_colors.xml
index d9e5c7f2b56d1cad67231cd496d2e2ca782c8fb1..22681ffdf230b7dc6d87a7f61e88a6e4e24ba53b 100644
--- a/indra/newview/skins/default/xui/de/panel_preferences_colors.xml
+++ b/indra/newview/skins/default/xui/de/panel_preferences_colors.xml
@@ -29,10 +29,10 @@
 		URLs
 	</text>
 	<text name="bubble_chat">
-		Hintergrund für Blasen-Chat:
+		Hintergrundfarbe für Avatarnamen (wirkt sich auch auf Blasen-Chat aus):
 	</text>
-	<color_swatch name="background" tool_tip="Farbe für Blasen-Chat auswählen"/>
-	<slider label="Deckkraft:" name="bubble_chat_opacity"/>
+	<color_swatch name="background" tool_tip="Farbe für Avatarnamen auswählen"/>
+	<slider label="Deckkraft:" name="bubble_chat_opacity" tool_tip="Deckkraft für Avatarnamen auswählen"/>
 	<text name="floater_opacity">
 		Floater-Deckkraft:
 	</text>
diff --git a/indra/newview/skins/default/xui/de/panel_preferences_privacy.xml b/indra/newview/skins/default/xui/de/panel_preferences_privacy.xml
index d78064833b7a207b3de7715f74ed01fb2a54279a..b56f150394b25eb9a9d862d6f4b46f80fb5a756e 100644
--- a/indra/newview/skins/default/xui/de/panel_preferences_privacy.xml
+++ b/indra/newview/skins/default/xui/de/panel_preferences_privacy.xml
@@ -7,9 +7,11 @@
 	<text name="cache_size_label_l">
 		(Standorte, Bilder, Web, Suchverlauf)
 	</text>
+	<check_box label="In Suchergebnissen anzeigen" name="online_searchresults"/>
 	<check_box label="Nur Freunde und Gruppen wissen, dass ich online bin" name="online_visibility"/>
 	<check_box label="Nur Freunde und Gruppen können mich anrufen oder mir eine IM schicken" name="voice_call_friends_only_check"/>
 	<check_box label="Mikrofon ausschalten, wenn Anrufe beendet werden" name="auto_disengage_mic_check"/>
+	<check_box label="Meine Lieblingslandmarken bei Anmeldung anzeigen (im Dropdown-Menü „Hier anfangen“)" name="favorites_on_login_check"/>
 	<text name="Logs:">
 		Chatprotokolle:
 	</text>
diff --git a/indra/newview/skins/default/xui/de/panel_preferences_setup.xml b/indra/newview/skins/default/xui/de/panel_preferences_setup.xml
index c4d095dde5f683ef4271106c80f00a085f6db1d2..490cead17dd0fccef2ba867ff51f4ef58975f7d8 100644
--- a/indra/newview/skins/default/xui/de/panel_preferences_setup.xml
+++ b/indra/newview/skins/default/xui/de/panel_preferences_setup.xml
@@ -39,5 +39,11 @@
 	</text>
 	<line_editor name="web_proxy_editor" tool_tip="Name oder IP Adresse des Proxyservers, den Sie benutzen möchten"/>
 	<spinner label="Portnummer:" name="web_proxy_port"/>
-	<check_box initial_value="true" label="Updates für [APP_NAME] automatisch herunterladen und installieren" name="updater_service_active"/>
+	<text name="Software updates:">
+		Softwareupdates:
+	</text>
+	<combo_box name="updater_service_combobox">
+		<combo_box.item label="Automatisch installieren" name="Install_automatically"/>
+		<combo_box.item label="Updates manuell herunterladen und installieren" name="Install_manual"/>
+	</combo_box>
 </panel>
diff --git a/indra/newview/skins/default/xui/de/panel_status_bar.xml b/indra/newview/skins/default/xui/de/panel_status_bar.xml
index 005290c1ff70e914dc1d5c1c1e72b429f31ae801..04ed58f9445e736154ceab74cf5c4c8be08c2e11 100644
--- a/indra/newview/skins/default/xui/de/panel_status_bar.xml
+++ b/indra/newview/skins/default/xui/de/panel_status_bar.xml
@@ -22,7 +22,7 @@
 		[AMT] L$
 	</panel.string>
 	<panel name="balance_bg">
-		<text name="balance" tool_tip="Mein Kontostand" value="20 L$"/>
+		<text name="balance" tool_tip="Klicken, um L$-Guthaben zu aktualisieren" value="20 L$"/>
 		<button label="L$ kaufen" name="buyL" tool_tip="Hier klicken, um mehr L$ zu kaufen"/>
 	</panel>
 	<text name="TimeText" tool_tip="Aktuelle Zeit (Pazifik)">
diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml
index e70e1eb61b3a05db9c45570b418838b72f10e048..1808fea44541ec42ab88fe791c2be08e010ad6fd 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -872,12 +872,13 @@
              length="1"
              follows="left|top"
              left_pad="0"
-             height="30"
+             height="20"
              layout="topleft"
              name="Creator Name"
              top_delta="0"
              width="190"
-             word_wrap="true">
+             word_wrap="true"
+             use_ellipses="ture">
                 Mrs. Esbee Linden (esbee.linden)
             </text>
             <text
@@ -888,7 +889,7 @@
              height="19"
              layout="topleft"
              name="Owner:"
-             top_pad="3"
+             top_pad="13"
              width="90">
                 Owner:
             </text>
@@ -897,13 +898,14 @@
              type="string"
              length="1"
              follows="left|top"
-             height="30"
+             height="20"
              layout="topleft"
              name="Owner Name"
              left_pad="0"
              top_delta="0"
              width="190"
-             word_wrap="true">
+             word_wrap="true"
+             use_ellipses="true">
                 Mrs. Erica "Moose" Linden (erica.linden)
             </text>
            <text
@@ -914,7 +916,7 @@
              left="10"
              height="18"
              name="Group:"
-             top_pad="7"
+             top_pad="17"
              width="75">
                 Group:
             </text>
diff --git a/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml b/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml
index 6f46165883e4ac868caec8df4b2c280a480d99d4..1aeb166e01570aaccb4ead89d93c7a887e3a4cad 100644
--- a/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml
+++ b/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml
@@ -25,6 +25,14 @@
          function="Places.LandmarksGear.Enable"
          parameter="category" />
     </menu_item_call>
+    <menu_item_call
+     label="Restore Item"
+     layout="topleft"
+     name="restore_item">
+        <menu_item_call.on_click
+         function="Places.LandmarksGear.Custom.Action"
+         parameter="restore" />
+    </menu_item_call>
     <menu_item_separator
      layout="topleft" />
     <menu_item_call
diff --git a/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml b/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml
index 121e7cc07ac23761271bf7cae52f205501bc3561..ff5fdd3795322d5c3582f0b7ff7d73b3240c6d29 100644
--- a/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml
+++ b/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml
@@ -60,6 +60,14 @@
          function="Places.LandmarksGear.Enable"
          parameter="category" />
     </menu_item_call>
+    <menu_item_call
+     label="Restore Item"
+     layout="topleft"
+     name="restore_item">
+        <menu_item_call.on_click
+         function="Places.LandmarksGear.Custom.Action"
+         parameter="restore" />
+    </menu_item_call>
     <menu_item_separator
      layout="topleft" />
     <menu_item_call
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index 2207e418c8dff036b8e58a3823378bb4cd10abd8..c2735c85e47fc5249f1c5d12f9c29870f1a3e7eb 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -1959,6 +1959,16 @@
                 <menu_item_check.on_click
                  function="ToggleControl"
                  parameter="DebugShowRenderInfo" />
+            </menu_item_check>
+			<menu_item_check
+             label="Show Texture Info"
+             name="Show Texture Info">
+                <menu_item_check.on_check
+                 function="CheckControl"
+                 parameter="DebugShowTextureInfo" />
+                <menu_item_check.on_click
+                 function="ToggleControl"
+                 parameter="DebugShowTextureInfo" />
             </menu_item_check>
             <menu_item_check
              label="Show Matrices"
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index 6f21938bdb0fd21f9543cec2305f3cfdebce4948..f008042a81c4e7d3edb0d355a9440ddf7ba83849 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -6303,15 +6303,6 @@ An error has occurred while trying to connect to voice chat for [VOICE_CHANNEL_N
     </unique>
   </notification>
 
-  <notification
-   duration="10"
-   icon="notifytip.tga"
-   name="ServerVersionChanged"
-   priority="high"
-   type="notifytip">
-You just entered a region using a different server version, which may affect performance. [[URL] View the release notes.]
-  </notification>
-
   <notification
    icon="notifytip.tga"
    name="UnsupportedCommandSLURL"
diff --git a/indra/newview/skins/default/xui/en/panel_nearby_media.xml b/indra/newview/skins/default/xui/en/panel_nearby_media.xml
index 8c13ced8f39809db5747d939de65726529ad3824..9bd60b935f6cc49bba64da11999617736b3feb4c 100644
--- a/indra/newview/skins/default/xui/en/panel_nearby_media.xml
+++ b/indra/newview/skins/default/xui/en/panel_nearby_media.xml
@@ -68,24 +68,12 @@
 		right="-8"
 		width="66"
 		height="22"
+		is_toggle="true"
 		label="More &gt;&gt;"
-		label_selected="Less &lt;&lt;">
+		label_selected="&lt;&lt; Less">
 	  <button.commit_callback
 		  function="MediaListCtrl.MoreLess" />
 	</button>
-  <button
-		name="less_btn"
-		follows="right"
-		tool_tip="Advanced Controls"
-		top_delta="0"
-		right="-8"
-		width="66"
-		height="22"
-		label="More &gt;&gt;"
-		label_selected="Less &lt;&lt;">
-      <button.commit_callback
-        function="MediaListCtrl.MoreLess" />
-  </button>
   </panel>
   <panel
 	  name="nearby_media_panel"
diff --git a/indra/newview/skins/default/xui/es/floater_web_content.xml b/indra/newview/skins/default/xui/es/floater_web_content.xml
new file mode 100644
index 0000000000000000000000000000000000000000..5e02fad2dd9ef84fd13a42f9fbaae6ac98252604
--- /dev/null
+++ b/indra/newview/skins/default/xui/es/floater_web_content.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<floater name="floater_web_content" title="">
+	<layout_stack name="stack1">
+		<layout_panel name="nav_controls">
+			<button name="back" tool_tip="Navegar hacia atrás"/>
+			<button name="forward" tool_tip="Navegar hacia adelante"/>
+			<button name="stop" tool_tip="Detener la navegación"/>
+			<button name="reload" tool_tip="Recargar página"/>
+			<combo_box name="address" tool_tip="Introducir URL aquí"/>
+			<icon name="media_secure_lock_flag" tool_tip="Navegación segura"/>
+			<button name="popexternal" tool_tip="Abrir URL actual en tu navegador de escritorio"/>
+		</layout_panel>
+	</layout_stack>
+</floater>
diff --git a/indra/newview/skins/default/xui/es/menu_login.xml b/indra/newview/skins/default/xui/es/menu_login.xml
index 5386f82ee5e8302d79cad0e193c9c39f14faab7f..c27d6247324206eca98b8f563d0203df1213653f 100644
--- a/indra/newview/skins/default/xui/es/menu_login.xml
+++ b/indra/newview/skins/default/xui/es/menu_login.xml
@@ -16,7 +16,8 @@
 		<menu_item_call label="Definir el tamaño de la ventana..." name="Set Window Size..."/>
 		<menu_item_call label="Mostrar los &apos;TOS&apos;" name="TOS"/>
 		<menu_item_call label="Mostrar mensaje crítico" name="Critical"/>
-		<menu_item_call label="Web Browser Test" name="Web Browser Test"/>
+		<menu_item_call label="Prueba de navegadores de medios" name="Web Browser Test"/>
+		<menu_item_call label="Prueba de ventanas de contenidos web" name="Web Content Floater Test"/>
 		<menu_item_check label="Mostrar el selector de Grid" name="Show Grid Picker"/>
 		<menu_item_call label="Mostrar la consola de notificaciones" name="Show Notifications Console"/>
 	</menu>
diff --git a/indra/newview/skins/default/xui/es/menu_mini_map.xml b/indra/newview/skins/default/xui/es/menu_mini_map.xml
index 41dc817551e8671f4316bfc1223a9c786c3774bd..07d1b08572936f0409098abbf2c2c9646c8648b6 100644
--- a/indra/newview/skins/default/xui/es/menu_mini_map.xml
+++ b/indra/newview/skins/default/xui/es/menu_mini_map.xml
@@ -3,6 +3,7 @@
 	<menu_item_call label="Zoom cerca" name="Zoom Close"/>
 	<menu_item_call label="Zoom medio" name="Zoom Medium"/>
 	<menu_item_call label="Zoom lejos" name="Zoom Far"/>
+	<menu_item_call label="Zoom por defecto" name="Zoom Default"/>
 	<menu_item_check label="Girar el mapa" name="Rotate Map"/>
 	<menu_item_check label="Centrar automáticamente" name="Auto Center"/>
 	<menu_item_call label="Parar la búsqueda" name="Stop Tracking"/>
diff --git a/indra/newview/skins/default/xui/es/menu_viewer.xml b/indra/newview/skins/default/xui/es/menu_viewer.xml
index 3dd940c331f78359af4048cdb43398bc2f2ef4c0..2fe7db10418ca00d0eb3c0ab5f0ab8b514239f34 100644
--- a/indra/newview/skins/default/xui/es/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/es/menu_viewer.xml
@@ -121,13 +121,15 @@
 			<menu_item_call label="Animación ([COST] L$)..." name="Upload Animation"/>
 			<menu_item_call label="Masivo ([COST] L$ por archivo)..." name="Bulk Upload"/>
 		</menu>
+		<menu_item_call label="Deshacer" name="Undo"/>
+		<menu_item_call label="Rehacer" name="Redo"/>
 	</menu>
 	<menu label="Ayuda" name="Help">
 		<menu_item_call label="Ayuda de [SECOND_LIFE]" name="Second Life Help"/>
+		<menu_item_check label="Permitir consejos" name="Enable Hints"/>
 		<menu_item_call label="Denunciar una infracción" name="Report Abuse"/>
 		<menu_item_call label="Informar de un fallo" name="Report Bug"/>
 		<menu_item_call label="Acerca de [APP_NAME]" name="About Second Life"/>
-		<menu_item_check label="Permitir consejos" name="Enable Hints"/>
 	</menu>
 	<menu label="Avanzado" name="Advanced">
 		<menu_item_call label="Recargar las texturas" name="Rebake Texture"/>
@@ -268,7 +270,8 @@
 			<menu_item_call label="Dump Region Object Cache" name="Dump Region Object Cache"/>
 		</menu>
 		<menu label="UI" name="UI">
-			<menu_item_call label="Web Browser Test" name="Web Browser Test"/>
+			<menu_item_call label="Prueba de navegadores de medios" name="Web Browser Test"/>
+			<menu_item_call label="Navegador de contenido web" name="Web Content Browser"/>
 			<menu_item_call label="Print Selected Object Info" name="Print Selected Object Info"/>
 			<menu_item_call label="Memory Stats" name="Memory Stats"/>
 			<menu_item_check label="Consola de depuración de región" name="Region Debug Console"/>
diff --git a/indra/newview/skins/default/xui/es/notifications.xml b/indra/newview/skins/default/xui/es/notifications.xml
index 14ce39e8fc673c493d4442ebe5cc79db4bf06be5..2bf36bb763fc00afdab6a8cc890bd4cc1d6a5142 100644
--- a/indra/newview/skins/default/xui/es/notifications.xml
+++ b/indra/newview/skins/default/xui/es/notifications.xml
@@ -108,6 +108,10 @@ Asegúrate de que tu conexión a Internet está funcionando adecuadamente.
 		Quienes no sean tus amigos no sabrán que has elegido ignorar sus llamadas y mensajes instantáneos.
 		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
+	<notification name="FavoritesOnLogin">
+		Nota: Al activar esta opción, cualquiera que utilice este ordenador podrá ver tu lista de lugares favoritos.
+		<usetemplate name="okbutton" yestext="OK"/>
+	</notification>
 	<notification name="GrantModifyRights">
 		Al conceder permisos de modificación a otro Residente, le estás permitiendo cambiar, borrar o tomar CUALQUIER objeto que tengas en el mundo. Sé MUY cuidadoso al conceder este permiso.
 ¿Quieres conceder permisos de modificación a [NAME]?
@@ -946,7 +950,7 @@ no tienes el permiso de comprar terreno para el grupo que tienes activado actual
 			<input name="message">
 				[DESC] (nuevo)
 			</input>
-			<button name="Offer" text="OK"/>
+			<button name="OK" text="OK"/>
 			<button name="Cancel" text="Cancelar"/>
 		</form>
 	</notification>
@@ -956,7 +960,7 @@ no tienes el permiso de comprar terreno para el grupo que tienes activado actual
 			<input name="message">
 				[DESC] (nuevo)
 			</input>
-			<button name="Offer" text="OK"/>
+			<button name="OK" text="OK"/>
 			<button name="Cancel" text="Cancelar"/>
 		</form>
 	</notification>
@@ -966,7 +970,7 @@ no tienes el permiso de comprar terreno para el grupo que tienes activado actual
 			<input name="new_name">
 				[NAME]
 			</input>
-			<button name="Offer" text="OK"/>
+			<button name="OK" text="OK"/>
 			<button name="Cancel" text="Cancelar"/>
 		</form>
 	</notification>
@@ -1347,9 +1351,41 @@ Descarga e instala el último visor a través de
 http://secondlife.com/download.
 		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
-	<notification name="DownloadBackground">
-		Se ha descargado una versión actualizada de [APP_NAME].
-Se aplicará la próxima vez que reinicies [APP_NAME]
+	<notification name="FailedRequiredUpdateInstall">
+		No hemos podido instalar una actualización necesaria. 
+No podrás iniciar sesión hasta que [APP_NAME] se haya actualizado.
+
+Descarga e instala el último visor a través de
+http://secondlife.com/download.
+		<usetemplate name="okbutton" yestext="Salir"/>
+	</notification>
+	<notification name="UpdaterServiceNotRunning">
+		Hay una actualización necesaria para la instalación de Second Life.
+
+Puedes descargar esta actualización de http://www.secondlife.com/downloads
+o instalarla ahora.
+		<usetemplate name="okcancelbuttons" notext="Salir de Second Life" yestext="Descargar e instalar ahora"/>
+	</notification>
+	<notification name="DownloadBackgroundTip">
+		Hemos descargado una actualización para la instalación de [APP_NAME].
+Versión [VERSION] [[RELEASE_NOTES_FULL_URL]; información acerca de esta actualización]
+		<usetemplate name="okcancelbuttons" notext="Más tarde..." yestext="Instalar ahora y reiniciar [NOMBRE_APL]"/>
+	</notification>
+	<notification name="DownloadBackgroundDialog">
+		Hemos descargado una actualización para la instalación de [APP_NAME].
+Versión [VERSION] [[RELEASE_NOTES_FULL_URL]; información acerca de esta actualización]
+		<usetemplate name="okcancelbuttons" notext="Más tarde..." yestext="Instalar ahora y reiniciar [APP_NAME]"/>
+	</notification>
+	<notification name="RequiredUpdateDownloadedVerboseDialog">
+		Hemos descargado una actualización de software necesaria.
+Versión [VERSION]
+
+Debemos reiniciar [APP_NAME] para instalar la actualización.
+		<usetemplate name="okbutton" yestext="OK"/>
+	</notification>
+	<notification name="RequiredUpdateDownloadedDialog">
+		Debemos reiniciar [APP_NAME] para instalar la actualización.
+		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="DeedObjectToGroup">
 		Transferir este objeto al grupo hará que:
@@ -2217,14 +2253,6 @@ Inténtalo seleccionando un trozo más pequeño de terreno.
 	<notification name="NoContentToSearch">
 		Por favor, elige al menos un tipo de contenido a buscar (&apos;PG&apos;, &apos;Mature&apos;, o &apos;Adult&apos;).
 	</notification>
-	<notification name="GroupVote">
-		[NAME] ha propuesto votar:
-[MESSAGE]
-		<form name="form">
-			<button name="VoteNow" text="Votar ahora"/>
-			<button name="Later" text="Más tarde"/>
-		</form>
-	</notification>
 	<notification name="SystemMessage">
 		[MESSAGE]
 	</notification>
@@ -2678,9 +2706,6 @@ Pulsa Aceptar o Rehusar para coger o no la llamada. Pulsa Ignorar para ignorar a
 	<notification name="VoiceCallGenericError">
 		Se ha producido un error al intentar conectarte al [VOICE_CHANNEL_NAME]. Por favor, inténtalo más tarde.
 	</notification>
-	<notification name="ServerVersionChanged">
-		Acabas de entrar en una región que usa un servidor con una versión distinta, y esto puede influir en el funcionamiento. [[URL] Ver las notas de desarrollo].
-	</notification>
 	<notification name="UnsupportedCommandSLURL">
 		No se admite el formato de la SLurl que has pulsado.
 	</notification>
@@ -2783,9 +2808,7 @@ El avatar &apos;[NAME]&apos; desactivó el modo de apariencia.
 	<notification name="NoConnect">
 		Tenemos problemas de conexión con [PROTOCOL] [HOSTID].
 Comprueba la configuración de la red y del servidor de seguridad.
-		<form name="form">
-			<button name="OK" text="OK"/>
-		</form>
+		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="NoVoiceConnect">
 		Tenemos problemas de conexión con tu servidor de voz:
@@ -2794,9 +2817,7 @@ Comprueba la configuración de la red y del servidor de seguridad.
 
 No podrás establecer comunicaciones de voz.
 Comprueba la configuración de la red y del servidor de seguridad.
-		<form name="form">
-			<button name="OK" text="OK"/>
-		</form>
+		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="AvatarRezLeftNotification">
 		( [EXISTENCE] segundos vivo)
@@ -2830,6 +2851,9 @@ Si lo haces, todos los residentes que se unan posteriormente a la llamada tambi
 	<notification label="Explora el mundo" name="HintDestinationGuide">
 		La Guía de destinos contiene miles de nuevos lugares por descubrir. Selecciona una ubicación y elige Teleportarme para iniciar la exploración.
 	</notification>
+	<notification label="Cambiar de apariencia" name="HintAvatarPicker">
+		¿Te gustaría cambiar de apariencia? Haz clic en el botón que aparece a continuación para ver más avatares.
+	</notification>
 	<notification label="Panel lateral" name="HintSidePanel">
 		Accede de manera rápida a tu inventario, así como a tu ropa, los perfiles y el resto de la información disponible en el panel lateral.
 	</notification>
@@ -2839,6 +2863,12 @@ Si lo haces, todos los residentes que se unan posteriormente a la llamada tambi
 	<notification label="Nombre mostrado" name="HintDisplayName">
 		Configura y personaliza aquí tu nombre mostrado. Esto se añadirá a tu nombre de usuario personal, que no puedes modificar. Puedes cambiar la manera en que ves los nombres de otras personas en tus preferencias.
 	</notification>
+	<notification label="Mover" name="HintMoveArrows">
+		Para caminar, utiliza las flechas de dirección del teclado. Para correr, pulsa dos veces la flecha hacia arriba.
+	</notification>
+	<notification label="Visión" name="HintView">
+		Para cambiar la vista de la cámara, utiliza los controles Orbital y Panorámica. Para restablecer tu vista, pulsa Esc o camina.
+	</notification>
 	<notification label="Inventario" name="HintInventory">
 		Accede a tu inventario para buscar ítems. Los ítems más recientes se pueden encontrar fácilmente en la pestaña Recientes.
 	</notification>
@@ -2852,6 +2882,15 @@ Si lo haces, todos los residentes que se unan posteriormente a la llamada tambi
 			<button name="open" text="Abrir ventana emergente"/>
 		</form>
 	</notification>
+	<notification name="AuthRequest">
+		El sitio en &apos;&lt;nolink&gt;[HOST_NAME]&lt;/nolink&gt;&apos; de la plataforma &apos;[REALM]&apos; requiere un nombre de usuario y una contraseña.
+		<form name="form">
+			<input name="username" text="Nombre de usuario"/>
+			<input name="password" text="Contraseña"/>
+			<button name="ok" text="Enviar"/>
+			<button name="cancel" text="Cancelar"/>
+		</form>
+	</notification>
 	<global name="UnsupportedCPU">
 		- La velocidad de tu CPU no cumple los requerimientos mínimos.
 	</global>
diff --git a/indra/newview/skins/default/xui/es/panel_avatar_list_item.xml b/indra/newview/skins/default/xui/es/panel_avatar_list_item.xml
index 09221c5599b211fcd9a80cccc419f55b1b3d9372..5220df5d21bed9b0c57510db2ba74ab7fe329eca 100644
--- a/indra/newview/skins/default/xui/es/panel_avatar_list_item.xml
+++ b/indra/newview/skins/default/xui/es/panel_avatar_list_item.xml
@@ -21,7 +21,7 @@
 	<string name="FormatYears">
 		[COUNT] año/s
 	</string>
-	<text name="avatar_name" value="Desconocido"/>
+	<text name="avatar_name" value="(cargando...)"/>
 	<icon name="permission_edit_theirs_icon" tool_tip="Puedes editar los objetos de este amigo"/>
 	<icon name="permission_edit_mine_icon" tool_tip="Este amigo puede editar, eliminar o manipular tus objetos"/>
 	<icon name="permission_map_icon" tool_tip="Este amigo puede encontrarte en el mapa"/>
diff --git a/indra/newview/skins/default/xui/es/panel_edit_alpha.xml b/indra/newview/skins/default/xui/es/panel_edit_alpha.xml
index 3f238da9d007fec1227d9369974ce117764fe834..829c206ae121fd4ed9f910cc3ea2528764caab03 100644
--- a/indra/newview/skins/default/xui/es/panel_edit_alpha.xml
+++ b/indra/newview/skins/default/xui/es/panel_edit_alpha.xml
@@ -1,10 +1,12 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel name="edit_alpha_panel">
-	<panel name="avatar_alpha_color_panel">
-		<texture_picker label="Alfa inferior" name="Lower Alpha" tool_tip="Pulsa para elegir una imagen"/>
-		<texture_picker label="Alfa superior" name="Upper Alpha" tool_tip="Pulsa para elegir una imagen"/>
-		<texture_picker label="Alfa de la cabeza" name="Head Alpha" tool_tip="Pulsa para elegir una imagen"/>
-		<texture_picker label="Alfa de los ojos" name="Eye Alpha" tool_tip="Pulsa para elegir una imagen"/>
-		<texture_picker label="Alfa del pelo" name="Hair Alpha" tool_tip="Pulsa para elegir una imagen"/>
-	</panel>
+	<scroll_container name="avatar_alpha_color_panel_scroll">
+		<panel name="avatar_alpha_color_panel">
+			<texture_picker label="Alfa inferior" name="Lower Alpha" tool_tip="Pulsa para elegir una imagen"/>
+			<texture_picker label="Alfa superior" name="Upper Alpha" tool_tip="Pulsa para elegir una imagen"/>
+			<texture_picker label="Alfa de la cabeza" name="Head Alpha" tool_tip="Pulsa para elegir una imagen"/>
+			<texture_picker label="Alfa de los ojos" name="Eye Alpha" tool_tip="Pulsa para elegir una imagen"/>
+			<texture_picker label="Alfa del pelo" name="Hair Alpha" tool_tip="Pulsa para elegir una imagen"/>
+		</panel>
+	</scroll_container>
 </panel>
diff --git a/indra/newview/skins/default/xui/es/panel_login.xml b/indra/newview/skins/default/xui/es/panel_login.xml
index 49d4881737bbd78ba52ccd47278c089570ed0e35..ada964f33efc2f1432957824f9ba82b48180ac04 100644
--- a/indra/newview/skins/default/xui/es/panel_login.xml
+++ b/indra/newview/skins/default/xui/es/panel_login.xml
@@ -11,7 +11,7 @@
 			<text name="username_text">
 				Nombre de usuario:
 			</text>
-			<line_editor label="bobsmith12 o Steller Sunshine" name="username_edit" tool_tip="El nombre de usuario que elegiste al registrarte, como bobsmith12 o Steller Sunshine"/>
+			<combo_box name="username_combo" tool_tip="El nombre de usuario que elegiste al registrarte, como bobsmith12 o Steller Sunshine"/>
 			<text name="password_text">
 				Contraseña:
 			</text>
diff --git a/indra/newview/skins/default/xui/es/panel_my_profile.xml b/indra/newview/skins/default/xui/es/panel_my_profile.xml
index 14c94acf5b4db093fc1122b627e0a9ebe3df6e11..29e5e6f652ed19642c33946b2bb725a4c03e86bb 100644
--- a/indra/newview/skins/default/xui/es/panel_my_profile.xml
+++ b/indra/newview/skins/default/xui/es/panel_my_profile.xml
@@ -5,30 +5,27 @@
 	<string name="RegisterDateFormat">
 		[REG_DATE] ([AGE])
 	</string>
+	<string name="name_text_args">
+		[NAME]
+	</string>
+	<string name="display_name_text_args">
+		[DISPLAY_NAME]
+	</string>
 	<layout_stack name="layout">
 		<layout_panel name="profile_stack">
 			<scroll_container name="profile_scroll">
 				<panel name="scroll_content_panel">
 					<panel name="second_life_image_panel">
-						<icon label="" name="2nd_life_edit_icon" tool_tip="Pulsa el botón Editar el perfil para cambiar la imagen"/>
-						<text name="title_sl_descr_text" value="[SECOND_LIFE]:"/>
-					</panel>
-					<panel name="first_life_image_panel">
-						<icon label="" name="real_world_edit_icon" tool_tip="Pulsa el botón Editar el perfil para cambiar la imagen"/>
-						<text name="title_rw_descr_text" value="Mundo real:"/>
-					</panel>
-					<text name="title_member_text" value="Residente desde:"/>
-					<text name="title_acc_status_text" value="Estado de la cuenta:"/>
-					<text name="title_partner_text" value="Compañero/a:"/>
-					<panel name="partner_data_panel">
-						<name_box initial_value="(obteniendo)" name="partner_text"/>
+						<text name="display_name_descr_text">
+							Nombre de usuario
+						</text>
+						<text name="name_descr_text">
+							Nombre mostrado
+						</text>
+						<button label="Perfil" name="see_profile_btn" tool_tip="Ver el perfil de este avatar"/>
 					</panel>
-					<text name="title_groups_text" value="Grupos:"/>
 				</panel>
 			</scroll_container>
 		</layout_panel>
 	</layout_stack>
-	<panel name="profile_me_buttons_panel">
-		<button label="Editar el perfil" name="edit_profile_btn" tool_tip="Modificar tu información personal"/>
-	</panel>
 </panel>
diff --git a/indra/newview/skins/default/xui/es/panel_notify_textbox.xml b/indra/newview/skins/default/xui/es/panel_notify_textbox.xml
index 10aaa288d7db99e3e767b5e017d2f18096e94b25..dc7c873303c5a9db7e71c395f755a5999720448b 100644
--- a/indra/newview/skins/default/xui/es/panel_notify_textbox.xml
+++ b/indra/newview/skins/default/xui/es/panel_notify_textbox.xml
@@ -3,8 +3,9 @@
 	<string name="message_max_lines_count" value="7"/>
 	<panel label="info_panel" name="info_panel">
 		<text_editor name="message" value="message"/>
-		parse_urls=&quot;false&quot;
+	</panel>
+	<panel label="control_panel" name="control_panel">
 		<button label="Enviar" name="btn_submit"/>
+		<button label="Ignorar" name="ignore_btn"/>
 	</panel>
-	<panel label="control_panel" name="control_panel"/>
 </panel>
diff --git a/indra/newview/skins/default/xui/es/panel_preferences_colors.xml b/indra/newview/skins/default/xui/es/panel_preferences_colors.xml
index 4fa5c4ce635d8f89327a7187e050ee32f97afd13..edd417d564463ddcd4e2b967c3a75b3e42d0e883 100644
--- a/indra/newview/skins/default/xui/es/panel_preferences_colors.xml
+++ b/indra/newview/skins/default/xui/es/panel_preferences_colors.xml
@@ -29,10 +29,10 @@
 		URL
 	</text>
 	<text name="bubble_chat">
-		Fondo de los bocadillos del chat:
+		Color de fondo de la etiqueta del nombre (afectará también a los bocadillos del chat):
 	</text>
-	<color_swatch name="background" tool_tip="Elegir el color de los bocadillos del chat"/>
-	<slider label="Opacidad:" name="bubble_chat_opacity"/>
+	<color_swatch name="background" tool_tip="Seleccionar el color de la etiqueta del nombre"/>
+	<slider label="Opacidad:" name="bubble_chat_opacity" tool_tip="Seleccionar opacidad de la etiqueta del nombre"/>
 	<text name="floater_opacity">
 		Opacidad de la ventana:
 	</text>
diff --git a/indra/newview/skins/default/xui/es/panel_preferences_privacy.xml b/indra/newview/skins/default/xui/es/panel_preferences_privacy.xml
index abff72c346c1c516bda3aa2e63f7dfe635da7f2f..5eaa345c988e2e1df63878b5895486f8ae3803ad 100644
--- a/indra/newview/skins/default/xui/es/panel_preferences_privacy.xml
+++ b/indra/newview/skins/default/xui/es/panel_preferences_privacy.xml
@@ -7,9 +7,11 @@
 	<text name="cache_size_label_l">
 		(Localizaciones, imágenes, web, historial de búsqueda)
 	</text>
+	<check_box label="Mostrarme en los resultados de la búsqueda" name="online_searchresults"/>
 	<check_box label="Sólo saben si estoy conectado mis amigos y grupos" name="online_visibility"/>
 	<check_box label="Sólo pueden llamarme o mandarme un MI mis amigos y grupos" name="voice_call_friends_only_check"/>
 	<check_box label="Desconectar el micrófono cuando finalicen las llamadas" name="auto_disengage_mic_check"/>
+	<check_box label="Mostrar mis Hitos favoritos en Inicio de sesión (mediante el menú desplegable &quot;Empezar en&quot;)" name="favorites_on_login_check"/>
 	<text name="Logs:">
 		Registros de chat:
 	</text>
diff --git a/indra/newview/skins/default/xui/es/panel_preferences_setup.xml b/indra/newview/skins/default/xui/es/panel_preferences_setup.xml
index f968f489100c38a954d48ac6755257a0bf68db0b..68484645b7ed917043b7f9e09bde7dde8f2042b8 100644
--- a/indra/newview/skins/default/xui/es/panel_preferences_setup.xml
+++ b/indra/newview/skins/default/xui/es/panel_preferences_setup.xml
@@ -39,5 +39,11 @@
 	</text>
 	<line_editor name="web_proxy_editor" tool_tip="Nombre o dirección IP del proxy que quieres usar"/>
 	<spinner label="Nº del puerto:" name="web_proxy_port"/>
-	<check_box initial_value="verdadero" label="Descargar e instalar automáticamente actualizaciones de [APP_NAME]" name="updater_service_active"/>
+	<text name="Software updates:">
+		Actualizaciones de software:
+	</text>
+	<combo_box name="updater_service_combobox">
+		<combo_box.item label="Instalar automáticamente" name="Install_automatically"/>
+		<combo_box.item label="Descargar e instalar actualizaciones manualmente" name="Install_manual"/>
+	</combo_box>
 </panel>
diff --git a/indra/newview/skins/default/xui/es/panel_status_bar.xml b/indra/newview/skins/default/xui/es/panel_status_bar.xml
index 13ed1acf0b4dda5d861d461475e2f70cd15d9d57..ab76d3f994a4e0bdbb9e57769699d13d85c809f7 100644
--- a/indra/newview/skins/default/xui/es/panel_status_bar.xml
+++ b/indra/newview/skins/default/xui/es/panel_status_bar.xml
@@ -22,7 +22,7 @@
 		[AMT] L$
 	</panel.string>
 	<panel name="balance_bg">
-		<text name="balance" tool_tip="Mi saldo" value="20 L$"/>
+		<text name="balance" tool_tip="Haz clic para actualizar tu saldo en L$" value="20 L$"/>
 		<button label="COMPRAR L$" name="buyL" tool_tip="Pulsa para comprar más L$"/>
 	</panel>
 	<text name="TimeText" tool_tip="Hora actual (Pacífico)">
diff --git a/indra/newview/skins/default/xui/fr/floater_web_content.xml b/indra/newview/skins/default/xui/fr/floater_web_content.xml
new file mode 100644
index 0000000000000000000000000000000000000000..65dfafe760340f0ab2f71dc9df544bdcd1192168
--- /dev/null
+++ b/indra/newview/skins/default/xui/fr/floater_web_content.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<floater name="floater_web_content" title="">
+	<layout_stack name="stack1">
+		<layout_panel name="nav_controls">
+			<button name="back" tool_tip="Précédente"/>
+			<button name="forward" tool_tip="Suivante"/>
+			<button name="stop" tool_tip="Arrêt de la navigation"/>
+			<button name="reload" tool_tip="Recharger la page"/>
+			<combo_box name="address" tool_tip="Entrer une URL ici"/>
+			<icon name="media_secure_lock_flag" tool_tip="Navigation sécurisée"/>
+			<button name="popexternal" tool_tip="Ouvrir l&apos;URL actuelle dans votre navigateur de bureau"/>
+		</layout_panel>
+	</layout_stack>
+</floater>
diff --git a/indra/newview/skins/default/xui/fr/menu_login.xml b/indra/newview/skins/default/xui/fr/menu_login.xml
index b712c008cdd05d1e3e82a96ba8adb1755a36b459..400c77e51a5746e102d3cd07295a9bfae67e1be4 100644
--- a/indra/newview/skins/default/xui/fr/menu_login.xml
+++ b/indra/newview/skins/default/xui/fr/menu_login.xml
@@ -17,7 +17,8 @@
 		<menu_item_call label="Définir la taille de la fenêtre..." name="Set Window Size..."/>
 		<menu_item_call label="Afficher les conditions d&apos;utilisation" name="TOS"/>
 		<menu_item_call label="Afficher le message critique" name="Critical"/>
-		<menu_item_call label="Test du navigateur Web" name="Web Browser Test"/>
+		<menu_item_call label="Test du navigateur de médias" name="Web Browser Test"/>
+		<menu_item_call label="Test de la fenêtre flottante du contenu Web" name="Web Content Floater Test"/>
 		<menu_item_check label="Afficher le sélecteur de grille" name="Show Grid Picker"/>
 		<menu_item_call label="Afficher la console des notifications" name="Show Notifications Console"/>
 	</menu>
diff --git a/indra/newview/skins/default/xui/fr/menu_mini_map.xml b/indra/newview/skins/default/xui/fr/menu_mini_map.xml
index 7530f31d4ebed9e179f71879142807c122021a4a..b9d0a70383efa6577d6ff7a53b62561d804f9a59 100644
--- a/indra/newview/skins/default/xui/fr/menu_mini_map.xml
+++ b/indra/newview/skins/default/xui/fr/menu_mini_map.xml
@@ -3,6 +3,7 @@
 	<menu_item_call label="Zoom rapproché" name="Zoom Close"/>
 	<menu_item_call label="Zoom moyen" name="Zoom Medium"/>
 	<menu_item_call label="Zoom éloigné" name="Zoom Far"/>
+	<menu_item_call label="Zoom par défaut" name="Zoom Default"/>
 	<menu_item_check label="Faire pivoter la carte" name="Rotate Map"/>
 	<menu_item_check label="Centrage auto" name="Auto Center"/>
 	<menu_item_call label="Arrêter de suivre" name="Stop Tracking"/>
diff --git a/indra/newview/skins/default/xui/fr/menu_viewer.xml b/indra/newview/skins/default/xui/fr/menu_viewer.xml
index fb4ab314afed3a025b01fb7dbe076b02d75e84f3..65a00c2e6c61d56e38ccc0176562d88dd8aabed1 100644
--- a/indra/newview/skins/default/xui/fr/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/fr/menu_viewer.xml
@@ -121,13 +121,15 @@
 			<menu_item_call label="Animation ([COST] L$)..." name="Upload Animation"/>
 			<menu_item_call label="Lot ([COST] L$ par fichier)..." name="Bulk Upload"/>
 		</menu>
+		<menu_item_call label="Annuler" name="Undo"/>
+		<menu_item_call label="Refaire" name="Redo"/>
 	</menu>
 	<menu label="Aide" name="Help">
 		<menu_item_call label="Aide de [SECOND_LIFE]" name="Second Life Help"/>
+		<menu_item_check label="Activer les astuces" name="Enable Hints"/>
 		<menu_item_call label="Signaler une infraction" name="Report Abuse"/>
 		<menu_item_call label="Signaler un bug" name="Report Bug"/>
 		<menu_item_call label="À propos de [APP_NAME]" name="About Second Life"/>
-		<menu_item_check label="Activer les astuces" name="Enable Hints"/>
 	</menu>
 	<menu label="Avancé" name="Advanced">
 		<menu_item_call label="Refixer les textures" name="Rebake Texture"/>
@@ -307,7 +309,8 @@
 			<menu_item_call label="Dump Region Object Cache" name="Dump Region Object Cache"/>
 		</menu>
 		<menu label="Interface" name="UI">
-			<menu_item_call label="Test du navigateur Web" name="Web Browser Test"/>
+			<menu_item_call label="Test du navigateur de médias" name="Web Browser Test"/>
+			<menu_item_call label="Navigateur du contenu Web" name="Web Content Browser"/>
 			<menu_item_call label="Dump SelectMgr" name="Dump SelectMgr"/>
 			<menu_item_call label="Dump inventaire" name="Dump Inventory"/>
 			<menu_item_call label="Dump Timers" name="Dump Timers"/>
diff --git a/indra/newview/skins/default/xui/fr/notifications.xml b/indra/newview/skins/default/xui/fr/notifications.xml
index f0b0e63af0079ca4bac7786f1bdf29268a68901b..603b8f0edcd3ba16d839480d95b114626abb609c 100644
--- a/indra/newview/skins/default/xui/fr/notifications.xml
+++ b/indra/newview/skins/default/xui/fr/notifications.xml
@@ -109,6 +109,10 @@ Veuillez ne sélectionner qu&apos;un seul objet.
 		Les résidents qui ne sont pas vos amis ne sauront pas que vous avez choisi d&apos;ignorer leurs appels et leurs messages instantanés.
 		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
+	<notification name="FavoritesOnLogin">
+		Remarque : si vous activez cette option, toutes les personnes utilisant cet ordinateur pourront voir votre liste d&apos;endroits favoris.
+		<usetemplate name="okbutton" yestext="OK"/>
+	</notification>
 	<notification name="GrantModifyRights">
 		Lorsque vous accordez des droits de modification à un autre résident, vous lui permettez de changer, supprimer ou prendre n&apos;importe lequel de vos objets dans Second Life. Réfléchissez bien avant d&apos;accorder ces droits.
 Voulez-vous vraiment accorder des droits de modification à [NAME] ?
@@ -945,7 +949,7 @@ Proposer à [NAME] de devenir votre ami(e) ?
 			<input name="message">
 				[DESC] (nouv.)
 			</input>
-			<button name="Offer" text="OK"/>
+			<button name="OK" text="OK"/>
 			<button name="Cancel" text="Annuler"/>
 		</form>
 	</notification>
@@ -955,7 +959,7 @@ Proposer à [NAME] de devenir votre ami(e) ?
 			<input name="message">
 				[DESC] (nouv.)
 			</input>
-			<button name="Offer" text="OK"/>
+			<button name="OK" text="OK"/>
 			<button name="Cancel" text="Annuler"/>
 		</form>
 	</notification>
@@ -965,7 +969,7 @@ Proposer à [NAME] de devenir votre ami(e) ?
 			<input name="new_name">
 				[NAME]
 			</input>
-			<button name="Offer" text="OK"/>
+			<button name="OK" text="OK"/>
 			<button name="Cancel" text="Annuler"/>
 		</form>
 	</notification>
@@ -1338,9 +1342,41 @@ Veuillez télécharger et installer la dernière version du client à la page We
 http://secondlife.com/download.
 		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
-	<notification name="DownloadBackground">
-		Une mise à jour de [APP_NAME] a été téléchargée.
-Elle sera appliquée au prochain redémarrage de [APP_NAME].
+	<notification name="FailedRequiredUpdateInstall">
+		Impossible d&apos;installer une mise à jour requise. 
+Vous ne pourrez pas vous connecter tant que [APP_NAME] ne sera pas mis à jour.
+
+Veuillez télécharger et installer la dernière version du client à la page Web
+http://secondlife.com/download.
+		<usetemplate name="okbutton" yestext="Quitter"/>
+	</notification>
+	<notification name="UpdaterServiceNotRunning">
+		Une mise à jour requise pour votre installation Second Life existe.
+
+Pour la télécharger, accédez à http://www.secondlife.com/downloads.
+Vous pouvez également l&apos;installer dès maintenant.
+		<usetemplate name="okcancelbuttons" notext="Quitter Second Life" yestext="Télécharger et installer maintenant"/>
+	</notification>
+	<notification name="DownloadBackgroundTip">
+		Nous avons téléchargé une mise à jour de votre installation [APP_NAME].
+Version [VERSION] [[RELEASE_NOTES_FULL_URL] Informations relatives à cette mise à jour]
+		<usetemplate name="okcancelbuttons" notext="Ultérieurement..." yestext="Installer maintenant et redémarrer [APP_NAME]"/>
+	</notification>
+	<notification name="DownloadBackgroundDialog">
+		Nous avons téléchargé une mise à jour de votre installation [APP_NAME].
+Version [VERSION] [[RELEASE_NOTES_FULL_URL] Informations relatives à cette mise à jour]
+		<usetemplate name="okcancelbuttons" notext="Ultérieurement..." yestext="Installer maintenant et redémarrer [APP_NAME]"/>
+	</notification>
+	<notification name="RequiredUpdateDownloadedVerboseDialog">
+		Nous avons téléchargé une mise à jour logicielle requise.
+Version [VERSION]
+
+[APP_NAME] doit être redémarré pour que la mise à jour soit installée.
+		<usetemplate name="okbutton" yestext="OK"/>
+	</notification>
+	<notification name="RequiredUpdateDownloadedDialog">
+		[APP_NAME] doit être redémarré pour que la mise à jour soit installée.
+		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="DeedObjectToGroup">
 		Si vous cédez cet objet, le groupe :
@@ -2209,14 +2245,6 @@ Veuillez sélectionner un terrain plus petit.
 	<notification name="NoContentToSearch">
 		Veuillez sélectionner au moins un type de contenu à rechercher (Général, Modéré ou Adulte)
 	</notification>
-	<notification name="GroupVote">
-		[NAME] a proposé un vote pour :
-[MESSAGE]
-		<form name="form">
-			<button name="VoteNow" text="Voter"/>
-			<button name="Later" text="Plus tard"/>
-		</form>
-	</notification>
 	<notification name="SystemMessage">
 		[MESSAGE]
 	</notification>
@@ -2674,9 +2702,6 @@ Pour y participer, cliquez sur Accepter. Sinon, cliquez sur Refuser. Pour ignore
 	<notification name="VoiceCallGenericError">
 		Une erreur est survenue pendant la connexion au chat vocal pour [VOICE_CHANNEL_NAME]. Veuillez réessayer ultérieurement.
 	</notification>
-	<notification name="ServerVersionChanged">
-		La région dans laquelle vous avez pénétré utilise une version de serveur différente, ce qui peut avoir un impact sur votre performance. [[URL] Consultez les notes de version.]
-	</notification>
 	<notification name="UnsupportedCommandSLURL">
 		La SLurl que vous avez saisie n&apos;est pas prise en charge.
 	</notification>
@@ -2779,9 +2804,7 @@ L&apos;avatar [NAME] a quitté le mode Apparence.
 	<notification name="NoConnect">
 		Problèmes de connexion via [PROTOCOL] [HOSTID].
 Veuillez vérifier la configuration de votre réseau et de votre pare-feu.
-		<form name="form">
-			<button name="OK" text="OK"/>
-		</form>
+		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="NoVoiceConnect">
 		Problèmes de connexion à votre serveur vocal :
@@ -2790,9 +2813,7 @@ Veuillez vérifier la configuration de votre réseau et de votre pare-feu.
 
 Aucune communication vocale n&apos;est disponible.
 Veuillez vérifier la configuration de votre réseau et de votre pare-feu.
-		<form name="form">
-			<button name="OK" text="OK"/>
-		</form>
+		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="AvatarRezLeftNotification">
 		([EXISTENCE] secondes d&apos;existence)
@@ -2827,6 +2848,9 @@ Ignorer les autres ?
 	<notification label="Explorer le monde" name="HintDestinationGuide">
 		Le Guide des destinations comprend des milliers d&apos;endroits nouveaux à découvrir. Sélectionnez-en un, puis cliquez sur Téléporter pour commencer à l&apos;explorer.
 	</notification>
+	<notification label="Changer d&apos;apparence" name="HintAvatarPicker">
+		Vous souhaitez changer de look ? Cliquez sur le bouton ci-dessous pour voir plus d&apos;avatars.
+	</notification>
 	<notification label="Panneau latéral" name="HintSidePanel">
 		Obtenir un accès rapide à votre inventaire, à vos habits, à vos profils et bien plus encore dans le panneau latéral.
 	</notification>
@@ -2836,6 +2860,12 @@ Ignorer les autres ?
 	<notification label="Nom d&apos;affichage" name="HintDisplayName">
 		Définissez ici votre nom d&apos;affichage personnalisable. Cette fonctionnalité vous est fournie en plus de votre nom d&apos;utilisateur unique qui, lui, ne peut être changé. Vous pouvez modifier l&apos;apparence des noms des autres résidents dans vos préférences.
 	</notification>
+	<notification label="Bouger" name="HintMoveArrows">
+		Pour marcher, utilisez les touches fléchées de votre clavier. Pour courir, appuyez deux fois sur la flèche vers le haut.
+	</notification>
+	<notification label="Affichage" name="HintView">
+		Pour changer d&apos;angle de vision, utilisez les contrôles Faire tourner et Faire un panoramique. Pour réinitialiser la vue, appuyez sur Échap ou marchez.
+	</notification>
 	<notification label="Inventaire" name="HintInventory">
 		Permet de rechercher des articles dans l&apos;inventaire. Pour accéder aux derniers articles ajoutés, cliquez sur l&apos;onglet Récent.
 	</notification>
@@ -2849,6 +2879,15 @@ Ignorer les autres ?
 			<button name="open" text="Ouvrir la fenêtre popup"/>
 		</form>
 	</notification>
+	<notification name="AuthRequest">
+		Nom d&apos;utilisateur et mot de passe requis pour le site se trouvant à l&apos;emplacement suivant : &apos;&lt;nolink&gt;[HOST_NAME]&lt;/nolink&gt;&apos;, domaine &apos;[REALM]&apos;.
+		<form name="form">
+			<input name="username" text="Nom d&apos;utilisateur"/>
+			<input name="password" text="Mot de passe"/>
+			<button name="ok" text="Soumettre"/>
+			<button name="cancel" text="Annuler"/>
+		</form>
+	</notification>
 	<global name="UnsupportedCPU">
 		- Votre processeur ne remplit pas les conditions minimum requises.
 	</global>
diff --git a/indra/newview/skins/default/xui/fr/panel_avatar_list_item.xml b/indra/newview/skins/default/xui/fr/panel_avatar_list_item.xml
index 607665ddd80305a69d54f2b3a02c42932cdc91d7..54b8f53e59ba49b08242310e835d0810743a6f11 100644
--- a/indra/newview/skins/default/xui/fr/panel_avatar_list_item.xml
+++ b/indra/newview/skins/default/xui/fr/panel_avatar_list_item.xml
@@ -21,7 +21,7 @@
 	<string name="FormatYears">
 		[COUNT] a
 	</string>
-	<text name="avatar_name" value="Inconnu"/>
+	<text name="avatar_name" value="(chargement)"/>
 	<text name="last_interaction" value="0s"/>
 	<icon name="permission_edit_theirs_icon" tool_tip="Vous pouvez modifier les objets de cet(te) ami(e)."/>
 	<icon name="permission_edit_mine_icon" tool_tip="Cet(te) ami(e) peut modifier, supprimer ou prendre vos objets."/>
diff --git a/indra/newview/skins/default/xui/fr/panel_edit_alpha.xml b/indra/newview/skins/default/xui/fr/panel_edit_alpha.xml
index 3b81ef2a5f97445a9d69060cc91a00ad5a45e4e5..a8b95c66fb111ac703ceb08e960cf75b3b4f44f1 100644
--- a/indra/newview/skins/default/xui/fr/panel_edit_alpha.xml
+++ b/indra/newview/skins/default/xui/fr/panel_edit_alpha.xml
@@ -1,10 +1,12 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel name="edit_alpha_panel">
-	<panel name="avatar_alpha_color_panel">
-		<texture_picker label="Alpha bas" name="Lower Alpha" tool_tip="Cliquez pour sélectionner une image"/>
-		<texture_picker label="Alpha haut" name="Upper Alpha" tool_tip="Cliquez pour sélectionner une image"/>
-		<texture_picker label="Alpha tête" name="Head Alpha" tool_tip="Cliquez pour sélectionner une image"/>
-		<texture_picker label="Alpha yeux" name="Eye Alpha" tool_tip="Cliquez pour sélectionner une image"/>
-		<texture_picker label="Alpha cheveux" width="80" name="Hair Alpha" tool_tip="Cliquez pour sélectionner une image"/>
-	</panel>
+	<scroll_container name="avatar_alpha_color_panel_scroll">
+		<panel name="avatar_alpha_color_panel">
+			<texture_picker label="Alpha bas" name="Lower Alpha" tool_tip="Cliquer pour sélectionner une image."/>
+			<texture_picker label="Alpha haut" name="Upper Alpha" tool_tip="Cliquer pour sélectionner une image."/>
+			<texture_picker label="Alpha tête" name="Head Alpha" tool_tip="Cliquer pour sélectionner une image."/>
+			<texture_picker label="Alpha yeux" name="Eye Alpha" tool_tip="Cliquer pour sélectionner une image."/>
+			<texture_picker label="Alpha cheveux" name="Hair Alpha" tool_tip="Cliquer pour sélectionner une image."/>
+		</panel>
+	</scroll_container>
 </panel>
diff --git a/indra/newview/skins/default/xui/fr/panel_login.xml b/indra/newview/skins/default/xui/fr/panel_login.xml
index b6677801802dd2c7233b6245f3f05a924e1c5662..ef55ba7991da384d73fd7ed1cc010dc755fcbadd 100644
--- a/indra/newview/skins/default/xui/fr/panel_login.xml
+++ b/indra/newview/skins/default/xui/fr/panel_login.xml
@@ -11,7 +11,7 @@
 			<text name="username_text">
 				Nom d&apos;utilisateur :
 			</text>
-			<line_editor label="bobsmith12 ou Steller Sunshine" name="username_edit" tool_tip="Nom d&apos;utilisateur que vous avez choisi lors de votre inscription (par exemple, bobsmith12 ou Steller Sunshine)."/>
+			<combo_box name="username_combo" tool_tip="Nom d&apos;utilisateur que vous avez choisi lors de votre inscription (par exemple, bobsmith12 ou Steller Sunshine)."/>
 			<text name="password_text">
 				Mot de passe :
 			</text>
diff --git a/indra/newview/skins/default/xui/fr/panel_my_profile.xml b/indra/newview/skins/default/xui/fr/panel_my_profile.xml
index 8dbc22d3c7434caa01c4c8b857fb11201bb49747..5207c5a28e7967fa8d961c1323a4430decdf0635 100644
--- a/indra/newview/skins/default/xui/fr/panel_my_profile.xml
+++ b/indra/newview/skins/default/xui/fr/panel_my_profile.xml
@@ -16,34 +16,27 @@
 	<string name="RegisterDateFormat">
 		[REG_DATE] ([AGE])
 	</string>
+	<string name="name_text_args">
+		[NAME]
+	</string>
+	<string name="display_name_text_args">
+		[DISPLAY_NAME]
+	</string>
 	<layout_stack name="layout">
 		<layout_panel name="profile_stack">
 			<scroll_container name="profile_scroll">
 				<panel name="scroll_content_panel">
 					<panel name="second_life_image_panel">
-						<icon label="" name="2nd_life_edit_icon" tool_tip="Cliquez sur le bouton Modifier le profil ci-dessous pour changer d&apos;image"/>
-						<text name="title_sl_descr_text" value="[SECOND_LIFE]:"/>
-					</panel>
-					<panel name="first_life_image_panel">
-						<icon label="" name="real_world_edit_icon" tool_tip="Cliquez sur le bouton Modifier le profil ci-dessous pour changer d&apos;image"/>
-						<text name="title_rw_descr_text" value="Vie réelle :"/>
-					</panel>
-					<text name="title_member_text" value="Résident depuis :"/>
-					<text name="title_acc_status_text" value="Statut du compte :"/>
-					<text_editor name="acc_status_text">
-						Résident. Aucune info de paiement enregistrée.
-              Linden.
-					</text_editor>
-					<text name="title_partner_text" value="Partenaire :"/>
-					<panel name="partner_data_panel">
-						<name_box initial_value="(récupération en cours)" name="partner_text"/>
+						<text name="display_name_descr_text">
+							Nom d&apos;utilisateur
+						</text>
+						<text name="name_descr_text">
+							Nom d&apos;affichage
+						</text>
+						<button label="Profil" name="see_profile_btn" tool_tip="Afficher le profil de cet avatar."/>
 					</panel>
-					<text name="title_groups_text" value="Groupes :"/>
 				</panel>
 			</scroll_container>
 		</layout_panel>
 	</layout_stack>
-	<panel name="profile_me_buttons_panel">
-		<button label="Modifier le profil" name="edit_profile_btn" tool_tip="Modifier vos informations personnelles"/>
-	</panel>
 </panel>
diff --git a/indra/newview/skins/default/xui/fr/panel_notify_textbox.xml b/indra/newview/skins/default/xui/fr/panel_notify_textbox.xml
index a37770e184e4977da4d3da24c428b689b8554dcb..6ce09cde4b18334c4146494585e6e15b33ec0b7f 100644
--- a/indra/newview/skins/default/xui/fr/panel_notify_textbox.xml
+++ b/indra/newview/skins/default/xui/fr/panel_notify_textbox.xml
@@ -3,8 +3,9 @@
 	<string name="message_max_lines_count" value="7"/>
 	<panel label="info_panel" name="info_panel">
 		<text_editor name="message" value="message"/>
-		parse_urls=&quot;false&quot;
+	</panel>
+	<panel label="control_panel" name="control_panel">
 		<button label="Soumettre" name="btn_submit"/>
+		<button label="Ignorer" name="ignore_btn"/>
 	</panel>
-	<panel label="control_panel" name="control_panel"/>
 </panel>
diff --git a/indra/newview/skins/default/xui/fr/panel_preferences_colors.xml b/indra/newview/skins/default/xui/fr/panel_preferences_colors.xml
index e94bb08c9c9ed3009a5994c7fcf73cfffdad5623..4e7d75e1b9d00b598dd48505e17905e8c2749226 100644
--- a/indra/newview/skins/default/xui/fr/panel_preferences_colors.xml
+++ b/indra/newview/skins/default/xui/fr/panel_preferences_colors.xml
@@ -29,10 +29,10 @@
 		URL
 	</text>
 	<text name="bubble_chat">
-		Arrière-plan des bulles de chat :
+		Couleur de fond des noms (bulles de chat comprises) :
 	</text>
-	<color_swatch name="background" tool_tip="Choisir la couleur des bulles de chat."/>
-	<slider label="Opacité :" name="bubble_chat_opacity"/>
+	<color_swatch name="background" tool_tip="Choisir une couleur pour les noms."/>
+	<slider label="Opacité :" name="bubble_chat_opacity" tool_tip="Choisir une opacité pour les noms."/>
 	<text name="floater_opacity">
 		Opacité des fenêtres flottantes :
 	</text>
diff --git a/indra/newview/skins/default/xui/fr/panel_preferences_privacy.xml b/indra/newview/skins/default/xui/fr/panel_preferences_privacy.xml
index 6a4c77a10e6c21bd8fdae1182ce381d4293f377d..202ec779f58cc7032c8b8f9cb270affadf900cdd 100644
--- a/indra/newview/skins/default/xui/fr/panel_preferences_privacy.xml
+++ b/indra/newview/skins/default/xui/fr/panel_preferences_privacy.xml
@@ -7,9 +7,11 @@
 	<text name="cache_size_label_l">
 		(Endroits, images, web, historique des recherches)
 	</text>
+	<check_box label="M&apos;afficher dans les résultats de recherche" name="online_searchresults"/>
 	<check_box label="Seuls mes amis et groupes voient quand je suis en ligne" name="online_visibility"/>
 	<check_box label="Seuls mes amis et groupes peuvent m&apos;appeler ou m&apos;envoyer un IM" name="voice_call_friends_only_check"/>
 	<check_box label="Fermer le micro à la fin d&apos;un appel" name="auto_disengage_mic_check"/>
+	<check_box label="Afficher mes repères favoris à la connexion (liste déroulante Lieu de départ)" name="favorites_on_login_check"/>
 	<text name="Logs:">
 		Journaux de chat :
 	</text>
diff --git a/indra/newview/skins/default/xui/fr/panel_preferences_setup.xml b/indra/newview/skins/default/xui/fr/panel_preferences_setup.xml
index 8fa499d14aab04315a9f6fb9e1c1294a03af8e5a..bfe0defd56f5b469242adaefefb3b2d4f1812ed5 100644
--- a/indra/newview/skins/default/xui/fr/panel_preferences_setup.xml
+++ b/indra/newview/skins/default/xui/fr/panel_preferences_setup.xml
@@ -39,5 +39,11 @@
 	</text>
 	<line_editor name="web_proxy_editor" tool_tip="Le nom ou adresse IP du proxy que vous souhaitez utiliser"/>
 	<spinner label="Numéro de port :" label_width="95" name="web_proxy_port" width="170"/>
-	<check_box initial_value="true" label="Télécharger et installer automatiquement les mises à jour [APP_NAME]" name="updater_service_active"/>
+	<text name="Software updates:">
+		Mises à jour logicielles :
+	</text>
+	<combo_box name="updater_service_combobox">
+		<combo_box.item label="Installation automatique" name="Install_automatically"/>
+		<combo_box.item label="Téléchargement et installation manuels" name="Install_manual"/>
+	</combo_box>
 </panel>
diff --git a/indra/newview/skins/default/xui/fr/panel_status_bar.xml b/indra/newview/skins/default/xui/fr/panel_status_bar.xml
index 85429a18c736ca9b2c86645b36f5c2eed39572aa..69aec99e1d80d0e27136d85617a3a02a508c5eca 100644
--- a/indra/newview/skins/default/xui/fr/panel_status_bar.xml
+++ b/indra/newview/skins/default/xui/fr/panel_status_bar.xml
@@ -22,7 +22,7 @@
 		[AMT] L$
 	</panel.string>
 	<panel name="balance_bg">
-		<text name="balance" tool_tip="Mon solde" value="20 L$"/>
+		<text name="balance" tool_tip="Cliquer sur ce bouton pour actualiser votre solde en L$." value="20 L$"/>
 		<button label="ACHETER L$" name="buyL" tool_tip="Cliquer pour acheter plus de L$"/>
 	</panel>
 	<text name="TimeText" tool_tip="Heure actuelle (Pacifique)">
diff --git a/indra/newview/skins/default/xui/it/notifications.xml b/indra/newview/skins/default/xui/it/notifications.xml
index 5e53080c77b312a87c8d54e4c31e591aeebc2a8e..cce588859824506c76dd138e61fab1e881d122f2 100644
--- a/indra/newview/skins/default/xui/it/notifications.xml
+++ b/indra/newview/skins/default/xui/it/notifications.xml
@@ -2623,9 +2623,6 @@ Clicca su Accetta per unirti alla chat oppure su Declina per declinare l&apos;in
 	<notification name="VoiceCallGenericError">
 		Si è verificato un errore durante il tentativo di collegarti a una voice chat con [VOICE_CHANNEL_NAME].  Riprova più tardi.
 	</notification>
-	<notification name="ServerVersionChanged">
-		Sei appena entrato in una regione che usa una versione differente del server: ciò potrebbe incidere sule prestazioni. [[URL] Visualizza le note sulla versione.]
-	</notification>
 	<notification name="UnsupportedCommandSLURL">
 		Lo SLurl su cui hai cliccato non è valido.
 	</notification>
diff --git a/indra/newview/skins/default/xui/ja/notifications.xml b/indra/newview/skins/default/xui/ja/notifications.xml
index f133bb361afcaf578764b04fc60c07c0f25f1cad..baec8c073c2d3dc27d17fa4db389cd2ef3522c91 100644
--- a/indra/newview/skins/default/xui/ja/notifications.xml
+++ b/indra/newview/skins/default/xui/ja/notifications.xml
@@ -2675,9 +2675,6 @@ M キーを押して変更します。
 	<notification name="VoiceCallGenericError">
 		[VOICE_CHANNEL_NAME] のボイスチャットに接続中に、エラーが発生しました。後でもう一度お試しください。
 	</notification>
-	<notification name="ServerVersionChanged">
-		サーバーのバージョンが異なるリージョンに来ました。パフォーマンスに影響することがあります。 [[URL] リリースノートを確認]
-	</notification>
 	<notification name="UnsupportedCommandSLURL">
 		クリックした SLurl はサポートされていません。
 	</notification>
diff --git a/indra/newview/skins/default/xui/nl/notifications.xml b/indra/newview/skins/default/xui/nl/notifications.xml
index be0c17d2ff8a7145f51aca577a62311a38bbe875..f27b83d3f92d1eaf7f68f7115276196e207821ef 100644
--- a/indra/newview/skins/default/xui/nl/notifications.xml
+++ b/indra/newview/skins/default/xui/nl/notifications.xml
@@ -3012,9 +3012,6 @@ Klik Accepteren om deel te nemen aan de chat of Afwijzen om de uitnodiging af te
 	<notification name="VoiceCallGenericError">
 		Er is een fout opgetreden tijdens het verbinden met voice chat voor [VOICE_CHANNEL_NAME]. Probeert u het later alstublieft opnieuw.
 	</notification>
-	<notification name="ServerVersionChanged">
-		De regio die u bent binnengetreden wordt onder een andere simulatorversie uitgevoerd. Klik dit bericht voor meer details.
-	</notification>
 	<notification name="UnableToOpenCommandURL">
 		De URL die u heeft geklikt kan niet binnen deze webbrowser worden geopend.
 	</notification>
diff --git a/indra/newview/skins/default/xui/pl/floater_hardware_settings.xml b/indra/newview/skins/default/xui/pl/floater_hardware_settings.xml
index bd5dd7e7d2ed418a2dda65f024e1641d420eb069..471d2c39baf2571cd487108b858625a008520771 100644
--- a/indra/newview/skins/default/xui/pl/floater_hardware_settings.xml
+++ b/indra/newview/skins/default/xui/pl/floater_hardware_settings.xml
@@ -14,6 +14,9 @@
 		<combo_box.item label="8x" name="8x"/>
 		<combo_box.item label="16x" name="16x"/>
 	</combo_box>
+	<text name="antialiasing restart">
+		(Restart wymagany)
+	</text>
 	<spinner label="Gamma:" name="gamma"/>
 	<text name="(brightness, lower is brighter)">
 		(0=domyślna jaskrawość, niższa wartość=jaśniej)
diff --git a/indra/newview/skins/default/xui/pl/floater_preferences.xml b/indra/newview/skins/default/xui/pl/floater_preferences.xml
index 3f62d764c61b703782e455f325f270ecdb30a62c..930a5c76b005e8882ecad6eb2986c11fda402176 100644
--- a/indra/newview/skins/default/xui/pl/floater_preferences.xml
+++ b/indra/newview/skins/default/xui/pl/floater_preferences.xml
@@ -5,10 +5,12 @@
 	<tab_container name="pref core">
 		<panel label="Ogólne" name="general"/>
 		<panel label="Grafika" name="display"/>
-		<panel label="Prywatność" name="im"/>
 		<panel label="Dźwięk &amp; Media" name="audio"/>
 		<panel label="Czat" name="chat"/>
+		<panel label="Ruch &amp; Widok" name="move"/>
 		<panel label="Powiadomienia" name="msgs"/>
+		<panel label="Kolory" name="colors"/>
+		<panel label="Prywatność" name="im"/>
 		<panel label="Ustawienie" name="input"/>
 		<panel label="Zaawansowane" name="advanced1"/>
 	</tab_container>
diff --git a/indra/newview/skins/default/xui/pl/floater_region_debug_console.xml b/indra/newview/skins/default/xui/pl/floater_region_debug_console.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ce1f3c0ac73491c2c0834fcb833f91c605c15dea
--- /dev/null
+++ b/indra/newview/skins/default/xui/pl/floater_region_debug_console.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<floater name="region_debug_console" title="Debugowanie regionu"/>
diff --git a/indra/newview/skins/default/xui/pl/floater_web_content.xml b/indra/newview/skins/default/xui/pl/floater_web_content.xml
new file mode 100644
index 0000000000000000000000000000000000000000..4cc8d0b27b3272ea0f66db049595663230655432
--- /dev/null
+++ b/indra/newview/skins/default/xui/pl/floater_web_content.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<floater name="floater_web_content" title="">
+	<layout_stack name="stack1">
+		<layout_panel name="nav_controls">
+			<button name="back" tool_tip="Do tyłu"/>
+			<button name="forward" tool_tip="Do przodu"/>
+			<button name="stop" tool_tip="Zatrzymaj"/>
+			<button name="reload" tool_tip="Odśwież stronę"/>
+			<combo_box name="address" tool_tip="Wprowadź URL tutaj"/>
+			<icon name="media_secure_lock_flag" tool_tip="Funkcja bezpiecznego przeglÄ…dania (Secured Browsing)"/>
+			<button name="popexternal" tool_tip="Otwórz bieżący URL w zewnętrznej przeglądarce"/>
+		</layout_panel>
+	</layout_stack>
+</floater>
diff --git a/indra/newview/skins/default/xui/pl/menu_inventory_gear_default.xml b/indra/newview/skins/default/xui/pl/menu_inventory_gear_default.xml
index d110a2f02e1e2de645aab3f3674034eb5ffac49d..491b4deeaaff5b7766f6647aa8f93e4a2a11d2c3 100644
--- a/indra/newview/skins/default/xui/pl/menu_inventory_gear_default.xml
+++ b/indra/newview/skins/default/xui/pl/menu_inventory_gear_default.xml
@@ -1,8 +1,9 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<menu name="menu_gear_default">
+<toggleable_menu name="menu_gear_default">
 	<menu_item_call label="Nowe okno Szafy" name="new_window"/>
-	<menu_item_call label="Porządkuj według nazwy" name="sort_by_name"/>
-	<menu_item_call label="Porządkuj według daty" name="sort_by_recent"/>
+	<menu_item_check label="Porządkuj według nazwy" name="sort_by_name"/>
+	<menu_item_check label="Porządkuj według daty" name="sort_by_recent"/>
+	<menu_item_check label="Posortuj foldery systemowe od góry" name="sort_system_folders_to_top"/>
 	<menu_item_call label="Pokaż filtry" name="show_filters"/>
 	<menu_item_call label="Zresetuj filtry" name="reset_filters"/>
 	<menu_item_call label="Zamknij wszystkie foldery" name="close_folders"/>
@@ -12,4 +13,4 @@
 	<menu_item_call label="Znajdź oryginał" name="Find Original"/>
 	<menu_item_call label="Znajdź wszystkie linki" name="Find All Links"/>
 	<menu_item_call label="Opróżnij Kosz" name="empty_trash"/>
-</menu>
+</toggleable_menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_login.xml b/indra/newview/skins/default/xui/pl/menu_login.xml
index 0dd6117b8541cbb7937e64cd63695f0265feacde..e50b69464119b2f3b2b020f5af4b6422adbdfbdf 100644
--- a/indra/newview/skins/default/xui/pl/menu_login.xml
+++ b/indra/newview/skins/default/xui/pl/menu_login.xml
@@ -16,7 +16,8 @@
 		<menu_item_call label="Ustaw rozmiar interfejsu..." name="Set Window Size..."/>
 		<menu_item_call label="Wyświetl TOS" name="TOS"/>
 		<menu_item_call label="Wyświetl wiadomość krytyczną" name="Critical"/>
-		<menu_item_call label="Test przeglÄ…darki internetowej" name="Web Browser Test"/>
+		<menu_item_call label="Test przeglądarki mediów" name="Web Browser Test"/>
+		<menu_item_call label="Test zawartości strony" name="Web Content Floater Test"/>
 		<menu_item_check label="Pokaż siatkę" name="Show Grid Picker"/>
 		<menu_item_call label="Pokaż konsolę Zawiadomień" name="Show Notifications Console"/>
 	</menu>
diff --git a/indra/newview/skins/default/xui/pl/menu_mini_map.xml b/indra/newview/skins/default/xui/pl/menu_mini_map.xml
index 148adfba0d12883d1f24b24e31debfd8ba9a509d..8f869654165d268d4c23e4ed73383f0473b47979 100644
--- a/indra/newview/skins/default/xui/pl/menu_mini_map.xml
+++ b/indra/newview/skins/default/xui/pl/menu_mini_map.xml
@@ -3,6 +3,7 @@
 	<menu_item_call label="Zoom blisko" name="Zoom Close"/>
 	<menu_item_call label="Zoom średnio" name="Zoom Medium"/>
 	<menu_item_call label="Zoom daleko" name="Zoom Far"/>
+	<menu_item_call label="Zoom domyślny" name="Zoom Default"/>
 	<menu_item_check label="Obróć mapę" name="Rotate Map"/>
 	<menu_item_check label="Autocentrowanie" name="Auto Center"/>
 	<menu_item_call label="Zatrzymaj" name="Stop Tracking"/>
diff --git a/indra/newview/skins/default/xui/pl/menu_viewer.xml b/indra/newview/skins/default/xui/pl/menu_viewer.xml
index a359180ffb0f8a05429260c1f6d70165680fb4b6..e6a9d360c4c2c74eeaa0fee511b981519051d259 100644
--- a/indra/newview/skins/default/xui/pl/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/pl/menu_viewer.xml
@@ -10,6 +10,12 @@
 		<menu_item_check label="Moja Szafa" name="ShowSidetrayInventory"/>
 		<menu_item_check label="Moje gesturki" name="Gestures"/>
 		<menu_item_check label="Mój głos" name="ShowVoice"/>
+		<menu label="Ruch" name="Movement">
+			<menu_item_call label="Usiądź" name="Sit Down Here"/>
+			<menu_item_check label="Zacznij latać" name="Fly"/>
+			<menu_item_check label="Zawsze biegnij" name="Always Run"/>
+			<menu_item_call label="Zatrzymaj animacje" name="Stop Animating My Avatar"/>
+		</menu>
 		<menu label="Mój Status" name="Status">
 			<menu_item_call label="Tryb oddalenia" name="Set Away"/>
 			<menu_item_call label="Tryb pracy" name="Set Busy"/>
@@ -45,6 +51,7 @@
 			<menu_item_check label="Właściciele posiadłości" name="Land Owners"/>
 			<menu_item_check label="Współrzędne" name="Coordinates"/>
 			<menu_item_check label="Właściwości posiadłości" name="Parcel Properties"/>
+			<menu_item_check label="Menu Zaawansowane" name="Show Advanced Menu"/>
 		</menu>
 		<menu_item_call label="Teleportuj do Miejsca Startu" name="Teleport Home"/>
 		<menu_item_call label="Ustaw Miejsce Startu" name="Set Home to Here"/>
@@ -112,16 +119,17 @@
 			<menu_item_call label="animacjÄ™ (L$[COST])..." name="Upload Animation"/>
 			<menu_item_call label="zbiór plików (L$[COST] za jeden plik)..." name="Bulk Upload"/>
 		</menu>
+		<menu_item_call label="Cofnij" name="Undo"/>
+		<menu_item_call label="Ponów" name="Redo"/>
 	</menu>
 	<menu label="Pomoc" name="Help">
 		<menu_item_call label="[SECOND_LIFE] Portal Pomocy" name="Second Life Help"/>
+		<menu_item_check label="WÅ‚Ä…cz podpowiedzi" name="Enable Hints"/>
 		<menu_item_call label="Złóż Raport o Nadużyciu" name="Report Abuse"/>
 		<menu_item_call label="Zgłoś błędy klienta" name="Report Bug"/>
 		<menu_item_call label="O [APP_NAME]" name="About Second Life"/>
-		<menu_item_check label="WÅ‚Ä…cz podpowiedzi" name="Enable Hints"/>
 	</menu>
 	<menu label="Zaawansowane" name="Advanced">
-		<menu_item_call label="Zatrzymaj wszystkie animacje" name="Stop Animating My Avatar"/>
 		<menu_item_call label="Odswież wyświetlanie tekstur" name="Rebake Texture"/>
 		<menu_item_call label="Domyślne ustawienia rozmiaru interfejsu" name="Set UI Size to Default"/>
 		<menu_item_call label="Ustaw rozmiar interfejsu..." name="Set Window Size..."/>
@@ -175,8 +183,7 @@
 			<menu_item_check label="Szukaj" name="Search"/>
 			<menu_item_call label="Zwolnij klawisze" name="Release Keys"/>
 			<menu_item_call label="Domyślne ustawienia rozmiaru interfejsu" name="Set UI Size to Default"/>
-			<menu_item_check label="Biegnij" name="Always Run"/>
-			<menu_item_check label="Zacznij latać" name="Fly"/>
+			<menu_item_check label="Pokaż menu Zaawansowane - skrót" name="Show Advanced Menu - legacy shortcut"/>
 			<menu_item_call label="Zamknij okno" name="Close Window"/>
 			<menu_item_call label="Zamknij wszystkie okna" name="Close All Windows"/>
 			<menu_item_call label="Zapisz zdjęcie na dysk twardy" name="Snapshot to Disk"/>
@@ -194,7 +201,6 @@
 			<menu_item_call label="Przybliż" name="Zoom In"/>
 			<menu_item_call label="Domyślne przybliżenie" name="Zoom Default"/>
 			<menu_item_call label="Oddal" name="Zoom Out"/>
-			<menu_item_check label="Pokaż menu Zaawansowane" name="Show Advanced Menu"/>
 		</menu>
 		<menu_item_call label="Pokaż ustawienia debugowania" name="Debug Settings"/>
 		<menu_item_check label="Pokaż menu progresu" name="Debug Mode"/>
@@ -262,19 +268,17 @@
 			<menu_item_call label="Zachowaj bufor pamięci obiektów regionu" name="Dump Region Object Cache"/>
 		</menu>
 		<menu label="UI" name="UI">
-			<menu_item_call label="Test przeglÄ…darki internetowej" name="Web Browser Test"/>
+			<menu_item_call label="Test przeglądarki mediów" name="Web Browser Test"/>
+			<menu_item_call label="Przeglądarka zawartości strony" name="Web Content Browser"/>
 			<menu_item_call label="Drukuj zaznaczone informacje o obiekcie" name="Print Selected Object Info"/>
 			<menu_item_call label="Statystyki pamięci" name="Memory Stats"/>
-			<menu_item_check label="Auto-pilot na podwójne kliknięcie" name="Double-ClickAuto-Pilot"/>
-			<menu_item_check label="Podwójne kliknięcie - Teleportuj" name="DoubleClick Teleport"/>
+			<menu_item_check label="Konsola debugowania regionu" name="Region Debug Console"/>
 			<menu_item_check label="Debugowanie zdarzeń klikania" name="Debug Clicks"/>
 			<menu_item_check label="Debugowanie zdarzeń myszy" name="Debug Mouse Events"/>
 		</menu>
 		<menu label="XUI" name="XUI">
 			<menu_item_call label="Załaduj ustawienia koloru" name="Reload Color Settings"/>
 			<menu_item_call label="Pokaż test czcionki" name="Show Font Test"/>
-			<menu_item_call label="Załaduj z XML" name="Load from XML"/>
-			<menu_item_call label="Zapisz jako XML" name="Save to XML"/>
 			<menu_item_check label="Pokaż nazwy XUI" name="Show XUI Names"/>
 			<menu_item_call label="Wyślij wiadomość (IM) testową" name="Send Test IMs"/>
 			<menu_item_call label="Wyczyść bufor pamięci nazw" name="Flush Names Caches"/>
@@ -301,9 +305,9 @@
 		</menu>
 		<menu_item_check label="Tekstury HTTP" name="HTTP Textures"/>
 		<menu_item_check label="Aktywacja okna konsoli podczas następnego uruchomienia" name="Console Window"/>
-		<menu_item_check label="Pokaż menu administratora" name="View Admin Options"/>
 		<menu_item_call label="Uzyskaj status administratora" name="Request Admin Options"/>
 		<menu_item_call label="Opuść status administratora" name="Leave Admin Options"/>
+		<menu_item_check label="Pokaż menu administratora" name="View Admin Options"/>
 	</menu>
 	<menu label="Administrator" name="Admin">
 		<menu label="Object">
diff --git a/indra/newview/skins/default/xui/pl/notifications.xml b/indra/newview/skins/default/xui/pl/notifications.xml
index 57a6b8b8ef9e6cfd258dff586746536f8c7d276c..25fa5da3ab0c28b5059a2627a92ee577c58007d3 100644
--- a/indra/newview/skins/default/xui/pl/notifications.xml
+++ b/indra/newview/skins/default/xui/pl/notifications.xml
@@ -109,6 +109,10 @@ Wybierz pojedynczy obiekt i spróbuj jeszcze raz.
 		Osoby spoza listy znajomych, których rozmowy głosowe i IM są ignorowane, nie wiedzą o tym.
 		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
+	<notification name="FavoritesOnLogin">
+		Pamiętaj: kiedy wyłączysz tą opcję, każdy kto używa tego komputera, może zobaczyć Twoją listę ulubionych miejsc.
+		<usetemplate name="okbutton" yestext="OK"/>
+	</notification>
 	<notification name="GrantModifyRights">
 		Udzielenie praw modyfikacji innemu Rezydentowi umożliwia modyfikację, usuwanie lub wzięcie JAKIEGOKOLWIEK z Twoich obiektów. Używaj tej opcji z rozwagą!
 Czy chcesz udzielić prawa do modyfikacji [NAME]?
@@ -383,6 +387,9 @@ Pamiętaj: Opcja ta wyczyszcza bufor danych.
 	<notification name="ChangeSkin">
 		Nowa skórka zostanie wczytana po restarcie aplikacji [APP_NAME].
 	</notification>
+	<notification name="ChangeLanguage">
+		Zmiana języka zadziała po restarcie [APP_NAME].
+	</notification>
 	<notification name="GoToAuctionPage">
 		Odwiedzić stronę internetową [SECOND_LIFE] żeby zobaczyć szczgóły aukcji lub zrobić ofertę?
 		<usetemplate name="okcancelbuttons" notext="Anuluj" yestext="OK"/>
@@ -578,6 +585,10 @@ Oczekiwana - [VALIDS]
 	</notification>
 	<notification name="SoundFileInvalidHeader">
 		Brak bloku &apos;data&apos; w nagłówku pliku WAV:
+[FILE]
+	</notification>
+	<notification name="SoundFileInvalidChunkSize">
+		Niewłaściwy rozmiar &quot;chunk&quot; w pliku WAV:
 [FILE]
 	</notification>
 	<notification name="SoundFileInvalidTooLong">
@@ -917,7 +928,7 @@ Zaproponować znajomość [NAME]?
 			<input name="message">
 				[DESC] (nowe)
 			</input>
-			<button name="Offer" text="OK"/>
+			<button name="OK" text="OK"/>
 			<button name="Cancel" text="Anuluj"/>
 		</form>
 	</notification>
@@ -927,7 +938,7 @@ Zaproponować znajomość [NAME]?
 			<input name="message">
 				[DESC] (nowy)
 			</input>
-			<button name="Offer" text="OK"/>
+			<button name="OK" text="OK"/>
 			<button name="Cancel" text="Anuluj"/>
 		</form>
 	</notification>
@@ -937,7 +948,7 @@ Zaproponować znajomość [NAME]?
 			<input name="new_name">
 				[NAME]
 			</input>
-			<button name="Offer" text="OK"/>
+			<button name="OK" text="OK"/>
 			<button name="Cancel" text="Anuluj"/>
 		</form>
 	</notification>
@@ -1303,6 +1314,40 @@ Aktualizacja nie jest wymagana ale jest zalecana w celu poprawy prędkości i st
 Pobrać i zapisać w folderze Aplikacji?
 		<usetemplate name="okcancelbuttons" notext="Kontynuuj" yestext="Załaduj"/>
 	</notification>
+	<notification name="FailedUpdateInstall">
+		Podczas aktualizacji pojawił się błąd. Proszę pobrać i zainstalować najnowszego klienta z http://secondlife.com/download.
+		<usetemplate name="okbutton" yestext="OK"/>
+	</notification>
+	<notification name="FailedRequiredUpdateInstall">
+		Nie można zainstalować wymaganej aktualizacji. Nie będzie można zalogować się dopóki [APP_NAME] nie zostanie zaktualizowana.
+				Proszę pobrać i zainstalować najnowszą wersję z http://secondlife.com/download.
+		<usetemplate name="okbutton" yestext="Rezygnuj"/>
+	</notification>
+	<notification name="UpdaterServiceNotRunning">
+		Istnieje obowiązkowa aktualizacja dla Second Life. Możesz ją pobrać z http://www.secondlife.com/downloads lub zainstalować teraz.
+		<usetemplate name="okcancelbuttons" notext="Opuść Second Life" yestext="Pobierz i zainstaluj teraz"/>
+	</notification>
+	<notification name="DownloadBackgroundTip">
+		Aktualizacja dla [APP_NAME] została pobrana.
+Wersja [VERSION] [[RELEASE_NOTES_FULL_URL] Informacja o tej aktualizacji]
+		<usetemplate name="okcancelbuttons" notext="Później..." yestext="Zainstaluj teraz i restartuj [APP_NAME]"/>
+	</notification>
+	<notification name="DownloadBackgroundDialog">
+		Aktualizacja [APP_NAME] została pobrana.
+Wersja [VERSION] [[RELEASE_NOTES_FULL_URL] Informacja o aktualizacji]
+		<usetemplate name="okcancelbuttons" notext="Później..." yestext="Zainstaluj teraz i restartuj [APP_NAME]"/>
+	</notification>
+	<notification name="RequiredUpdateDownloadedVerboseDialog">
+		Pobrano wymaganÄ… aktualizacjÄ™.
+Wersja [VERSION]
+
+W celu instalacji aktualizacji musi zostać wykonany restart [APP_NAME].
+		<usetemplate name="okbutton" yestext="OK"/>
+	</notification>
+	<notification name="RequiredUpdateDownloadedDialog">
+		W celu instalacji aktualizacji musi zostać wykonany restart [APP_NAME].
+		<usetemplate name="okbutton" yestext="OK"/>
+	</notification>
 	<notification name="DeedObjectToGroup">
 		Przekazanie tego obiektu spowoduje, że grupa:
 * Otrzyma L$ zapłacone temu obiektowi
@@ -2171,14 +2216,6 @@ Spróbuj wybrać mniejszy obszar.
 	<notification name="NoContentToSearch">
 		Proszę wybrać przynajmiej jeden z podanych rodzajów treści jaką zawiera region podczas wyszukiwania (&apos;General&apos;, &apos;Moderate&apos;, lub &apos;Adult&apos;).
 	</notification>
-	<notification name="GroupVote">
-		[NAME] zaprasza do głosowania nad propozycją:
-[MESSAGE]
-		<form name="form">
-			<button name="VoteNow" text="GÅ‚osuj Teraz"/>
-			<button name="Later" text="Później"/>
-		</form>
-	</notification>
 	<notification name="SystemMessage">
 		[MESSAGE]
 	</notification>
@@ -2440,8 +2477,8 @@ Spróbuj ponowanie za kilka minut.
 		Propozycja znajomości została odrzucona.
 	</notification>
 	<notification name="OfferCallingCard">
-		[NAME] daje Tobie swoją wizytówkę.
-Wizytówka będzie znajdowała się w Szafie i umożliwi szybkie wysłanie IM do tego Rezydenta.
+		[NAME] oferuje swoją wizytówkę.
+Wizytówka w Twojej Szafie umożliwi szybki kontakt IM z tym Rezydentem.
 		<form name="form">
 			<button name="Accept" text="Zaakceptuj"/>
 			<button name="Decline" text="Odmów"/>
@@ -2635,9 +2672,6 @@ Wybierz Zaakceptuj żeby zacząć czat albo Odmów żeby nie przyjąć zaproszen
 	<notification name="VoiceCallGenericError">
 		Błąd podczas łączenia z rozmową [VOICE_CHANNEL_NAME]. Spróbuj póżniej.
 	</notification>
-	<notification name="ServerVersionChanged">
-		Ten region używa innej wersji symulatora. Kliknij na tą wiadomość żeby uzyskać więcej informacji: [[URL] View the release notes.]
-	</notification>
 	<notification name="UnsupportedCommandSLURL">
 		Nie można otworzyć wybranego SLurl.
 	</notification>
@@ -2740,9 +2774,7 @@ Awatar &apos;[NAME]&apos; opuścił edycję wyglądu.
 	<notification name="NoConnect">
 		Występuje problem z połączeniem [PROTOCOL] [HOSTID].
 Proszę sprawdź swoją sieć i ustawienia firewall.
-		<form name="form">
-			<button name="OK" text="OK"/>
-		</form>
+		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="NoVoiceConnect">
 		Występuje problem z Twoim połączniem głosowym:
@@ -2751,9 +2783,7 @@ Proszę sprawdź swoją sieć i ustawienia firewall.
 
 Komunikacja głosowa nie będzie dostępna.
 Proszę sprawdź swoją sieć i ustawienia firewall.
-		<form name="form">
-			<button name="OK" text="OK"/>
-		</form>
+		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="AvatarRezLeftNotification">
 		( [EXISTENCE] sekund w Second Life)
@@ -2787,6 +2817,9 @@ Wyciszyć wszystkich?
 	<notification label="Odkrywaj Åšwiat" name="HintDestinationGuide">
 		Destination Guide zawiera tysiące nowych miejsc do odkrycia. Wybierz lokalizację i teleportuj się aby rozpocząć zwiedzanie.
 	</notification>
+	<notification label="Zmień wygląd swojego awatara" name="HintAvatarPicker">
+		Czy chcesz inaczej wyglądać? Kliknij poniższy przycisk aby zobaczyć więcej przykładów awatarów.
+	</notification>
 	<notification label="Schowek" name="HintSidePanel">
 		Schowek umożliwia szybki dostęp do Twojej Szafy, ubrań, profili i innych w panelu bocznym.
 	</notification>
@@ -2796,6 +2829,12 @@ Wyciszyć wszystkich?
 	<notification label="Wyświetlana nazwa" name="HintDisplayName">
 		Ustaw wyświetlaną nazwę, którą możesz zmieniać tutaj. Jest ona dodatkiem do unikatowej nazwy użytkownika, która nie może być zmieniona. Możesz zmienić sposób w jaki widzisz nazwy innych osób w Twoich Ustawieniach.
 	</notification>
+	<notification label="Ruch" name="HintMoveArrows">
+		Użyj przycisków ze strzałkami z klawiatury aby chodzić. Jeśli wciśniesz strzałkę &apos;do góry&apos; podwójnie, zaczniesz biec.
+	</notification>
+	<notification label="Widok" name="HintView">
+		To change your camera view, use the Orbit and Pan controls. Zresetuj widok poprzez wciśnięcie klawisza Esc lub chodzenie.
+	</notification>
 	<notification label="Szafa" name="HintInventory">
 		Sprawdź swoją Szafę aby znaleźć obiekty. Najnowsze obiekty mogą być łatwo odnalezione w zakładce Nowe obiekty.
 	</notification>
@@ -2809,6 +2848,15 @@ Wyciszyć wszystkich?
 			<button name="open" text="Otwórz wyskakujące okno."/>
 		</form>
 	</notification>
+	<notification name="AuthRequest">
+		Strpna &apos;&lt;nolink&gt;[HOST_NAME]&lt;/nolink&gt;&apos; w domenie &apos;[REALM]&apos; wymaga nazwy użytkownika i hasła.
+		<form name="form">
+			<input name="username" text="Nazwa użytkownika"/>
+			<input name="password" text="Hasło"/>
+			<button name="ok" text="Wyślij"/>
+			<button name="cancel" text="Anuluj"/>
+		</form>
+	</notification>
 	<global name="UnsupportedCPU">
 		- Prędkość Twojego CPU nie spełnia minimalnych wymagań.
 	</global>
diff --git a/indra/newview/skins/default/xui/pl/panel_avatar_list_item.xml b/indra/newview/skins/default/xui/pl/panel_avatar_list_item.xml
index 1ab95eec0023f815ddbc3bf17f200ee8d9752cd5..c43a9bed811a09ba51110abfb79cd349297a2beb 100644
--- a/indra/newview/skins/default/xui/pl/panel_avatar_list_item.xml
+++ b/indra/newview/skins/default/xui/pl/panel_avatar_list_item.xml
@@ -21,7 +21,7 @@
 	<string name="FormatYears">
 		[COUNT]lat
 	</string>
-	<text name="avatar_name" value="Nieznane"/>
+	<text name="avatar_name" value="(Å‚adowanie)"/>
 	<icon name="permission_edit_theirs_icon" tool_tip="Możesz edytować obiekty tego Znajomego"/>
 	<icon name="permission_edit_mine_icon" tool_tip="Ten Znajomy może edytować, kasować lub wziąć Twoje obiekty"/>
 	<icon name="permission_map_icon" tool_tip="Ten Znajomy może zlokalizować Ciebie na mapie"/>
diff --git a/indra/newview/skins/default/xui/pl/panel_edit_alpha.xml b/indra/newview/skins/default/xui/pl/panel_edit_alpha.xml
index a22d4b048273b634f8241b7d448d3c31f7d2b4cd..51ee3af00d830402797ff0f707f7ec7db9e2c917 100644
--- a/indra/newview/skins/default/xui/pl/panel_edit_alpha.xml
+++ b/indra/newview/skins/default/xui/pl/panel_edit_alpha.xml
@@ -1,10 +1,12 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel name="edit_alpha_panel">
-	<panel name="avatar_alpha_color_panel">
-		<texture_picker label="Alpha dolnej części ciała" name="Lower Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
-		<texture_picker label="Alpha górnej części ciała" name="Upper Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
-		<texture_picker label="Alpha głowy" name="Head Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
-		<texture_picker label="Alpha oka" name="Eye Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
-		<texture_picker label="Alpha włosów" name="Hair Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
-	</panel>
+	<scroll_container name="avatar_alpha_color_panel_scroll">
+		<panel name="avatar_alpha_color_panel">
+			<texture_picker label="Alpha dolnej części ciała" name="Lower Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
+			<texture_picker label="Alpha górnej części ciała" name="Upper Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
+			<texture_picker label="Alpha głowy" name="Head Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
+			<texture_picker label="Alpha oka" name="Eye Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
+			<texture_picker label="Alpha włosów" name="Hair Alpha" tool_tip="Kliknij aby wybrać teksturę"/>
+		</panel>
+	</scroll_container>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_edit_gloves.xml b/indra/newview/skins/default/xui/pl/panel_edit_gloves.xml
index 166e3c4551f48ec0e1383527bb90dfc034360fd2..d32646d1a3db242c84d980388061d617f63a03d2 100644
--- a/indra/newview/skins/default/xui/pl/panel_edit_gloves.xml
+++ b/indra/newview/skins/default/xui/pl/panel_edit_gloves.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel name="edit_gloves_panel">
 	<panel name="avatar_gloves_color_panel">
-		<texture_picker label="Materiał" name="Fabric" tool_tip="Kliknij aby wybrać teksturę"/>
+		<texture_picker label="Tekstura" name="Fabric" tool_tip="Kliknij aby wybrać teksturę"/>
 		<color_swatch label="Kolor/Barwa" name="Color/Tint" tool_tip="Kliknij aby wybrać teksturę"/>
 	</panel>
 	<panel name="accordion_panel">
diff --git a/indra/newview/skins/default/xui/pl/panel_edit_jacket.xml b/indra/newview/skins/default/xui/pl/panel_edit_jacket.xml
index ba0b908394bdb649874d48008b1adf267e8e3f4d..7653e84cc09ed74993e1e15969ba80f090305318 100644
--- a/indra/newview/skins/default/xui/pl/panel_edit_jacket.xml
+++ b/indra/newview/skins/default/xui/pl/panel_edit_jacket.xml
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel name="edit_jacket_panel">
 	<panel name="avatar_jacket_color_panel">
-		<texture_picker label="Górny materiał" name="Upper Fabric" tool_tip="Kliknij aby wybrać teksturę"/>
-		<texture_picker label="Dolny materiał" name="Lower Fabric" tool_tip="Kliknij aby wybrać teksturę"/>
+		<texture_picker label="Górna tekstura" name="Upper Fabric" tool_tip="Kliknij aby wybrać teksturę"/>
+		<texture_picker label="Dolna tekstura" name="Lower Fabric" tool_tip="Kliknij aby wybrać teksturę"/>
 		<color_swatch label="Kolor/Barwa" name="Color/Tint" tool_tip="Kliknij aby wybrać kolor"/>
 	</panel>
 	<panel name="accordion_panel">
diff --git a/indra/newview/skins/default/xui/pl/panel_edit_pants.xml b/indra/newview/skins/default/xui/pl/panel_edit_pants.xml
index 4adac604f4600ece614358b80ff1cc17f703b223..7975e5574672a5691ef65bbe1f8e659b29922b9a 100644
--- a/indra/newview/skins/default/xui/pl/panel_edit_pants.xml
+++ b/indra/newview/skins/default/xui/pl/panel_edit_pants.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel name="edit_pants_panel">
 	<panel name="avatar_pants_color_panel">
-		<texture_picker label="Materiał" name="Fabric" tool_tip="Kliknij aby wybrać teksturę"/>
+		<texture_picker label="Tekstura" name="Fabric" tool_tip="Kliknij aby wybrać teksturę"/>
 		<color_swatch label="Kolor/Barwa" name="Color/Tint" tool_tip="Kliknij aby wybrać kolor"/>
 	</panel>
 	<panel name="accordion_panel">
diff --git a/indra/newview/skins/default/xui/pl/panel_edit_shirt.xml b/indra/newview/skins/default/xui/pl/panel_edit_shirt.xml
index 3bcf992d4d98648ba4f379a58749f1662fb68327..9530c781ab839091ada6722205eb00ef749397e8 100644
--- a/indra/newview/skins/default/xui/pl/panel_edit_shirt.xml
+++ b/indra/newview/skins/default/xui/pl/panel_edit_shirt.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel name="edit_shirt_panel">
 	<panel name="avatar_shirt_color_panel">
-		<texture_picker label="Materiał" name="Fabric" tool_tip="Kliknij by wybrać grafikę"/>
+		<texture_picker label="Tekstura" name="Fabric" tool_tip="Kliknij by wybrać grafikę"/>
 		<color_swatch label="Kolor/Odcień" name="Color/Tint" tool_tip="Kliknij by wybrać kolor"/>
 	</panel>
 	<panel name="accordion_panel">
diff --git a/indra/newview/skins/default/xui/pl/panel_edit_shoes.xml b/indra/newview/skins/default/xui/pl/panel_edit_shoes.xml
index e2c00c05069d0bbf2d5c9231eae085f1794001a1..d90a6d8726658e02066f47f96f8abb475709d330 100644
--- a/indra/newview/skins/default/xui/pl/panel_edit_shoes.xml
+++ b/indra/newview/skins/default/xui/pl/panel_edit_shoes.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel name="edit_shoes_panel">
 	<panel name="avatar_shoes_color_panel">
-		<texture_picker label="Materiał" name="Fabric" tool_tip="Kliknij aby wybrać teksturę"/>
+		<texture_picker label="Tekstura" name="Fabric" tool_tip="Kliknij aby wybrać teksturę"/>
 		<color_swatch label="Kolor/Barwa" name="Color/Tint" tool_tip="Kliknij aby wybrać kolor"/>
 	</panel>
 	<panel name="accordion_panel">
diff --git a/indra/newview/skins/default/xui/pl/panel_edit_skirt.xml b/indra/newview/skins/default/xui/pl/panel_edit_skirt.xml
index 3fa9cefeb67fe97602a5fdb1ee796a4bd02b2c22..f74ad916cd47b3fbdcd67c992d0ebcb4593bd344 100644
--- a/indra/newview/skins/default/xui/pl/panel_edit_skirt.xml
+++ b/indra/newview/skins/default/xui/pl/panel_edit_skirt.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel name="edit_skirt_panel">
 	<panel name="avatar_skirt_color_panel">
-		<texture_picker label="Materiał" name="Fabric" tool_tip="Kliknij aby wybrać teksturę"/>
+		<texture_picker label="Tekstura" name="Fabric" tool_tip="Kliknij aby wybrać teksturę"/>
 		<color_swatch label="Kolor/Barwa" name="Color/Tint" tool_tip="Kliknij aby wybrać kolor"/>
 	</panel>
 	<panel name="accordion_panel">
diff --git a/indra/newview/skins/default/xui/pl/panel_edit_socks.xml b/indra/newview/skins/default/xui/pl/panel_edit_socks.xml
index bb2cd637b5fcd1de3711f3b7437400b1c0a712ac..b41069e8d75f53ca803ba3b6065f743ba3b5b74d 100644
--- a/indra/newview/skins/default/xui/pl/panel_edit_socks.xml
+++ b/indra/newview/skins/default/xui/pl/panel_edit_socks.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel name="edit_socks_panel">
 	<panel name="avatar_socks_color_panel">
-		<texture_picker label="Materiał" name="Fabric" tool_tip="Kliknij aby wybrać teksturę"/>
+		<texture_picker label="Tekstura" name="Fabric" tool_tip="Kliknij aby wybrać teksturę"/>
 		<color_swatch label="Kolor/Barwa" name="Color/Tint" tool_tip="Kliknij aby wybrać kolor"/>
 	</panel>
 	<panel name="accordion_panel">
diff --git a/indra/newview/skins/default/xui/pl/panel_edit_underpants.xml b/indra/newview/skins/default/xui/pl/panel_edit_underpants.xml
index 010d9b53d9ceaaf074b38d32e990426fda334bdb..f2a9b10f17371cdace338a68ce33269bd3e8a7c9 100644
--- a/indra/newview/skins/default/xui/pl/panel_edit_underpants.xml
+++ b/indra/newview/skins/default/xui/pl/panel_edit_underpants.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel name="edit_underpants_panel">
 	<panel name="avatar_underpants_color_panel">
-		<texture_picker label="Materiał" name="Fabric" tool_tip="Kliknij aby wybrać kolor"/>
+		<texture_picker label="Tekstura" name="Fabric" tool_tip="Kliknij aby wybrać kolor"/>
 		<color_swatch label="Kolor/Barwa" name="Color/Tint" tool_tip="Kliknij aby wybrać kolor"/>
 	</panel>
 	<panel name="accordion_panel">
diff --git a/indra/newview/skins/default/xui/pl/panel_edit_undershirt.xml b/indra/newview/skins/default/xui/pl/panel_edit_undershirt.xml
index 63ae1215e09ed70aae932993042e83749d2a40d3..7da1341e96be4dad20e028ef97cda0b8ae00fb7b 100644
--- a/indra/newview/skins/default/xui/pl/panel_edit_undershirt.xml
+++ b/indra/newview/skins/default/xui/pl/panel_edit_undershirt.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel name="edit_undershirt_panel">
 	<panel name="avatar_undershirt_color_panel">
-		<texture_picker label="Materiał" name="Fabric" tool_tip="Kliknij aby wybrać teksturę"/>
+		<texture_picker label="Tekstura" name="Fabric" tool_tip="Kliknij aby wybrać teksturę"/>
 		<color_swatch label="Kolor/Barwa" name="Color/Tint" tool_tip="Kliknij aby wybrać kolor"/>
 	</panel>
 	<panel name="accordion_panel">
diff --git a/indra/newview/skins/default/xui/pl/panel_login.xml b/indra/newview/skins/default/xui/pl/panel_login.xml
index 30432c509d5703a1b4f793bc09429aa59ff20b68..81da94a65952e37aec3130f46b2b95ee9b191f80 100644
--- a/indra/newview/skins/default/xui/pl/panel_login.xml
+++ b/indra/newview/skins/default/xui/pl/panel_login.xml
@@ -1,8 +1,5 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel name="panel_login">
-	<panel.string name="real_url">
-		http://secondlife.com/app/login/
-	</panel.string>
 	<panel.string name="forgot_password_url">
 		http://secondlife.com/account/request.php
 	</panel.string>
@@ -11,7 +8,7 @@
 			<text name="username_text">
 				Użytkownik:
 			</text>
-			<line_editor label="bobsmith12 lub Steller Sunshine" name="username_edit" tool_tip="Nazwę użytkownika wybierasz podczas rejestracji, np: like bobsmith12 lub Steller Sunshine"/>
+			<combo_box name="username_combo" tool_tip="Nazwę użytkownika wybierasz przy rejestracji, np. bobsmith12 lub Steller Sunshine"/>
 			<text name="password_text">
 				Hasło:
 			</text>
diff --git a/indra/newview/skins/default/xui/pl/panel_my_profile.xml b/indra/newview/skins/default/xui/pl/panel_my_profile.xml
index 6b0ba44bb49b583eb9349a4c4668ab00c2e6b946..cdc833241d650d51815debdb80f2d59b37a65bce 100644
--- a/indra/newview/skins/default/xui/pl/panel_my_profile.xml
+++ b/indra/newview/skins/default/xui/pl/panel_my_profile.xml
@@ -5,30 +5,27 @@
 	<string name="RegisterDateFormat">
 		[REG_DATE] ([AGE])
 	</string>
+	<string name="name_text_args">
+		[NAME]
+	</string>
+	<string name="display_name_text_args">
+		[DISPLAY_NAME]
+	</string>
 	<layout_stack name="layout">
 		<layout_panel name="profile_stack">
 			<scroll_container name="profile_scroll">
 				<panel name="scroll_content_panel">
 					<panel name="second_life_image_panel">
-						<icon label="" name="2nd_life_edit_icon" tool_tip="Kliknij przycisk Edytuj profil by zmienić zdjęcie"/>
-						<text name="title_sl_descr_text" value="[SECOND_LIFE]:"/>
-					</panel>
-					<panel name="first_life_image_panel">
-						<icon label="" name="real_world_edit_icon" tool_tip="Kliknij przycisk Edytuj profil by zmienić zdjęcie"/>
-						<text name="title_rw_descr_text" value="Życie#1:"/>
-					</panel>
-					<text name="title_member_text" value="Urodziny:"/>
-					<text name="title_acc_status_text" value="Konto:"/>
-					<text name="title_partner_text" value="Partner:"/>
-					<panel name="partner_data_panel">
-						<name_box initial_value="(przetwarzanie)" name="partner_text"/>
+						<text name="display_name_descr_text">
+							Nazwa użytkownika
+						</text>
+						<text name="name_descr_text">
+							Wyświetlana nazwa
+						</text>
+						<button label="Profil" name="see_profile_btn" tool_tip="Zobacz profil tego awatara"/>
 					</panel>
-					<text name="title_groups_text" value="Grupy:"/>
 				</panel>
 			</scroll_container>
 		</layout_panel>
 	</layout_stack>
-	<panel name="profile_me_buttons_panel">
-		<button label="Edytuj profil" name="edit_profile_btn" tool_tip="Edytuj informacje o sobie"/>
-	</panel>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_notify_textbox.xml b/indra/newview/skins/default/xui/pl/panel_notify_textbox.xml
new file mode 100644
index 0000000000000000000000000000000000000000..e1668e1ef15cfab25aae5600001baf6ea66e66c6
--- /dev/null
+++ b/indra/newview/skins/default/xui/pl/panel_notify_textbox.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<panel label="instant_message" name="panel_notify_textbox">
+	<string name="message_max_lines_count" value="7"/>
+	<panel label="info_panel" name="info_panel">
+		<text_editor name="message" value="wiadomość"/>
+	</panel>
+	<panel label="control_panel" name="control_panel">
+		<button label="Wyślij" name="btn_submit"/>
+		<button label="Ignoruj" name="ignore_btn"/>
+	</panel>
+</panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_people.xml b/indra/newview/skins/default/xui/pl/panel_people.xml
index fcb6b196350588dcc8f2ba4d6b4da9315d058624..1bd5b4a9123f15f536a6f461c7366f3c537601e3 100644
--- a/indra/newview/skins/default/xui/pl/panel_people.xml
+++ b/indra/newview/skins/default/xui/pl/panel_people.xml
@@ -22,7 +22,7 @@ Chcesz spotkać ludzi? Spróbuj [secondlife:///app/worldmap Mapa Świata].
 	<tab_container name="tabs">
 		<panel label="W POBLIŻU" name="nearby_panel">
 			<panel label="bottom_panel" name="bottom_panel">
-				<button name="nearby_view_sort_btn" tool_tip="Opcje"/>
+				<menu_button name="nearby_view_sort_btn" tool_tip="Opcje"/>
 				<button name="add_friend_btn" tool_tip="Dodaj wybranego Rezydenta do znajomych"/>
 			</panel>
 		</panel>
@@ -34,27 +34,27 @@ Chcesz spotkać ludzi? Spróbuj [secondlife:///app/worldmap Mapa Świata].
 			<panel label="bottom_panel" name="bottom_panel">
 				<layout_stack name="bottom_panel">
 					<layout_panel name="options_gear_btn_panel">
-						<button name="friends_viewsort_btn" tool_tip="Pokaż opcje dodatkowe"/>
+						<menu_button name="friends_viewsort_btn" tool_tip="Pokaż opcje dodatkowe"/>
 					</layout_panel>
 					<layout_panel name="add_btn_panel">
 						<button name="add_btn" tool_tip="Dodaj wybranego Rezydenta do znajomych"/>
 					</layout_panel>
 					<layout_panel name="trash_btn_panel">
-						<dnd_button name="trash_btn" tool_tip="Usuń wybraną osobę ze swojej listy znajomych"/>
+						<dnd_button name="del_btn" tool_tip="Usuń zaznaczoną osobę ze swojej listy znajomych"/>
 					</layout_panel>
 				</layout_stack>
 			</panel>
 		</panel>
 		<panel label="GRUPY" name="groups_panel">
 			<panel label="bottom_panel" name="bottom_panel">
-				<button name="groups_viewsort_btn" tool_tip="Opcje"/>
+				<menu_button name="groups_viewsort_btn" tool_tip="Opcje"/>
 				<button name="plus_btn" tool_tip="Dołącz do grupy/Stwórz nową grupę"/>
 				<button name="activate_btn" tool_tip="Aktywuj wybranÄ… grupÄ™"/>
 			</panel>
 		</panel>
 		<panel label="OSTATNIE" name="recent_panel">
 			<panel label="bottom_panel" name="bottom_panel">
-				<button name="recent_viewsort_btn" tool_tip="Opcje"/>
+				<menu_button name="recent_viewsort_btn" tool_tip="Opcje"/>
 				<button name="add_friend_btn" tool_tip="Dodaj wybranego Rezydenta do znajomych"/>
 			</panel>
 		</panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_preferences_advanced.xml b/indra/newview/skins/default/xui/pl/panel_preferences_advanced.xml
index b267610d333f0903a53b556232638c24424e62df..5e61f6269131a78ebc784b9a89025757bd3c831b 100644
--- a/indra/newview/skins/default/xui/pl/panel_preferences_advanced.xml
+++ b/indra/newview/skins/default/xui/pl/panel_preferences_advanced.xml
@@ -3,35 +3,16 @@
 	<panel.string name="aspect_ratio_text">
 		[NUM]:[DEN]
 	</panel.string>
-	<panel.string name="middle_mouse">
-		Åšrodkowy klawisz myszki
-	</panel.string>
-	<slider label="KÄ…t widoku" name="camera_fov"/>
-	<slider label="Odległość" name="camera_offset_scale"/>
-	<text name="heading2">
-		Automatyczna pozycja dla:
-	</text>
-	<check_box label="Buduj/Edytuj" name="edit_camera_movement" tool_tip="Używaj automatycznego pozycjonowania kamery aktywując i deaktywując tryb edycji"/>
-	<check_box label="Wygląd" name="appearance_camera_movement" tool_tip="Używaj automatycznego pozycjonowania kamery podczas trybu edycji"/>
-	<check_box initial_value="prawda" label="Schowek" name="appearance_sidebar_positioning" tool_tip="Użyj automatycznego pozycjonowania kamery dla schowka"/>
-	<check_box label="Pokaż w trybie widoku panoramicznego" name="first_person_avatar_visible"/>
-	<check_box label="Aktywacja klawiszy strzałek do poruszania awatarem" name="arrow_keys_move_avatar_check"/>
-	<check_box label="Kliknij-kliknij-przytrzymaj, aby uruchomić" name="tap_tap_hold_to_run"/>
-	<check_box label="Poruszaj ustami awatara kiedy używana jest komunikacja głosowa" name="enable_lip_sync"/>
-	<check_box label="Czat chmurkowy" name="bubble_text_chat"/>
-	<slider label="Intensywność" name="bubble_chat_opacity"/>
-	<color_swatch name="background" tool_tip="Wybierz kolor czatu w chmurce"/>
 	<text name="UI Size:">
-		Rozmiar UI
+		rozmiar UI:
 	</text>
 	<check_box label="Pokaż błędy skryptu w:" name="show_script_errors"/>
 	<radio_group name="show_location">
 		<radio_item label="Czat Lokalny" name="0"/>
 		<radio_item label="Osobne okno:" name="1"/>
 	</radio_group>
-	<check_box label="Włącz/Wyłącz głos:" name="push_to_talk_toggle_check" tool_tip="Jeżeli jesteś w trybie mówienia, w celu aktywacji lub deaktywacji swojego mikrofonu wybierz i wyłącz przycisk Mów tylko raz. Jeżeli nie jesteś w trybie mówienia, mikrofon przesyła Twój głos tylko w momencie aktywacji pełnej przycisku Mów."/>
-	<line_editor label="Naciśnij Mów by rozpocząć komunikację głosową" name="modifier_combo"/>
-	<button label="Wybierz klawisz" name="set_voice_hotkey_button"/>
-	<button label="Środkowy przycisk myszki" name="set_voice_middlemouse_button" tool_tip="Zresetuj do środkowego przycisku myszy"/>
-	<button label="Inne urzÄ…dzenia" name="joystick_setup_button"/>
+	<check_box label="Pozwól na wiele przeglądarek" name="allow_multiple_viewer_check"/>
+	<check_box label="Pokaż selekcję siatki przy logowaniu" name="show_grid_selection_check"/>
+	<check_box label="Pokaz menu Zaawansowane" name="show_advanced_menu_check"/>
+	<check_box label="Pokaz menu Rozwinięcie" name="show_develop_menu_check"/>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_preferences_chat.xml b/indra/newview/skins/default/xui/pl/panel_preferences_chat.xml
index 87894bb35808bdbddc3c4b1f01f99c77d8ab29c5..c7142c8419969df8242705a6699ed435466e41ba 100644
--- a/indra/newview/skins/default/xui/pl/panel_preferences_chat.xml
+++ b/indra/newview/skins/default/xui/pl/panel_preferences_chat.xml
@@ -8,44 +8,10 @@
 		<radio_item label="Åšrednia" name="radio2" value="1"/>
 		<radio_item label="Duża" name="radio3" value="2"/>
 	</radio_group>
-	<text name="font_colors">
-		Kolor czcionki:
-	</text>
-	<color_swatch label="Ty" name="user"/>
-	<text name="text_box1">
-		Ja
-	</text>
-	<color_swatch label="Inni" name="agent"/>
-	<text name="text_box2">
-		Inni
-	</text>
-	<color_swatch label="IM" name="im"/>
-	<text name="text_box3">
-		IM
-	</text>
-	<color_swatch label="System" name="system"/>
-	<text name="text_box4">
-		System
-	</text>
-	<color_swatch label="Błędy" name="script_error"/>
-	<text name="text_box5">
-		Błędy
-	</text>
-	<color_swatch label="Obiekty" name="objects"/>
-	<text name="text_box6">
-		Obiekty
-	</text>
-	<color_swatch label="Właściciel" name="owner"/>
-	<text name="text_box7">
-		Właściciel
-	</text>
-	<color_swatch label="Linki" name="links"/>
-	<text name="text_box9">
-		Linki
-	</text>
 	<check_box initial_value="true" label="Używaj animacji podczas pisania" name="play_typing_animation"/>
 	<check_box label="Wysyłaj wszystkie wiadomości (IM) na moją skrzynkę pocztową kiedy jestem niedostępny" name="send_im_to_email"/>
 	<check_box label="Zwykły tekst IM i historia czatu" name="plain_text_chat_history"/>
+	<check_box label="Czat chmurkowy" name="bubble_text_chat"/>
 	<text name="show_ims_in_label">
 		Pokaż wiadomości (IM) w:
 	</text>
@@ -56,6 +22,13 @@
 		<radio_item label="Osobne okna" name="radio" value="0"/>
 		<radio_item label="Etykiety" name="radio2" value="1"/>
 	</radio_group>
+	<text name="disable_toast_label">
+		Uaktywnij wyskakujące okienka rozpoczynających się rozmów:
+	</text>
+	<check_box label="Czat grupy" name="EnableGroupChatPopups" tool_tip="Zaznacz aby widzieć wyskakuące okienka kiedy czat grupy się pojawia"/>
+	<check_box label="Czat IM" name="EnableIMChatPopups" tool_tip="Zaznacz aby widzieć wyskakujące okienka kiedy IM się pojawia"/>
+	<spinner label="Czas widoczności czatu w pobliżu:" name="nearby_toasts_lifetime"/>
+	<spinner label="Czas znikania czatu w pobliżu:" name="nearby_toasts_fadingtime"/>
 	<check_box label="Używaj translatora podczas rozmowy (wspierany przez Google)" name="translate_chat_checkbox"/>
 	<text name="translate_language_text">
 		Przetłumacz czat na:
diff --git a/indra/newview/skins/default/xui/pl/panel_preferences_colors.xml b/indra/newview/skins/default/xui/pl/panel_preferences_colors.xml
new file mode 100644
index 0000000000000000000000000000000000000000..3d1160882b6af1587c4bb4e71137391740b9f2d4
--- /dev/null
+++ b/indra/newview/skins/default/xui/pl/panel_preferences_colors.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<panel label="Kolory" name="colors_panel">
+	<text name="effects_color_textbox">
+		Moje efekty (selection beam):
+	</text>
+	<color_swatch name="effect_color_swatch" tool_tip="Kliknij aby wybrać kolor"/>
+	<text name="font_colors">
+		Kolor czcionki czatu:
+	</text>
+	<text name="text_box1">
+		Ja
+	</text>
+	<text name="text_box2">
+		Inni
+	</text>
+	<text name="text_box3">
+		Obiekty
+	</text>
+	<text name="text_box4">
+		System
+	</text>
+	<text name="text_box5">
+		Błędy
+	</text>
+	<text name="text_box7">
+		Właściciel
+	</text>
+	<text name="text_box9">
+		URL
+	</text>
+	<text name="bubble_chat">
+		Kolor tła taga (dotyczy również czatu chmurkowego):
+	</text>
+	<color_swatch name="background" tool_tip="Wybierz kolor taga"/>
+	<slider label="Przeźroczystość:" name="bubble_chat_opacity" tool_tip="Wybierz przeźroczystość taga"/>
+	<text name="floater_opacity">
+		Przeźroczystość:
+	</text>
+	<slider label="Aktywny:" name="active"/>
+	<slider label="Niekatywny:" name="inactive"/>
+</panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_preferences_general.xml b/indra/newview/skins/default/xui/pl/panel_preferences_general.xml
index 00dc84dd7a7604ed2afe60adadc1a53834d030b0..44dcb2112c845b292f336e05a3bc3fae5f5c283b 100644
--- a/indra/newview/skins/default/xui/pl/panel_preferences_general.xml
+++ b/indra/newview/skins/default/xui/pl/panel_preferences_general.xml
@@ -48,13 +48,18 @@
 	<check_box label="Nazwy użytkowników" name="show_slids" tool_tip="Pokaż nazwy użytkowników, np. bobsmith123"/>
 	<check_box label="Wyświetl tytuł grupowy" name="show_all_title_checkbox1" tool_tip="Wyświetl tytuł grupowy np. oficer"/>
 	<check_box label="Zaznacz znajomych" name="show_friends" tool_tip="Zaznacz imiona swoich znajomych"/>
-	<text name="effects_color_textbox">
-		Kolor moich efektów:
+	<check_box label="Pokaż wyświetlane nazwy" name="display_names_check" tool_tip="Pokaż wyświetlane nazwy w czacie, IM, imionach, etc."/>
+	<check_box label="Uaktywnij wskazówki UI" name="viewer_hints_check"/>
+	<text name="inworld_typing_rg_label">
+		Wciśnięcie klawiszy liter:
 	</text>
+	<radio_group name="inworld_typing_preference">
+		<radio_item label="WÅ‚Ä…cza czat lokalny" name="radio_start_chat" value="1"/>
+		<radio_item label="Wpływ na ruch (WASD)" name="radio_move" value="0"/>
+	</radio_group>
 	<text name="title_afk_text">
 		Zasypiaj w czasie:
 	</text>
-	<color_swatch label="" name="effect_color_swatch" tool_tip="Selekcja koloru"/>
 	<combo_box label="Czas Trybu Oddalenia:" name="afk">
 		<combo_box.item label="2 minuty" name="item0"/>
 		<combo_box.item label="5 minut" name="item1"/>
@@ -62,7 +67,6 @@
 		<combo_box.item label="30 minut" name="item3"/>
 		<combo_box.item label="nigdy" name="item4"/>
 	</combo_box>
-	<check_box label="Pokaż wyświetlane nazwy" name="display_names_check" tool_tip="Pokaż wyświetlane nazwy w czacie, IM, imionach, etc."/>
 	<text name="text_box3">
 		Odpowiedź w trybie pracy:
 	</text>
diff --git a/indra/newview/skins/default/xui/pl/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/pl/panel_preferences_graphics1.xml
index 1a9f59bbffb65699b052522064eca815a7cd37e3..0f21aa9dd1f467e674ed1dc3e634e6d722f7c1c6 100644
--- a/indra/newview/skins/default/xui/pl/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/pl/panel_preferences_graphics1.xml
@@ -26,6 +26,7 @@
 		<text name="ShadersText">
 			Cieniowanie pixeli (shadery):
 		</text>
+		<check_box initial_value="prawda" label="Przeźroczystość wody" name="TransparentWater"/>
 		<check_box initial_value="true" label="Mapowanie wypukłości i połysk" name="BumpShiny"/>
 		<check_box initial_value="true" label="Podstawowe shadery" name="BasicShaders" tool_tip="Wyłączenie tej opcji może naprawić błędy niektórych sterowników graficznych."/>
 		<check_box initial_value="true" label="Shadery atmosfery" name="WindLightUseAtmosShaders"/>
diff --git a/indra/newview/skins/default/xui/pl/panel_preferences_move.xml b/indra/newview/skins/default/xui/pl/panel_preferences_move.xml
new file mode 100644
index 0000000000000000000000000000000000000000..4c2df2c1f3f022769f7bc3faf9fa04b6206fe581
--- /dev/null
+++ b/indra/newview/skins/default/xui/pl/panel_preferences_move.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<panel label="Ruch" name="move_panel">
+	<slider label="KÄ…t widoku kamery" name="camera_fov"/>
+	<slider label="Dystans kamery" name="camera_offset_scale"/>
+	<text name="heading2">
+		Automatyczna pozycja dla:
+	</text>
+	<check_box label="Budowanie/Edycja" name="edit_camera_movement" tool_tip="Używaj automatycznego pozycjonowania kamery podczas włączania i wyłączania trybu edycji."/>
+	<check_box label="Wygląd" name="appearance_camera_movement" tool_tip="Używaj automatycznego pozycjonowania kamery podczas trybu edycji"/>
+	<check_box initial_value="prawda" label="Schowek" name="appearance_sidebar_positioning" tool_tip="Używaj automatycznego pozycjonowania kamery dla panelu bocznego"/>
+	<check_box label="Awatar widoczny w trybie panoramicznym" name="first_person_avatar_visible"/>
+	<text name=" Mouse Sensitivity">
+		Czułość myszki w widoku panoramicznym:
+	</text>
+	<check_box label="Zmień klawisze myszki" name="invert_mouse"/>
+	<check_box label="Przyciski ze strzałkami zawsze poruszają awatarem" name="arrow_keys_move_avatar_check"/>
+	<check_box label="Wciśnij-wciśnij-przytrzymaj aby biec" name="tap_tap_hold_to_run"/>
+	<check_box label="Podwójnie kliknij aby:" name="double_click_chkbox"/>
+	<radio_group name="double_click_action">
+		<radio_item label="teleportować się" name="radio_teleport"/>
+		<radio_item label="włączyć auto-pilota" name="radio_autopilot"/>
+	</radio_group>
+	<button label="Inne urzÄ…dzenia" name="joystick_setup_button"/>
+</panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_preferences_privacy.xml b/indra/newview/skins/default/xui/pl/panel_preferences_privacy.xml
index fd9cdd6ff0af18a934e9b82ba1ef0f241b6e7b06..a2f9b4176e1fe1b0f7a39cc5291a0d924d9ee7f9 100644
--- a/indra/newview/skins/default/xui/pl/panel_preferences_privacy.xml
+++ b/indra/newview/skins/default/xui/pl/panel_preferences_privacy.xml
@@ -7,19 +7,24 @@
 	<text name="cache_size_label_l">
 		(Miejsca, obrazy, przeglÄ…darka internetowa, wyszukiwarka historii)
 	</text>
+	<check_box label="Pokaż mój profil w wynikach wyszukiwarki" name="online_searchresults"/>
 	<check_box label="Mój status online jest dostępny tylko dla znajomych i grup do których należę" name="online_visibility"/>
 	<check_box label="Możliwość wysyłania wiadomości prywatnej (IM) oraz rozmowy głosowej tylko dla znajomych i grup do których należę" name="voice_call_friends_only_check"/>
 	<check_box label="Wyłącz mikrofon po zakończeniu rozmowy głosowej" name="auto_disengage_mic_check"/>
-	<check_box label="Akceptuj ciasteczka" name="cookies_enabled"/>
+	<check_box label="Pokaż moje ulubione landmarki przy logowaniu (w rozwijanym menu &apos;Rozpocznij w&apos;)" name="favorites_on_login_check"/>
 	<text name="Logs:">
-		Logi:
+		Logi rozmów:
 	</text>
 	<check_box label="Zapisz logi rozmów ogólnych na moim komputerze" name="log_nearby_chat"/>
 	<check_box label="Zapisuj logi wiadomości prywatnych (IM) na moim komputerze" name="log_instant_messages"/>
-	<check_box label="Pokazuj czas" name="show_timestamps_check_im"/>
+	<check_box label="Dodaj znacznik czasu do każdej linii w logu rozmów." name="show_timestamps_check_im"/>
+	<check_box label="Dodaj znacznik czasu do nazwy pliku z zapisem rozmów." name="logfile_name_datestamp"/>
 	<text name="log_path_desc">
 		Lokalizacja zapisu:
 	</text>
 	<button label="PrzeglÄ…daj" label_selected="PrzeglÄ…daj" name="log_path_button"/>
 	<button label="Lista zablokowanych" name="block_list"/>
+	<text name="block_list_label">
+		(Ludzie i/lub obiekty zablokowane)
+	</text>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_preferences_setup.xml b/indra/newview/skins/default/xui/pl/panel_preferences_setup.xml
index 24e5c2b8243004ce1842cda95d83fa7e370d9b63..fa0a5981a8711f62b775bf2f231710522d54790b 100644
--- a/indra/newview/skins/default/xui/pl/panel_preferences_setup.xml
+++ b/indra/newview/skins/default/xui/pl/panel_preferences_setup.xml
@@ -1,13 +1,5 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="Ustawienia" name="Input panel">
-	<text name="Mouselook:">
-		Widok panoramiczny:
-	</text>
-	<text name=" Mouse Sensitivity">
-		Czułość myszki
-	</text>
-	<slider name="mouse_sensitivity"/>
-	<check_box label="Zmień klawisze myszki" name="invert_mouse"/>
 	<text name="Network:">
 		Sieć:
 	</text>
@@ -47,4 +39,11 @@
 	</text>
 	<line_editor name="web_proxy_editor" tool_tip="Nazwa lub IP proxy, którego chcesz użyć"/>
 	<spinner label="Numer portu:" name="web_proxy_port"/>
+	<text name="Software updates:">
+		Aktualizaje oprogramowania:
+	</text>
+	<combo_box name="updater_service_combobox">
+		<combo_box.item label="Zainstauj automatycznie" name="Install_automatically"/>
+		<combo_box.item label="Pobierz i zainstaluj aktualizacje ręcznie" name="Install_manual"/>
+	</combo_box>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_preferences_sound.xml b/indra/newview/skins/default/xui/pl/panel_preferences_sound.xml
index eaf9ae809b3dda458ba3a852f6c1bb8f2fc44327..c708cc0b99f6e61441502d2aa6be3f8577041ed0 100644
--- a/indra/newview/skins/default/xui/pl/panel_preferences_sound.xml
+++ b/indra/newview/skins/default/xui/pl/panel_preferences_sound.xml
@@ -1,5 +1,8 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="Dźwięki" name="Preference Media panel">
+	<panel.string name="middle_mouse">
+		Åšrodkowy przycisk myszy
+	</panel.string>
 	<slider label="Główny" name="System Volume"/>
 	<check_box initial_value="true" label="Wycisz podczas minimalizacji" name="mute_when_minimized"/>
 	<slider label="Interfejs" name="UI Volume"/>
@@ -23,6 +26,11 @@
 		<radio_item label="pozycji kamery" name="0"/>
 		<radio_item label="pozycji awatara" name="1"/>
 	</radio_group>
+	<check_box label="Poruszaj ustami awatara podczas mówienia" name="enable_lip_sync"/>
+	<check_box label="Włącz/wyłącz mikrofon kiedy naciskam:" name="push_to_talk_toggle_check" tool_tip="Kiedy aktywny jest tryb przełączania wciśnij i zwolnij przełącznik RAZ aby włączyć lub wyłączyć mikrofon. Kiedy tryb przełączania nie jest aktywny mikrofon nadaje głos tylko kiedy przełącznik jest wciśnięty."/>
+	<line_editor label="Przełącznik kliknij-aby-mówić" name="modifier_combo"/>
+	<button label="Ustaw klawisz" name="set_voice_hotkey_button"/>
+	<button name="set_voice_middlemouse_button" tool_tip="Zresetuj do środkowego przycisku myszy"/>
 	<button label="Wejściowe/Wyjściowe urządzenia" name="device_settings_btn"/>
 	<panel label="Ustawienia sprzętowe" name="device_settings_panel">
 		<panel.string name="default_text">
diff --git a/indra/newview/skins/default/xui/pl/panel_script_ed.xml b/indra/newview/skins/default/xui/pl/panel_script_ed.xml
index fa89a3f72767ad4824ff26b7ff522b1621248e2c..e18900af68541b410e6b4ed5896b08c8cfa18be0 100644
--- a/indra/newview/skins/default/xui/pl/panel_script_ed.xml
+++ b/indra/newview/skins/default/xui/pl/panel_script_ed.xml
@@ -15,11 +15,6 @@
 	<panel.string name="Title">
 		Skrypt: [NAME]
 	</panel.string>
-	<text_editor name="Script Editor">
-		Ładowanie...
-	</text_editor>
-	<button label="Zapisz" label_selected="Zapisz" name="Save_btn"/>
-	<combo_box label="Wklej..." name="Insert..."/>
 	<menu_bar name="script_menu">
 		<menu label="Plik" name="File">
 			<menu_item_call label="Zapisz" name="Save"/>
@@ -40,4 +35,10 @@
 			<menu_item_call label="Pomoc..." name="Keyword Help..."/>
 		</menu>
 	</menu_bar>
+	<text_editor name="Script Editor">
+		Ładowanie...
+	</text_editor>
+	<combo_box label="Wklej..." name="Insert..."/>
+	<button label="Zapisz" label_selected="Zapisz" name="Save_btn"/>
+	<button label="Edytuj..." name="Edit_btn"/>
 </panel>
diff --git a/indra/newview/skins/default/xui/pl/panel_status_bar.xml b/indra/newview/skins/default/xui/pl/panel_status_bar.xml
index 5e97dd89611417c86518f7ff7feed0cdac136cea..6aa0d27bb80881b6f0b102f7b8c8847251da9846 100644
--- a/indra/newview/skins/default/xui/pl/panel_status_bar.xml
+++ b/indra/newview/skins/default/xui/pl/panel_status_bar.xml
@@ -22,7 +22,7 @@
 		L$ [AMT]
 	</panel.string>
 	<panel name="balance_bg">
-		<text name="balance" tool_tip="Mój bilans" value="L$20"/>
+		<text name="balance" tool_tip="Kliknij aby odświeżyć bilans L$" value="L$20"/>
 		<button label="Kup L$" name="buyL" tool_tip="Kliknij aby kupić więcej L$"/>
 	</panel>
 	<text name="TimeText" tool_tip="Obecny czas (Pacyficzny)">
diff --git a/indra/newview/skins/default/xui/pl/strings.xml b/indra/newview/skins/default/xui/pl/strings.xml
index ea8bdd75b9fa53b0fd733949e301894f8bf60977..d1fb382a2dafb3cbb713743f7f84f274205c7bda 100644
--- a/indra/newview/skins/default/xui/pl/strings.xml
+++ b/indra/newview/skins/default/xui/pl/strings.xml
@@ -1737,11 +1737,8 @@
 	<string name="InvOfferGaveYou">
 		oddany Tobie
 	</string>
-	<string name="InvOfferYouDecline">
-		Odrzucony przez Ciebie
-	</string>
-	<string name="InvOfferFrom">
-		od
+	<string name="InvOfferDecline">
+		Odrzucono [DESC] od &lt;nolink&gt;[NAME]&lt;/nolink&gt;.
 	</string>
 	<string name="GroupMoneyTotal">
 		Suma
diff --git a/indra/newview/skins/default/xui/pt/floater_web_content.xml b/indra/newview/skins/default/xui/pt/floater_web_content.xml
new file mode 100644
index 0000000000000000000000000000000000000000..5101579c6f21e8fde127f7e08487b5f6c50a29b4
--- /dev/null
+++ b/indra/newview/skins/default/xui/pt/floater_web_content.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<floater name="floater_web_content" title="">
+	<layout_stack name="stack1">
+		<layout_panel name="nav_controls">
+			<button name="back" tool_tip="Navegar para trás"/>
+			<button name="forward" tool_tip="Navegar para frente"/>
+			<button name="stop" tool_tip="Parar a navegação"/>
+			<button name="reload" tool_tip="Recarregar página"/>
+			<combo_box name="address" tool_tip="Digite a URL aqui"/>
+			<icon name="media_secure_lock_flag" tool_tip="Navegação segura"/>
+			<button name="popexternal" tool_tip="Abrir a URL atual no navegador do seu computador"/>
+		</layout_panel>
+	</layout_stack>
+</floater>
diff --git a/indra/newview/skins/default/xui/pt/menu_login.xml b/indra/newview/skins/default/xui/pt/menu_login.xml
index a43ac271a9dc786c0455e2722251c52149f9139d..3dff3d7c8a96d76881d90f76718e9526c9572710 100644
--- a/indra/newview/skins/default/xui/pt/menu_login.xml
+++ b/indra/newview/skins/default/xui/pt/menu_login.xml
@@ -16,7 +16,8 @@
 		<menu_item_call label="Definir tamanho da janela:" name="Set Window Size..."/>
 		<menu_item_call label="Mostrar TOS" name="TOS"/>
 		<menu_item_call label="Mostrar mensagem crítica" name="Critical"/>
-		<menu_item_call label="Teste de navegador web" name="Web Browser Test"/>
+		<menu_item_call label="Teste de mídia do navegador" name="Web Browser Test"/>
+		<menu_item_call label="Teste de conteúdo web" name="Web Content Floater Test"/>
 		<menu_item_check label="Exibir seletor da grade" name="Show Grid Picker"/>
 		<menu_item_call label="Exibir painel de notificações" name="Show Notifications Console"/>
 	</menu>
diff --git a/indra/newview/skins/default/xui/pt/menu_mini_map.xml b/indra/newview/skins/default/xui/pt/menu_mini_map.xml
index d742038e1521a40089d8f21871f02e42ecd30378..6a3fe55de52df5be09679231de600e69391e76ba 100644
--- a/indra/newview/skins/default/xui/pt/menu_mini_map.xml
+++ b/indra/newview/skins/default/xui/pt/menu_mini_map.xml
@@ -3,6 +3,7 @@
 	<menu_item_call label="Zoom Perto" name="Zoom Close"/>
 	<menu_item_call label="Zoom Médio" name="Zoom Medium"/>
 	<menu_item_call label="Zoom Longe" name="Zoom Far"/>
+	<menu_item_call label="Zoom padrão" name="Zoom Default"/>
 	<menu_item_check label="Girar mapa" name="Rotate Map"/>
 	<menu_item_check label="Auto Center" name="Auto Center"/>
 	<menu_item_call label="Parar Acompanhamento" name="Stop Tracking"/>
diff --git a/indra/newview/skins/default/xui/pt/menu_viewer.xml b/indra/newview/skins/default/xui/pt/menu_viewer.xml
index 95c37c53ca48eb6c358b596e0a9ff1d41b5b22e7..3bbf2b66f223dc8b67bb756e90a9f34e520808aa 100644
--- a/indra/newview/skins/default/xui/pt/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/pt/menu_viewer.xml
@@ -121,13 +121,15 @@
 			<menu_item_call label="Animação (L$[COST])..." name="Upload Animation"/>
 			<menu_item_call label="Volume (L$[COST] por arquivo)..." name="Bulk Upload"/>
 		</menu>
+		<menu_item_call label="Desfazer" name="Undo"/>
+		<menu_item_call label="Repetir" name="Redo"/>
 	</menu>
 	<menu label="Ajuda" name="Help">
 		<menu_item_call label="[SECOND_LIFE] Ajuda" name="Second Life Help"/>
+		<menu_item_check label="Ativar dicas" name="Enable Hints"/>
 		<menu_item_call label="Denunciar abuso" name="Report Abuse"/>
 		<menu_item_call label="Relatar bug" name="Report Bug"/>
 		<menu_item_call label="Sobre [APP_NAME]" name="About Second Life"/>
-		<menu_item_check label="Ativar dicas" name="Enable Hints"/>
 	</menu>
 	<menu label="Avançado" name="Advanced">
 		<menu_item_call label="Recarregar texturas" name="Rebake Texture"/>
@@ -268,7 +270,8 @@
 			<menu_item_call label="Dump Region Object Cache" name="Dump Region Object Cache"/>
 		</menu>
 		<menu label="Interface" name="UI">
-			<menu_item_call label="Teste de navegador web" name="Web Browser Test"/>
+			<menu_item_call label="Teste de mídia do navegador" name="Web Browser Test"/>
+			<menu_item_call label="Navegador de conteúdo web" name="Web Content Browser"/>
 			<menu_item_call label="Print Selected Object Info" name="Print Selected Object Info"/>
 			<menu_item_call label="Dados de memória" name="Memory Stats"/>
 			<menu_item_check label="Console de depuração de região" name="Region Debug Console"/>
diff --git a/indra/newview/skins/default/xui/pt/notifications.xml b/indra/newview/skins/default/xui/pt/notifications.xml
index a1855f2e892ce26b66be0a7b38aa19bf41fd6153..4b2e4bc5e0e342b072116b7858170a1efb9e21ad 100644
--- a/indra/newview/skins/default/xui/pt/notifications.xml
+++ b/indra/newview/skins/default/xui/pt/notifications.xml
@@ -108,6 +108,10 @@ Por favor, selecione apenas um objeto e tente novamente.
 		Residentes que não são amigos não veem que você decidiu ignorar ligações e MIs deles.
 		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
+	<notification name="FavoritesOnLogin">
+		Nota: Ao ativar esta opção, qualquer pessoa que utilizar este computador poderá ver a sua lista de lugares preferidos.
+		<usetemplate name="okbutton" yestext="OK"/>
+	</notification>
 	<notification name="GrantModifyRights">
 		Conceder direitos de modificação a outros residentes vai autorizá-los a mudar, apagar ou pegar TODOS os seus objetos. Seja MUITO cuidadoso ao conceder esta autorização.
 Deseja dar direitos de modificação a [NAME]?
@@ -938,7 +942,7 @@ Oferecer amizade para [NAME]?
 			<input name="message">
 				[DESC] (novo)
 			</input>
-			<button name="Offer" text="OK"/>
+			<button name="OK" text="OK"/>
 			<button name="Cancel" text="Cancelar"/>
 		</form>
 	</notification>
@@ -948,7 +952,7 @@ Oferecer amizade para [NAME]?
 			<input name="message">
 				[DESC] (novo)
 			</input>
-			<button name="Offer" text="OK"/>
+			<button name="OK" text="OK"/>
 			<button name="Cancel" text="Cancelar"/>
 		</form>
 	</notification>
@@ -958,7 +962,7 @@ Oferecer amizade para [NAME]?
 			<input name="new_name">
 				[NAME]
 			</input>
-			<button name="Offer" text="OK"/>
+			<button name="OK" text="OK"/>
 			<button name="Cancel" text="Cancelar"/>
 		</form>
 	</notification>
@@ -1329,9 +1333,41 @@ Baixe e instale a versão mais recente do visualizador em
 http://secondlife.com/download.
 		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
-	<notification name="DownloadBackground">
-		Foi baixada uma nova versão do [APP_NAME]
-A nova versão será exibida quando o [APP_NAME] for reiniciado.
+	<notification name="FailedRequiredUpdateInstall">
+		Não foi possível instalar uma atualização necessária. 
+Não será possível acessar a sua conta até que você atualize o [APP_NAME].
+
+Baixe e instale a versão mais recente do visualizador em 
+http://secondlife.com/download.
+		<usetemplate name="okbutton" yestext="Sair"/>
+	</notification>
+	<notification name="UpdaterServiceNotRunning">
+		A instalação do Second Life requer uma atualização.
+
+Baixe a atualização em http://www.secondlife.com/downloads
+ou você pode instalar a instalação agora.
+		<usetemplate name="okcancelbuttons" notext="Sair do Second Life" yestext="Baixar e instalar agora"/>
+	</notification>
+	<notification name="DownloadBackgroundTip">
+		Baixamos uma atualização para a instalação do [APP_NAME].
+Versão [VERSION] [[RELEASE_NOTES_FULL_URL] sobre esta atualização]
+		<usetemplate name="okcancelbuttons" notext="Depois..." yestext="Instalar agora e reiniciar o [APP_NAME]"/>
+	</notification>
+	<notification name="DownloadBackgroundDialog">
+		Baixamos uma atualização para a instalação do [APP_NAME].
+Versão [VERSION] [[RELEASE_NOTES_FULL_URL] sobre esta atualização]
+		<usetemplate name="okcancelbuttons" notext="Depois..." yestext="Instalar agora e reiniciar o [APP_NAME]"/>
+	</notification>
+	<notification name="RequiredUpdateDownloadedVerboseDialog">
+		O software requer uma atualização que já foi baixada.
+Versão [VERSION]
+
+Para instalar a atualização, será preciso reiniciar o [APP_NAME].
+		<usetemplate name="okbutton" yestext="OK"/>
+	</notification>
+	<notification name="RequiredUpdateDownloadedDialog">
+		Para instalar a atualização, será preciso reiniciar o [APP_NAME].
+		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="DeedObjectToGroup">
 		Delegar este objeto causará ao grupo:
@@ -2198,14 +2234,6 @@ Selecione o residente da lista e clique em &apos;MI&apos; na parte de baixo do p
 	<notification name="NoContentToSearch">
 		Por favor, selecione ao menos um tipo de conteúdo para a busca (PG, Mature ou Adult).
 	</notification>
-	<notification name="GroupVote">
-		[NAME] propõe que você vote:
-[MESSAGE]
-		<form name="form">
-			<button name="VoteNow" text="Vote agora"/>
-			<button name="Later" text="Depois"/>
-		</form>
-	</notification>
 	<notification name="SystemMessage">
 		[MESSAGE]
 	</notification>
@@ -2658,9 +2686,6 @@ Clique em Aceitar para atender ou em Recusar para recusar este convite.  Clique
 	<notification name="VoiceCallGenericError">
 		Ocorreu um erro enquanto você tentava se conectar à conversa de voz de [VOICE_CHANNEL_NAME].  Favor tentar novamente mais tarde.
 	</notification>
-	<notification name="ServerVersionChanged">
-		Você chegou a uma região com uma versão diferente de servidor, que pode afetar o desempenho.  [[URL] Consultar notas da versão.]
-	</notification>
 	<notification name="UnsupportedCommandSLURL">
 		O SLurl no qual você clicou não é suportado.
 	</notification>
@@ -2763,9 +2788,7 @@ Avatar &apos;[NAME]&apos; sair do modo aparecer.
 	<notification name="NoConnect">
 		Detectamos um problema de conexão com [PROTOCOL] [HOSTID].
 Verifique a configuração da sua rede e firewall.
-		<form name="form">
-			<button name="OK" text="OK"/>
-		</form>
+		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="NoVoiceConnect">
 		Estamos tendo problemas de conexão com o seu servidor de voz:
@@ -2774,9 +2797,7 @@ Verifique a configuração da sua rede e firewall.
 
 Talvez não seja possível se comunicar via voz.
 Verifique a configuração da sua rede e firewall.
-		<form name="form">
-			<button name="OK" text="OK"/>
-		</form>
+		<usetemplate name="okbutton" yestext="OK"/>
 	</notification>
 	<notification name="AvatarRezLeftNotification">
 		( [EXISTENCE] segundos de vida )
@@ -2811,6 +2832,9 @@ Silenciar todos?
 	<notification label="Explore o mundo" name="HintDestinationGuide">
 		O Guia de Destinos traz milhares de lugares novos para você explorar e conhecer. Selecione um lugar, clique em Teletransportar e comece suas descobertas.
 	</notification>
+	<notification label="Troque o visual" name="HintAvatarPicker">
+		Que tal mudar o visual? Clique o botão abaixo para ver Avatares diferentes.
+	</notification>
 	<notification label="Painel lateral" name="HintSidePanel">
 		Acesse rapidamente seu inventário, roupas, looks, perfis e mais no painel lateral.
 	</notification>
@@ -2820,6 +2844,12 @@ Silenciar todos?
 	<notification label="Nome de tela" name="HintDisplayName">
 		Defina seu nome de tela personalizável. O nome de tele é separado do seu nome de usuário, que não pode ser modificado. Você pode mudar a visualização dos nomes de outras pessoas nas suas preferências.
 	</notification>
+	<notification label="Movimentar" name="HintMoveArrows">
+		Para andar, use as setas do teclado. Para correr, pressione a seta para cima duas vezes.
+	</notification>
+	<notification label="Exibir" name="HintView">
+		Para mudar o ângulo de visualização, use os controles Órbita e Pan. Volte à visualização normal pressionando a tecla Escape ou começando a andar.
+	</notification>
 	<notification label="Inventário" name="HintInventory">
 		Você encontrará seus pertences no inventário.  Os itens mais novos também ficam na guia Itens recentes.
 	</notification>
@@ -2833,6 +2863,15 @@ Silenciar todos?
 			<button name="open" text="Abrir pop-up"/>
 		</form>
 	</notification>
+	<notification name="AuthRequest">
+		O site em &apos;&lt;nolink&gt;[HOST_NAME]&lt;/nolink&gt;&apos; em &apos;[REALM]&apos; requer nome e senha.
+		<form name="form">
+			<input name="username" text="Nome de usuário"/>
+			<input name="password" text="Senha:"/>
+			<button name="ok" text="Enviar"/>
+			<button name="cancel" text="Cancelar"/>
+		</form>
+	</notification>
 	<global name="UnsupportedCPU">
 		- A velocidade da sua CPU não suporta os requisitos mínimos exigidos.
 	</global>
diff --git a/indra/newview/skins/default/xui/pt/panel_avatar_list_item.xml b/indra/newview/skins/default/xui/pt/panel_avatar_list_item.xml
index ca67125c65fc618f31e7badc056f8fe4b80c0487..b444593af82dc5f62c382682e86a096d7eeb21c3 100644
--- a/indra/newview/skins/default/xui/pt/panel_avatar_list_item.xml
+++ b/indra/newview/skins/default/xui/pt/panel_avatar_list_item.xml
@@ -21,7 +21,7 @@
 	<string name="FormatYears">
 		[COUNT]anos
 	</string>
-	<text name="avatar_name" value="Desconhecido"/>
+	<text name="avatar_name" value="(carregando)"/>
 	<icon name="permission_edit_theirs_icon" tool_tip="Você pode editar os pertences deste amigo"/>
 	<icon name="permission_edit_mine_icon" tool_tip="Este amigo pode editar, excluir ou pegar seus pertences"/>
 	<icon name="permission_map_icon" tool_tip="Este amigo pode localizar você no mapa"/>
diff --git a/indra/newview/skins/default/xui/pt/panel_edit_alpha.xml b/indra/newview/skins/default/xui/pt/panel_edit_alpha.xml
index f8be9daf1bc62341543ffbc34037b14edddfbb10..b274945dbdb0dd61e3f2b6eee6a21aeab9766c47 100644
--- a/indra/newview/skins/default/xui/pt/panel_edit_alpha.xml
+++ b/indra/newview/skins/default/xui/pt/panel_edit_alpha.xml
@@ -1,10 +1,12 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel name="edit_alpha_panel">
-	<panel name="avatar_alpha_color_panel">
-		<texture_picker label="Alpha inferior" name="Lower Alpha" tool_tip="Selecionar imagem"/>
-		<texture_picker label="Alpha de cima" name="Upper Alpha" tool_tip="Selecionar imagem"/>
-		<texture_picker label="Cabeça Alpha" name="Head Alpha" tool_tip="Selecionar imagem"/>
-		<texture_picker label="Olhos Alpha" name="Eye Alpha" tool_tip="Selecionar imagem"/>
-		<texture_picker label="Cabelo alpha" name="Hair Alpha" tool_tip="Selecionar imagem"/>
-	</panel>
+	<scroll_container name="avatar_alpha_color_panel_scroll">
+		<panel name="avatar_alpha_color_panel">
+			<texture_picker label="Alpha inferior" name="Lower Alpha" tool_tip="Selecionar imagem"/>
+			<texture_picker label="Alpha de cima" name="Upper Alpha" tool_tip="Selecionar imagem"/>
+			<texture_picker label="Cabeça Alpha" name="Head Alpha" tool_tip="Selecionar imagem"/>
+			<texture_picker label="Olhos Alpha" name="Eye Alpha" tool_tip="Selecionar imagem"/>
+			<texture_picker label="Cabelo alpha" name="Hair Alpha" tool_tip="Selecionar imagem"/>
+		</panel>
+	</scroll_container>
 </panel>
diff --git a/indra/newview/skins/default/xui/pt/panel_login.xml b/indra/newview/skins/default/xui/pt/panel_login.xml
index 9c8650e75e16a3446f32b99186c4e0a9bc8b1050..42df93fd867d324870f02c13db968411884d6c96 100644
--- a/indra/newview/skins/default/xui/pt/panel_login.xml
+++ b/indra/newview/skins/default/xui/pt/panel_login.xml
@@ -11,7 +11,7 @@
 			<text name="username_text">
 				Nome de usuário:
 			</text>
-			<line_editor label="zecazc12 or Magia Solar" name="username_edit" tool_tip="O nome de usuário que você escolheu ao fazer seu cadastro, como zecazc12 or Magia Solar"/>
+			<combo_box name="username_combo" tool_tip="O nome de usuário que você escolheu ao fazer seu cadastro, como zecazc12 or Magia Solar"/>
 			<text name="password_text">
 				Senha:
 			</text>
diff --git a/indra/newview/skins/default/xui/pt/panel_my_profile.xml b/indra/newview/skins/default/xui/pt/panel_my_profile.xml
index 1a28f61c2da5e1cf717d5db13416f1a20554cda0..aa15a2445d236e491446f8b7aacfb7a0e6831510 100644
--- a/indra/newview/skins/default/xui/pt/panel_my_profile.xml
+++ b/indra/newview/skins/default/xui/pt/panel_my_profile.xml
@@ -5,30 +5,27 @@
 	<string name="RegisterDateFormat">
 		[REG_DATE] ([AGE])
 	</string>
+	<string name="name_text_args">
+		[NAME]
+	</string>
+	<string name="display_name_text_args">
+		[DISPLAY_NAME]
+	</string>
 	<layout_stack name="layout">
 		<layout_panel name="profile_stack">
 			<scroll_container name="profile_scroll">
 				<panel name="scroll_content_panel">
 					<panel name="second_life_image_panel">
-						<icon label="" name="2nd_life_edit_icon" tool_tip="Clique no botão Editar para trocar a imagem"/>
-						<text name="title_sl_descr_text" value="[SECOND_LIFE]:"/>
-					</panel>
-					<panel name="first_life_image_panel">
-						<icon label="" name="real_world_edit_icon" tool_tip="Clique no botão Editar para trocar a imagem"/>
-						<text name="title_rw_descr_text" value="Mundo real:"/>
-					</panel>
-					<text name="title_member_text" value="Residente desde:"/>
-					<text name="title_acc_status_text" value="Conta:"/>
-					<text name="title_partner_text" value="Parceiro(a):"/>
-					<panel name="partner_data_panel">
-						<name_box initial_value="(pesquisando)" name="partner_text"/>
+						<text name="display_name_descr_text">
+							Nome de usuário
+						</text>
+						<text name="name_descr_text">
+							Nome de tela
+						</text>
+						<button label="Perfil" name="see_profile_btn" tool_tip="Ver o perfil deste avatar"/>
 					</panel>
-					<text name="title_groups_text" value="Grupos:"/>
 				</panel>
 			</scroll_container>
 		</layout_panel>
 	</layout_stack>
-	<panel name="profile_me_buttons_panel">
-		<button label="Editar perfil" name="edit_profile_btn" tool_tip="Editar dados pessoais"/>
-	</panel>
 </panel>
diff --git a/indra/newview/skins/default/xui/pt/panel_notify_textbox.xml b/indra/newview/skins/default/xui/pt/panel_notify_textbox.xml
index d9614fe76bdf076787ea9c1f3ae8441ae65ed656..dcd9ba18154a4f03bb410d35bba64d139fee45cd 100644
--- a/indra/newview/skins/default/xui/pt/panel_notify_textbox.xml
+++ b/indra/newview/skins/default/xui/pt/panel_notify_textbox.xml
@@ -3,8 +3,9 @@
 	<string name="message_max_lines_count" value="7"/>
 	<panel label="info_panel" name="info_panel">
 		<text_editor name="message" value="mensagem"/>
-		parse_urls=&quot;false&quot;
+	</panel>
+	<panel label="control_panel" name="control_panel">
 		<button label="Enviar" name="btn_submit"/>
+		<button label="Ignorar" name="ignore_btn"/>
 	</panel>
-	<panel label="control_panel" name="control_panel"/>
 </panel>
diff --git a/indra/newview/skins/default/xui/pt/panel_preferences_colors.xml b/indra/newview/skins/default/xui/pt/panel_preferences_colors.xml
index 3ca9da06c9cd0ef3169ca215bef57a36e6f35beb..5f2f341e3fdacfdbdddac7591e4bc86b8cd4f6c6 100644
--- a/indra/newview/skins/default/xui/pt/panel_preferences_colors.xml
+++ b/indra/newview/skins/default/xui/pt/panel_preferences_colors.xml
@@ -29,10 +29,10 @@
 		URLs
 	</text>
 	<text name="bubble_chat">
-		Fundo do balão:
+		Cor de fundo do nome (e do balão do bate-papo):
 	</text>
-	<color_swatch name="background" tool_tip="Escolha a cor do balão de bate-papo"/>
-	<slider label="Opacidade:" name="bubble_chat_opacity"/>
+	<color_swatch name="background" tool_tip="Selecionar cor do nome"/>
+	<slider label="Opacidade:" name="bubble_chat_opacity" tool_tip="Selecionar cor do nome"/>
 	<text name="floater_opacity">
 		Opacidade:
 	</text>
diff --git a/indra/newview/skins/default/xui/pt/panel_preferences_privacy.xml b/indra/newview/skins/default/xui/pt/panel_preferences_privacy.xml
index 5545dcda388bbd18cdd04091d531c2ec8f5a7220..d7fb585e352e739e356a97fa04110546ad583e15 100644
--- a/indra/newview/skins/default/xui/pt/panel_preferences_privacy.xml
+++ b/indra/newview/skins/default/xui/pt/panel_preferences_privacy.xml
@@ -7,9 +7,11 @@
 	<text name="cache_size_label_l">
 		(Locações, imagens, web, histórico de busca)
 	</text>
+	<check_box label="Mostrar nos resultados de busca" name="online_searchresults"/>
 	<check_box label="Apenas amigos e grupos sabem que estou online" name="online_visibility"/>
 	<check_box label="Apenas amigos e grupos podem me chamar ou enviar MI" name="voice_call_friends_only_check"/>
 	<check_box label="Desligar o microfone quando terminar chamadas" name="auto_disengage_mic_check"/>
+	<check_box label="Mostrar meus marcos preferidos na página de login (menu &apos;Começar em&apos;:)" name="favorites_on_login_check"/>
 	<text name="Logs:">
 		Registro de bate-papos:
 	</text>
diff --git a/indra/newview/skins/default/xui/pt/panel_preferences_setup.xml b/indra/newview/skins/default/xui/pt/panel_preferences_setup.xml
index 0c6fb68140b0e6a81a196ff58d4513d437f553e5..d8d4a8fc1c64b63320eee14e28016d214b49db3a 100644
--- a/indra/newview/skins/default/xui/pt/panel_preferences_setup.xml
+++ b/indra/newview/skins/default/xui/pt/panel_preferences_setup.xml
@@ -39,5 +39,11 @@
 	</text>
 	<line_editor name="web_proxy_editor" tool_tip="O nome ou endereço IP do proxy da sua preferência"/>
 	<spinner label="Porta:" name="web_proxy_port"/>
-	<check_box initial_value="verdadeiro" label="Baixar e instalar atualizações [APP_NAME] automaticamente" name="updater_service_active"/>
+	<text name="Software updates:">
+		Atualizações de software:
+	</text>
+	<combo_box name="updater_service_combobox">
+		<combo_box.item label="Instalar automaticamente" name="Install_automatically"/>
+		<combo_box.item label="Baixar e instalar atualizações manualmente" name="Install_manual"/>
+	</combo_box>
 </panel>
diff --git a/indra/newview/skins/default/xui/pt/panel_status_bar.xml b/indra/newview/skins/default/xui/pt/panel_status_bar.xml
index fbbcf0d1be0020c1d9c755d14d3c5abd5a954686..f7890ae57d6b62e6b1b2289757730f69cb2fb2ff 100644
--- a/indra/newview/skins/default/xui/pt/panel_status_bar.xml
+++ b/indra/newview/skins/default/xui/pt/panel_status_bar.xml
@@ -22,7 +22,7 @@
 		L$ [AMT]
 	</panel.string>
 	<panel name="balance_bg">
-		<text name="balance" tool_tip="Meu saldo" value="L$20"/>
+		<text name="balance" tool_tip="Atualizar saldo de L$" value="L$20"/>
 		<button label="Comprar L$" name="buyL" tool_tip="Comprar mais L$"/>
 	</panel>
 	<text name="TimeText" tool_tip="Hora atual (Pacífico)">
diff --git a/indra/newview/tests/llcapabilitylistener_test.cpp b/indra/newview/tests/llcapabilitylistener_test.cpp
index 9da851ffc4e0906cd3f7510a81698756f442a702..d691bb6c44f6aec08bdb7480729edda9a6234ff0 100644
--- a/indra/newview/tests/llcapabilitylistener_test.cpp
+++ b/indra/newview/tests/llcapabilitylistener_test.cpp
@@ -72,7 +72,7 @@ struct TestCapabilityProvider: public LLCapabilityProvider
     {
         mCaps[cap] = url;
     }
-    LLHost getHost() const { return mHost; }
+    const LLHost& getHost() const { return mHost; }
     std::string getDescription() const { return "TestCapabilityProvider"; }
 
     LLHost mHost;
diff --git a/indra/viewer_components/updater/llupdaterservice.cpp b/indra/viewer_components/updater/llupdaterservice.cpp
index aa4983a3b6634984df873f706787e7a4a1c128d9..ea242f45cdad09799eabea2614371cc0e6acffd4 100644
--- a/indra/viewer_components/updater/llupdaterservice.cpp
+++ b/indra/viewer_components/updater/llupdaterservice.cpp
@@ -361,6 +361,7 @@ void LLUpdaterServiceImpl::error(std::string const & message)
 {
 	if(mIsChecking)
 	{
+		setState(LLUpdaterService::TEMPORARY_ERROR);
 		restartTimer(mCheckPeriod);
 	}
 }
diff --git a/indra/viewer_components/updater/llupdaterservice.h b/indra/viewer_components/updater/llupdaterservice.h
index 421481bc43d0adfe44ad6d6bb12dbd8bc22e2d93..450f19c1c6d18cbffc4b4f0c95621f0a6b9717ba 100644
--- a/indra/viewer_components/updater/llupdaterservice.h
+++ b/indra/viewer_components/updater/llupdaterservice.h
@@ -59,6 +59,7 @@ class LLUpdaterService
 	enum eUpdaterState {
 		INITIAL,
 		CHECKING_FOR_UPDATE,
+		TEMPORARY_ERROR,
 		DOWNLOADING,
 		INSTALLING,
 		UP_TO_DATE,