diff --git a/doc/contributions.txt b/doc/contributions.txt
index 8178a4608e69548c9e336c932a1f7728cfeb6c20..71423bda9cd1c21e0cf2aeb243f7040a9abfe42d 100644
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -24,18 +24,24 @@ Aimee Trescothick
 	VWR-6550
 	VWR-6583
 	VWR-6482
-  VWR-7109
+	VWR-7109
 	VWR-7383
 	VWR-8341
 	VWR-8430
 	VWR-8482
 	VWR-9255
-	VWR-11844
+	VWR-10990
+	VWR-11100
+	VWR-11111
+ 	VWR-11844
 Alejandro Rosenthal
 	VWR-1184
 Aleric Inglewood
+	VWR-10001
 	VWR-10759
 	VWR-10837
+Ales Beaumont
+    VWR-9352
 Alissa Sabre
 	VWR-81
 	VWR-83
@@ -82,6 +88,8 @@ Angus Boyd
 	VWR-592
 Argent Stonecutter
 	VWR-68
+Armin Weatherwax
+	VWR-8436
 Asuka Neely
 	VWR-3434
 	VWR-8179
@@ -109,6 +117,7 @@ Carjay McGinnis
 	VWR-4070
 	VWR-4212
 	VWR-6154
+	VWR-9400
 Catherine Pfeffer
 	VWR-1282
 	VWR-8624
@@ -184,6 +193,7 @@ Gigs Taggart
 	VWR-2502
 	VWR-2331
 	VWR-8781
+	VWR-8783
 Ginko Bayliss
 	VWR-4
 Grazer Kline
@@ -236,10 +246,14 @@ Kage Pixel
 Kerutsen Sellery
 	VWR-1350
 Khyota Wulluf
+	VWR-2085
 	VWR-9256
+	VWR-9966
 Kunnis Basiat
 	VWR-82
 	VWR-102
+Latif Khalifa
+	VWR-5370
 Lockhart Cordoso
 	VWR-108
 maciek marksman
@@ -257,6 +271,7 @@ McCabe Maxsted
 	VWR-1318
 	VWR-4065
 	VWR-4826
+	VWR-6518
 	VWR-7827
 	VWR-7877
 	VWR-7893
diff --git a/indra/CMakeLists.txt b/indra/CMakeLists.txt
index d19811586ffce355bc3b2f100e43d4805b77d619..7f4c2c33c138bd200324b7ab82f0a56e77f7bc22 100644
--- a/indra/CMakeLists.txt
+++ b/indra/CMakeLists.txt
@@ -50,9 +50,9 @@ add_subdirectory(${LIBS_OPEN_PREFIX}llvfs)
 add_subdirectory(${LIBS_OPEN_PREFIX}llwindow)
 add_subdirectory(${LIBS_OPEN_PREFIX}llxml)
 
-if (EXISTS ${LIBS_CLOSED_DIR}llkdu AND NOT STANDALONE)
+if (EXISTS ${LIBS_CLOSED_DIR}llkdu)
   add_subdirectory(${LIBS_CLOSED_PREFIX}llkdu)
-endif (EXISTS ${LIBS_CLOSED_DIR}llkdu AND NOT STANDALONE)
+endif (EXISTS ${LIBS_CLOSED_DIR}llkdu)
 
 add_subdirectory(${LIBS_OPEN_PREFIX}lscript)
 
diff --git a/indra/llcharacter/lleditingmotion.cpp b/indra/llcharacter/lleditingmotion.cpp
index 913be27ba7100d32bf7fde151f6e3bb9ee4511c7..6907df82d448040ab00ada24e1d8590ab8a2d7cc 100644
--- a/indra/llcharacter/lleditingmotion.cpp
+++ b/indra/llcharacter/lleditingmotion.cpp
@@ -190,8 +190,10 @@ BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask)
 	if (!llfinite(focus_pt.magVecSquared()))
 	{
 		LLVector3 tmp = mCharacter->getCharacterPosition() ;
-		llerrs << "Non finite focus point in editing motion. focus point: " << focus_pt << " and character position: " <<
-			tmp << " and pointAtPt: " << *pointAtPt << llendl;
+		LL_WARNS_ONCE("Animation") << "Non finite focus point in editing motion. focus point: " << focus_pt << " and character position: " <<
+			tmp << " and pointAtPt: " << pointAtPt <<
+			" - ignoring anim" << LL_ENDL;
+		return FALSE;
 	}
 
 	// propagate joint positions to kinematic chain
diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp
index e1c457b74520e52200635c13d945a8a4f5812979..19d83862557efb2b939552eeb31cc93aacbbf751 100644
--- a/indra/llcharacter/llkeyframemotion.cpp
+++ b/indra/llcharacter/llkeyframemotion.cpp
@@ -468,7 +468,7 @@ LLMotion *LLKeyframeMotion::create(const LLUUID &id)
 //-----------------------------------------------------------------------------
 LLPointer<LLJointState>& LLKeyframeMotion::getJointState(U32 index)
 {
-	llassert_always (index < (S32)mJointStates.size());
+	llassert_always (index < mJointStates.size());
 	return mJointStates[index];
 }
 
@@ -477,7 +477,7 @@ LLPointer<LLJointState>& LLKeyframeMotion::getJointState(U32 index)
 //-----------------------------------------------------------------------------
 LLJoint* LLKeyframeMotion::getJoint(U32 index)
 {
-	llassert_always (index < (S32)mJointStates.size());
+	llassert_always (index < mJointStates.size());
 	LLJoint* joint = mJointStates[index]->getJoint();
 	llassert_always (joint);
 	return joint;
diff --git a/indra/llcharacter/llkeyframemotionparam.cpp b/indra/llcharacter/llkeyframemotionparam.cpp
index a9c1f6fc456bd89d75cd343403007f7f070a6e91..622405a5e13daea245e7f6fbd8bb87d4f54930d7 100644
--- a/indra/llcharacter/llkeyframemotionparam.cpp
+++ b/indra/llcharacter/llkeyframemotionparam.cpp
@@ -364,18 +364,13 @@ BOOL LLKeyframeMotionParam::loadMotions()
 	}
 
 	// allocate a text buffer
-	char *text = new char[ fileSize+1 ];
-	if ( !text )
-	{
-		llinfos << "ERROR: can't allocated keyframe text buffer." << llendl;
-		return FALSE;
-	}
+	std::vector<char> text(fileSize+1);
 
 	//-------------------------------------------------------------------------
 	// load data from file into buffer
 	//-------------------------------------------------------------------------
 	bool error = false;
-	char *p = text;
+	char *p = &text[0];
 	while ( 1 )
 	{
 		if (apr_file_eof(fp) == APR_EOF)
@@ -399,12 +394,11 @@ BOOL LLKeyframeMotionParam::loadMotions()
 	//-------------------------------------------------------------------------
 	// check for error
 	//-------------------------------------------------------------------------
-	llassert( p <= (text+fileSize) );
+	llassert( p <= (&text[0] + fileSize) );
 
 	if ( error )
 	{
 		llinfos << "ERROR: error while reading from " << path << llendl;
-		delete [] text;
 		return FALSE;
 	}
 
@@ -413,7 +407,7 @@ BOOL LLKeyframeMotionParam::loadMotions()
 	//-------------------------------------------------------------------------
 	// parse the text and build keyframe data structures
 	//-------------------------------------------------------------------------
-	p = text;
+	p = &text[0];
 	S32 num;
 	char strA[80]; /* Flawfinder: ignore */
 	char strB[80]; /* Flawfinder: ignore */
@@ -432,7 +426,6 @@ BOOL LLKeyframeMotionParam::loadMotions()
 		if ((num != 3))
 		{
 			llinfos << "WARNING: can't read parametric motion" << llendl;
-			delete [] text;
 			return FALSE;
 		}
 
@@ -453,7 +446,6 @@ BOOL LLKeyframeMotionParam::loadMotions()
 		num = sscanf(p, "%79s %79s %f", strA, strB, &floatA);	/* Flawfinder: ignore */
 	}
 
-	delete [] text;
 	return TRUE;
 }
 
diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp
index 5e520afab968035a7fdf41a25a0cbbc6e65cfd6e..e8c95d0a76c3f193c767f1d1ef694682fb532320 100644
--- a/indra/llcommon/llerror.cpp
+++ b/indra/llcommon/llerror.cpp
@@ -1083,29 +1083,6 @@ namespace LLError
 	#endif
 		prefix << site.mFunction << ": ";
 
-		if (site.mPrintOnce)
-		{
-			std::map<std::string, unsigned int>::iterator messageIter = s.uniqueLogMessages.find(message);
-			if (messageIter != s.uniqueLogMessages.end())
-			{
-				messageIter->second++;
-				unsigned int num_messages = messageIter->second;
-				if (num_messages == 10 || num_messages == 50 || (num_messages % 100) == 0)
-				{
-					prefix << "ONCE (" << num_messages << "th time seen): ";
-				} 
-				else
-				{
-					return;
-				}
-			}
-			else 
-			{
-				prefix << "ONCE: ";
-				s.uniqueLogMessages[message] = 1;
-			}
-		}
-
 		if (site.mPrintOnce)
 		{
 			std::map<std::string, unsigned int>::iterator messageIter = s.uniqueLogMessages.find(message);
@@ -1210,14 +1187,17 @@ namespace LLError
 	void crashAndLoop(const std::string& message)
 	{
 		// Now, we go kaboom!
-		int* crash = NULL;
+		int* make_me_crash = NULL;
 
-		*crash = 0;
+		*make_me_crash = 0;
 
 		while(true)
 		{
 			// Loop forever, in case the crash didn't work?
 		}
+		
+		// this is an attempt to let Coverity and other semantic scanners know that this function won't be returning ever.
+		exit(EXIT_FAILURE);
 	}
 #if LL_WINDOWS
 		#pragma optimize("", on)
diff --git a/indra/llcommon/llerrorlegacy.h b/indra/llcommon/llerrorlegacy.h
index 143fe201807c2dcbf1271593bce64531fd2d8c95..7a970b1466042575db10403fc3d10df491ca67c3 100644
--- a/indra/llcommon/llerrorlegacy.h
+++ b/indra/llcommon/llerrorlegacy.h
@@ -103,17 +103,14 @@ const int LL_ERR_PRICE_MISMATCH = -23018;
 
 #define llwarning(msg, num)		llwarns << "Warning # " << num << ": " << msg << llendl;
 
-#ifdef SHOW_ASSERT
-#define llassert(func)			if (!(func)) llerrs << "ASSERT (" << #func << ")" << llendl;
-#else
-#define llassert(func)
-#endif
 #define llassert_always(func)	if (!(func)) llerrs << "ASSERT (" << #func << ")" << llendl;
 
 #ifdef SHOW_ASSERT
-#define llverify(func)			if (!(func)) llerrs << "ASSERT (" << #func << ")" << llendl;
+#define llassert(func)			llassert_always(func)
+#define llverify(func)			llassert_always(func)
 #else
-#define llverify(func)			(func); // get rid of warning C4189
+#define llassert(func)
+#define llverify(func)			do {if (func) {}} while(0)
 #endif
 
 // handy compile-time assert - enforce those template parameters! 
diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp
index 9f4ce64d2cab8915fb6c37fd67c8a8753f054d92..7a66d70d3f71f76b0dd3713dae24e1ef25d15211 100644
--- a/indra/llcommon/llsdserialize.cpp
+++ b/indra/llcommon/llsdserialize.cpp
@@ -1502,7 +1502,7 @@ void LLSDBinaryFormatter::formatString(
  */
 int deserialize_string(std::istream& istr, std::string& value, S32 max_bytes)
 {
-	char c = istr.get();
+	int c = istr.get();
 	if(istr.fail())
 	{
 		// No data in stream, bail out but mention the character we
@@ -1544,7 +1544,7 @@ int deserialize_string_delim(
 
 	while (true)
 	{
-		char next_char = istr.get();
+		int next_byte = istr.get();
 		++count;
 
 		if(istr.fail())
@@ -1553,6 +1553,8 @@ int deserialize_string_delim(
 			value = write_buffer.str();
 			return LLSDParser::PARSE_FAILURE;
 		}
+
+		char next_char = (char)next_byte; // Now that we know it's not EOF
 		
 		if(found_escape)
 		{
@@ -1641,7 +1643,7 @@ int deserialize_string_raw(
 	char buf[BUF_LEN];		/* Flawfinder: ignore */
 	istr.get(buf, BUF_LEN - 1, ')');
 	count += istr.gcount();
-	char c = istr.get();
+	int c = istr.get();
 	c = istr.get();
 	count += 2;
 	if(((c == '"') || (c == '\'')) && (buf[0] == '('))
diff --git a/indra/llcommon/llstat.cpp b/indra/llcommon/llstat.cpp
index cbf5a2e1c19be0330396b022622a8ba033d8dbc0..e411a1c798639fbcf04dca0ceecc19b86acdb2ec 100644
--- a/indra/llcommon/llstat.cpp
+++ b/indra/llcommon/llstat.cpp
@@ -327,6 +327,7 @@ U64 LLStatAccum::sScaleTimes[NUM_SCALES] =
 LLStatAccum::LLStatAccum(bool useFrameTimer)
 	: mUseFrameTimer(useFrameTimer),
 	  mRunning(FALSE),
+	  mLastTime(0),
 	  mLastSampleValue(0.0),
 	  mLastSampleValid(FALSE)
 {
@@ -347,7 +348,7 @@ void LLStatAccum::reset(U64 when)
 	{
 		mBuckets[i].accum = 0.0;
 		mBuckets[i].endTime = when + sScaleTimes[i];
-		mBuckets[i].lastValid = FALSE;
+		mBuckets[i].lastValid = false;
 	}
 }
 
@@ -395,7 +396,7 @@ void LLStatAccum::sum(F64 value, U64 when)
 			{
 				F64 valueLeft = value * timeLeft / timeSpan;
 
-				bucket.lastValid = TRUE;
+				bucket.lastValid = true;
 				bucket.lastAccum = bucket.accum + (value - valueLeft);
 				bucket.accum = valueLeft;
 				bucket.endTime += timeScale;
@@ -404,7 +405,7 @@ void LLStatAccum::sum(F64 value, U64 when)
 			{
 				U64 timeTail = timeLeft % timeScale;
 
-				bucket.lastValid = TRUE;
+				bucket.lastValid = true;
 				bucket.lastAccum = value * timeScale / timeSpan;
 				bucket.accum = value * timeTail / timeSpan;
 				bucket.endTime += (timeLeft - timeTail) + timeScale;
diff --git a/indra/llcommon/llstat.h b/indra/llcommon/llstat.h
index 66521a31cb1b883fa3ecf17c280c1c514828716d..61aaac45bfbd552a6193a73f06175cfde6fe4b91 100644
--- a/indra/llcommon/llstat.h
+++ b/indra/llcommon/llstat.h
@@ -96,11 +96,18 @@ public:
 	
 	struct Bucket
 	{
-		F64		accum;
-		U64		endTime;
-
-		BOOL	lastValid;
-		F64		lastAccum;
+		Bucket() :
+			accum(0.0),
+			endTime(0),
+			lastValid(false),
+			lastAccum(0.0)
+		{}
+
+		F64	accum;
+		U64	endTime;
+
+		bool	lastValid;
+		F64	lastAccum;
 	};
 
 	Bucket	mBuckets[NUM_SCALES];
diff --git a/indra/llcommon/llstreamtools.cpp b/indra/llcommon/llstreamtools.cpp
index ee4f46318fd4fbab12688bc95dbb1183c0e6b86b..4ed2df58e06d17a7c9d820ecbc76e2efdff1e02b 100644
--- a/indra/llcommon/llstreamtools.cpp
+++ b/indra/llcommon/llstreamtools.cpp
@@ -45,7 +45,7 @@
 // skips spaces and tabs
 bool skip_whitespace(std::istream& input_stream)
 {
-	char c = input_stream.peek();
+	int c = input_stream.peek();
 	while (('\t' == c || ' ' == c) && input_stream.good())
 	{
 		input_stream.get();
@@ -57,7 +57,7 @@ bool skip_whitespace(std::istream& input_stream)
 // skips whitespace, newlines, and carriage returns
 bool skip_emptyspace(std::istream& input_stream)
 {
-	char c = input_stream.peek();
+	int c = input_stream.peek();
 	while ( input_stream.good()
 			&& ('\t' == c || ' ' == c || '\n' == c || '\r' == c) )
 	{
@@ -72,7 +72,7 @@ bool skip_comments_and_emptyspace(std::istream& input_stream)
 {
 	while (skip_emptyspace(input_stream))
 	{
-		char c = input_stream.peek();
+		int c = input_stream.peek();
 		if ('#' == c )
 		{
 			while ('\n' != c && input_stream.good())
@@ -90,7 +90,7 @@ bool skip_comments_and_emptyspace(std::istream& input_stream)
 
 bool skip_line(std::istream& input_stream)
 {
-	char c;
+	int c;
 	do
 	{
 		c = input_stream.get();
@@ -100,7 +100,7 @@ bool skip_line(std::istream& input_stream)
 
 bool skip_to_next_word(std::istream& input_stream)
 {
-	char c = input_stream.peek();
+	int c = input_stream.peek();
 	while ( input_stream.good()
 			&& (   (c >= 'a' && c <= 'z')
 		   		|| (c >= 'A' && c <= 'Z')
@@ -132,7 +132,7 @@ bool skip_to_end_of_next_keyword(const char* keyword, std::istream& input_stream
 	while (input_stream.good())
 	{
 		skip_emptyspace(input_stream);
-		char c = input_stream.get();
+		int c = input_stream.get();
 		if (keyword[0] != c)
 		{
 			skip_line(input_stream);
@@ -181,7 +181,7 @@ bool skip_to_start_of_next_keyword(const char* keyword, std::istream& input_stre
 	while (input_stream.good())
 	{
 		skip_emptyspace(input_stream);
-		char c = input_stream.get();
+		int c = input_stream.get();
 		if (keyword[0] != c)
 		{
 			skip_line(input_stream);
@@ -229,7 +229,7 @@ bool skip_to_start_of_next_keyword(const char* keyword, std::istream& input_stre
 bool get_word(std::string& output_string, std::istream& input_stream)
 {
 	skip_emptyspace(input_stream);
-	char c = input_stream.peek();
+	int c = input_stream.peek();
 	while ( !isspace(c) 
 			&& '\n' != c 
 			&& '\r' != c 
@@ -246,7 +246,7 @@ bool get_word(std::string& output_string, std::istream& input_stream, int n)
 {
 	skip_emptyspace(input_stream);
 	int char_count = 0;
-	char c = input_stream.peek();
+	int c = input_stream.peek();
 	while (!isspace(c) 
 			&& '\n' != c 
 			&& '\r' != c 
@@ -265,7 +265,7 @@ bool get_word(std::string& output_string, std::istream& input_stream, int n)
 bool get_line(std::string& output_string, std::istream& input_stream)
 {
 	output_string.clear();
-	char c = input_stream.get();
+	int c = input_stream.get();
 	while (input_stream.good())
 	{
 		output_string += c;
@@ -285,7 +285,7 @@ bool get_line(std::string& output_string, std::istream& input_stream, int n)
 {
 	output_string.clear();
 	int char_count = 0;
-	char c = input_stream.get();
+	int c = input_stream.get();
 	while (input_stream.good() && char_count < n)
 	{
 		char_count++;
@@ -436,7 +436,7 @@ void get_keyword_and_value(std::string& keyword,
 	while (line_index < line_size)
 	{
 		c = line[line_index];
-		if (!isspace(c))
+		if (!LLStringOps::isSpace(c))
 		{
 			break;
 		}
@@ -448,7 +448,7 @@ void get_keyword_and_value(std::string& keyword,
 	while (line_index < line_size)
 	{
 		c = line[line_index];
-		if (isspace(c) || '\r' == c || '\n' == c)
+		if (LLStringOps::isSpace(c) || '\r' == c || '\n' == c)
 		{
 			break;
 		}
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index 2e93b2a3a7db66f0af8e18895a87b6b09422e69f..4d03c4d40dbaadb9174b229c5af4bbfa47cbeb84 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -226,8 +226,8 @@ LLOSInfo::LLOSInfo() :
 		else if (ostype == "Linux")
 		{
 			// Only care about major and minor Linux versions, truncate at second '.'
-			S32 idx1 = mOSStringSimple.find_first_of(".", 0);
-			S32 idx2 = (idx1 != std::string::npos) ? mOSStringSimple.find_first_of(".", idx1+1) : std::string::npos;
+			std::string::size_type idx1 = mOSStringSimple.find_first_of(".", 0);
+			std::string::size_type idx2 = (idx1 != std::string::npos) ? mOSStringSimple.find_first_of(".", idx1+1) : std::string::npos;
 			std::string simple = mOSStringSimple.substr(0, idx2);
 			if (simple.length() > 0)
 				mOSStringSimple = simple;
diff --git a/indra/llcommon/roles_constants.h b/indra/llcommon/roles_constants.h
index 854a153d193ed73fc1c4cd5e72db8b326d48e09d..57f2418c0fb0b37687e0a16a958f190ad1c4a7f4 100644
--- a/indra/llcommon/roles_constants.h
+++ b/indra/llcommon/roles_constants.h
@@ -141,7 +141,9 @@ const U64 GP_NOTICES_SEND			= 0x1LL << 42;	// Send Notices
 const U64 GP_NOTICES_RECEIVE		= 0x1LL << 43;	// Receive Notices and View Notice History
 
 // Proposals
+// TODO: _DEPRECATED suffix as part of vote removal - DEV-24856:
 const U64 GP_PROPOSAL_START		= 0x1LL << 44;	// Start Proposal
+// TODO: _DEPRECATED suffix as part of vote removal - DEV-24856:
 const U64 GP_PROPOSAL_VOTE		= 0x1LL << 45;	// Vote on Proposal
 
 // Group chat moderation related
@@ -152,20 +154,17 @@ const U64 GP_SESSION_MODERATOR = 0x1LL << 37; //can mute people's session
 const U64 GP_DEFAULT_MEMBER = GP_ACCOUNTING_ACCOUNTABLE
 								| GP_LAND_ALLOW_SET_HOME
 								| GP_NOTICES_RECEIVE
-								| GP_PROPOSAL_START
-								| GP_PROPOSAL_VOTE
-                                | GP_SESSION_JOIN
+								| GP_SESSION_JOIN
 								| GP_SESSION_VOICE
 								;
 
-const U64 GP_DEFAULT_OFFICER = GP_ACCOUNTING_ACCOUNTABLE
+const U64 GP_DEFAULT_OFFICER = GP_DEFAULT_MEMBER // Superset of GP_DEFAULT_MEMBER
 								| GP_GROUP_CHANGE_IDENTITY
 								| GP_LAND_ADMIN
 								| GP_LAND_ALLOW_EDIT_LAND
 								| GP_LAND_ALLOW_FLY
 								| GP_LAND_ALLOW_CREATE
 								| GP_LAND_ALLOW_LANDMARK
-								| GP_LAND_ALLOW_SET_HOME
 								| GP_LAND_CHANGE_IDENTITY
 								| GP_LAND_CHANGE_MEDIA
 								| GP_LAND_DEED
@@ -187,17 +186,12 @@ const U64 GP_DEFAULT_OFFICER = GP_ACCOUNTING_ACCOUNTABLE
 								| GP_MEMBER_INVITE	
 								| GP_MEMBER_OPTIONS
 								| GP_MEMBER_VISIBLE_IN_DIR
-								| GP_NOTICES_RECEIVE
 								| GP_NOTICES_SEND
 								| GP_OBJECT_DEED
 								| GP_OBJECT_MANIPULATE
 								| GP_OBJECT_SET_SALE
-								| GP_PROPOSAL_START
-								| GP_PROPOSAL_VOTE
 								| GP_ROLE_ASSIGN_MEMBER_LIMITED
 								| GP_ROLE_PROPERTIES
 								| GP_SESSION_MODERATOR
-								| GP_SESSION_JOIN
-								| GP_SESSION_VOICE
 								;
 #endif
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index 88edc9943c68ac0c8ffbaa6745bafa6b68ea6fb0..93ddc65f32a7b4fa40fbd1364b1c55077190d5ca 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -417,22 +417,17 @@ void LLImageRaw::verticalFlip()
 {
 	LLMemType mt1((LLMemType::EMemType)mMemType);
 	S32 row_bytes = getWidth() * getComponents();
-	U8* line_buffer = new U8[row_bytes];
-	if (!line_buffer )
-	{
-		llerrs << "Out of memory in LLImageRaw::verticalFlip()" << llendl;
-		return;
-	}
+	llassert(row_bytes > 0);
+	std::vector<U8> line_buffer(row_bytes);
 	S32 mid_row = getHeight() / 2;
 	for( S32 row = 0; row < mid_row; row++ )
 	{
 		U8* row_a_data = getData() + row * row_bytes;
 		U8* row_b_data = getData() + (getHeight() - 1 - row) * row_bytes;
-		memcpy( line_buffer, row_a_data,  row_bytes );	/* Flawfinder: ignore */
-		memcpy( row_a_data,  row_b_data,  row_bytes );	/* Flawfinder: ignore */
-		memcpy( row_b_data,  line_buffer, row_bytes );	/* Flawfinder: ignore */
+		memcpy( &line_buffer[0], row_a_data,  row_bytes );
+		memcpy( row_a_data,  row_b_data,  row_bytes );
+		memcpy( row_b_data,  &line_buffer[0], row_bytes );
 	}
-	delete[] line_buffer;
 }
 
 
@@ -560,22 +555,21 @@ void LLImageRaw::compositeScaled4onto3(LLImageRaw* src)
 
 	llassert( (4 == src->getComponents()) && (3 == dst->getComponents()) );
 
-	// Vertical: scale but no composite
 	S32 temp_data_size = src->getWidth() * dst->getHeight() * src->getComponents();
-	U8* temp_buffer = new U8[ temp_data_size ];
+	llassert_always(temp_data_size > 0);
+	std::vector<U8> temp_buffer(temp_data_size);
+
+	// Vertical: scale but no composite
 	for( S32 col = 0; col < src->getWidth(); col++ )
 	{
-		copyLineScaled( src->getData() + (src->getComponents() * col), temp_buffer + (src->getComponents() * col), src->getHeight(), dst->getHeight(), src->getWidth(), src->getWidth() );
+		copyLineScaled( src->getData() + (src->getComponents() * col), &temp_buffer[0] + (src->getComponents() * col), src->getHeight(), dst->getHeight(), src->getWidth(), src->getWidth() );
 	}
 
 	// Horizontal: scale and composite
 	for( S32 row = 0; row < dst->getHeight(); row++ )
 	{
-		compositeRowScaled4onto3( temp_buffer + (src->getComponents() * src->getWidth() * row), dst->getData() + (dst->getComponents() * dst->getWidth() * row), src->getWidth(), dst->getWidth() );
+		compositeRowScaled4onto3( &temp_buffer[0] + (src->getComponents() * src->getWidth() * row), dst->getData() + (dst->getComponents() * dst->getWidth() * row), src->getWidth(), dst->getWidth() );
 	}
-
-	// Clean up
-	delete[] temp_buffer;
 }
 
 
@@ -805,23 +799,21 @@ void LLImageRaw::copyScaled( LLImageRaw* src )
 		return;
 	}
 
-	// Vertical
 	S32 temp_data_size = src->getWidth() * dst->getHeight() * getComponents();
 	llassert_always(temp_data_size > 0);
-	U8* temp_buffer = new U8[ temp_data_size ];
+	std::vector<U8> temp_buffer(temp_data_size);
+
+	// Vertical
 	for( S32 col = 0; col < src->getWidth(); col++ )
 	{
-		copyLineScaled( src->getData() + (getComponents() * col), temp_buffer + (getComponents() * col), src->getHeight(), dst->getHeight(), src->getWidth(), src->getWidth() );
+		copyLineScaled( src->getData() + (getComponents() * col), &temp_buffer[0] + (getComponents() * col), src->getHeight(), dst->getHeight(), src->getWidth(), src->getWidth() );
 	}
 
 	// Horizontal
 	for( S32 row = 0; row < dst->getHeight(); row++ )
 	{
-		copyLineScaled( temp_buffer + (getComponents() * src->getWidth() * row), dst->getData() + (getComponents() * dst->getWidth() * row), src->getWidth(), dst->getWidth(), 1, 1 );
+		copyLineScaled( &temp_buffer[0] + (getComponents() * src->getWidth() * row), dst->getData() + (getComponents() * dst->getWidth() * row), src->getWidth(), dst->getWidth(), 1, 1 );
 	}
-
-	// Clean up
-	delete[] temp_buffer;
 }
 
 
@@ -842,12 +834,14 @@ BOOL LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data )
 
 	if (scale_image_data)
 	{
-		// Vertical
 		S32 temp_data_size = old_width * new_height * getComponents();
-		U8* temp_buffer = new U8[ temp_data_size ];
+		llassert_always(temp_data_size > 0);
+		std::vector<U8> temp_buffer(temp_data_size);
+
+		// Vertical
 		for( S32 col = 0; col < old_width; col++ )
 		{
-			copyLineScaled( getData() + (getComponents() * col), temp_buffer + (getComponents() * col), old_height, new_height, old_width, old_width );
+			copyLineScaled( getData() + (getComponents() * col), &temp_buffer[0] + (getComponents() * col), old_height, new_height, old_width, old_width );
 		}
 
 		deleteData();
@@ -857,25 +851,15 @@ BOOL LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data )
 		// Horizontal
 		for( S32 row = 0; row < new_height; row++ )
 		{
-			copyLineScaled( temp_buffer + (getComponents() * old_width * row), new_buffer + (getComponents() * new_width * row), old_width, new_width, 1, 1 );
+			copyLineScaled( &temp_buffer[0] + (getComponents() * old_width * row), new_buffer + (getComponents() * new_width * row), old_width, new_width, 1, 1 );
 		}
-
-		// Clean up
-		delete[] temp_buffer;
 	}
 	else
 	{
 		// copy	out	existing image data
 		S32	temp_data_size = old_width * old_height	* getComponents();
-		U8*	temp_buffer	= new U8[ temp_data_size ];
-		if (!temp_buffer)
-		{
-			llwarns << "Out of memory in LLImageRaw::scale: old (w, h, c) = (" << old_width << ", " << old_height << ", " << (S32)getComponents() << 
-				") ; new (w, h, c) = (" << new_width << ", " << new_height << ", " << (S32)getComponents() << ")" << llendl;			
-
-			return FALSE ;
-		}
-		memcpy(temp_buffer,	getData(), temp_data_size);	/* Flawfinder: ignore */
+		std::vector<U8> temp_buffer(temp_data_size);
+		memcpy(&temp_buffer[0],	getData(), temp_data_size);
 
 		// allocate	new	image data,	will delete	old	data
 		U8*	new_buffer = allocateDataSize(new_width, new_height, getComponents());
@@ -884,7 +868,7 @@ BOOL LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data )
 		{
 			if (row	< old_height)
 			{
-				memcpy(new_buffer +	(new_width * row * getComponents()), temp_buffer + (old_width *	row	* getComponents()),	getComponents()	* llmin(old_width, new_width));	/* Flawfinder: ignore */
+				memcpy(new_buffer +	(new_width * row * getComponents()), &temp_buffer[0] + (old_width *	row	* getComponents()),	getComponents()	* llmin(old_width, new_width));
 				if (old_width <	new_width)
 				{
 					// pad out rest	of row with	black
@@ -897,9 +881,6 @@ BOOL LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data )
 				memset(new_buffer +	(new_width * row * getComponents()), 0,	new_width *	getComponents());
 			}
 		}
-
-		// Clean up
-		delete[] temp_buffer;
 	}
 
 	return TRUE ;
@@ -1239,7 +1220,7 @@ bool LLImageRaw::createFromFile(const std::string &filename, bool j2c_lowest_mip
 	llassert(image.notNull());
 
 	U8 *buffer = image->allocateData(length);
-	ifs.read ((char*)buffer, length);	/* Flawfinder: ignore */
+	ifs.read ((char*)buffer, length);
 	ifs.close();
 	
 	image->updateData();
diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp
index 4dddd9de3ee7ac2c01a9ef8671de99ebec1399f9..2823cf7be981a97802ee74067ddfab96adfd7639 100644
--- a/indra/llinventory/llinventory.cpp
+++ b/indra/llinventory/llinventory.cpp
@@ -1257,23 +1257,19 @@ void LLInventoryItem::unpackBinaryBucket(U8* bin_bucket, S32 bin_bucket_size)
 	// Early exit on an empty binary bucket.
 	if (bin_bucket_size <= 1) return;
 
-	// Convert the bin_bucket into a string.
-	char* item_buffer = new char[bin_bucket_size+1];
-	if ((item_buffer != NULL) && (bin_bucket != NULL))
-	{
-		memcpy(item_buffer, bin_bucket, bin_bucket_size);	/* Flawfinder: ignore */
-	}
-	else
+	if (NULL == bin_bucket)
 	{
-		llerrs << "unpackBinaryBucket failed. item_buffer or bin_bucket is Null." << llendl;
-		delete[] item_buffer;
+		llerrs << "unpackBinaryBucket failed.  bin_bucket is NULL." << llendl;
 		return;
 	}
+
+	// Convert the bin_bucket into a string.
+	std::vector<char> item_buffer(bin_bucket_size+1);
+	memcpy(&item_buffer[0], bin_bucket, bin_bucket_size);	/* Flawfinder: ignore */
 	item_buffer[bin_bucket_size] = '\0';
-	std::string str(item_buffer);
+	std::string str(&item_buffer[0]);
 
-	lldebugs << "item buffer: " << item_buffer << llendl;
-	delete[] item_buffer;
+	lldebugs << "item buffer: " << str << llendl;
 
 	// Tokenize the string.
 	typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp
index 1e6584a085e24cee7dbce560fa0424ee7f20db2d..799bc83e2028bae719e38b8c2b3aa1ccbed448c7 100644
--- a/indra/llmessage/llcachename.cpp
+++ b/indra/llmessage/llcachename.cpp
@@ -426,6 +426,7 @@ bool LLCacheName::importFile(std::istream& istr)
 		entry->mFirstName = agent[FIRST].asString();
 		entry->mLastName = agent[LAST].asString();
 		impl.mCache[id] = entry;
+
 		++count;
 	}
 	llinfos << "LLCacheName loaded " << count << " agent names" << llendl;
diff --git a/indra/llmessage/llcircuit.cpp b/indra/llmessage/llcircuit.cpp
index 725425cc20e55c4054535d68bffdd9058882093e..7c60886ed37bd5bdf85dbb4181b6137f51fd9cc8 100644
--- a/indra/llmessage/llcircuit.cpp
+++ b/indra/llmessage/llcircuit.cpp
@@ -77,6 +77,8 @@ LLCircuitData::LLCircuitData(const LLHost &host, TPACKETID in_id,
 	mPacketsOutID(0), 
 	mPacketsInID(in_id),
 	mHighestPacketID(in_id),
+	mTimeoutCallback(NULL),
+	mTimeoutUserData(NULL),
 	mTrusted(FALSE),
 	mbAllowTimeout(TRUE),
 	mbAlive(TRUE),
@@ -102,11 +104,12 @@ LLCircuitData::LLCircuitData(const LLHost &host, TPACKETID in_id,
 	mBytesOutLastPeriod(0),
 	mBytesInThisPeriod(0),
 	mBytesOutThisPeriod(0),
-	mPeakBPSIn(0),
-	mPeakBPSOut(0),
+	mPeakBPSIn(0.f),
+	mPeakBPSOut(0.f),
 	mPeriodTime(0.0),
 	mExistenceTimer(),
 	mCurrentResendCount(0),
+	mLastPacketGap(0),
 	mHeartbeatInterval(circuit_heartbeat_interval), 
 	mHeartbeatTimeout(circuit_timeout)
 {
@@ -121,9 +124,6 @@ LLCircuitData::LLCircuitData(const LLHost &host, TPACKETID in_id,
 	mNextPingSendTime = mLastPingSendTime + 0.95*mHeartbeatInterval + ll_frand(0.1f*mHeartbeatInterval);
 	mPeriodTime = mt_sec;
 
-	mTimeoutCallback = NULL;
-	mTimeoutUserData = NULL;
-
 	mLocalEndPointID.generate();
 }
 
diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index a4eb90d7ff82a2315333a04c4e7d253a4441d09e..1a432cd7dfdf91d4fa7a12e8584f52a26af63202 100644
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -74,7 +74,7 @@
 
 //////////////////////////////////////////////////////////////////////////////
 
-static const S32 EASY_HANDLE_POOL_SIZE		= 5;
+static const U32 EASY_HANDLE_POOL_SIZE		= 5;
 static const S32 MULTI_PERFORM_CALL_REPEAT	= 5;
 static const S32 CURL_REQUEST_TIMEOUT = 30; // seconds
 static const S32 MAX_ACTIVE_REQUEST_COUNT = 100;
diff --git a/indra/llmessage/lldatapacker.cpp b/indra/llmessage/lldatapacker.cpp
index 1cdb475b2fb0e5c17db22562d1e777e258f05513..1f52bf3a23ac9e1cc8555efcc360aa7a4c509676 100644
--- a/indra/llmessage/lldatapacker.cpp
+++ b/indra/llmessage/lldatapacker.cpp
@@ -1896,7 +1896,12 @@ BOOL LLDataPackerAsciiFile::getValueStr(const char *name, char *out_value, S32 v
 	if (mFP)
 	{
 		fpos_t last_pos;
-		fgetpos(mFP, &last_pos);
+		if (0 != fgetpos(mFP, &last_pos)) // 0==success for fgetpos
+		{
+			llwarns << "Data packer failed to fgetpos" << llendl;
+			return FALSE;
+		}
+
 		if (fgets(buffer, DP_BUFSIZE, mFP) == NULL)
 		{
 			buffer[0] = '\0';
diff --git a/indra/llmessage/llhttpclient.cpp b/indra/llmessage/llhttpclient.cpp
index a6041b413963f3f2e2d7dfdbda27b9c2d5abe019..307d9b92faab43b3761154e9982c22aef95cbf68 100644
--- a/indra/llmessage/llhttpclient.cpp
+++ b/indra/llmessage/llhttpclient.cpp
@@ -161,10 +161,9 @@ namespace
 				fstream.seekg(0, std::ios::end);
 				U32 fileSize = fstream.tellg();
 				fstream.seekg(0, std::ios::beg);
-				char* fileBuffer;
-				fileBuffer = new char [fileSize];
-				fstream.read(fileBuffer, fileSize);
-				ostream.write(fileBuffer, fileSize);
+				std::vector<char> fileBuffer(fileSize);
+				fstream.read(&fileBuffer[0], fileSize);
+				ostream.write(&fileBuffer[0], fileSize);
 				fstream.close();
 				eos = true;
 				return STATUS_DONE;
diff --git a/indra/llmessage/llinstantmessage.h b/indra/llmessage/llinstantmessage.h
index 96a2cf9cabe747f9e753d0b5320c7939a928a8f1..9ce6a10c806a9c24ae2385a78c195f20b4172547 100644
--- a/indra/llmessage/llinstantmessage.h
+++ b/indra/llmessage/llinstantmessage.h
@@ -74,6 +74,7 @@ enum EInstantMessage
 	// Group vote
 	// Name is name of person who called vote.
 	// ID is vote ID used for internal tracking
+	// TODO: _DEPRECATED suffix as part of vote removal - DEV-24856
 	IM_GROUP_VOTE = 7,
 
 	// Group message
diff --git a/indra/llmessage/lltemplatemessagereader.cpp b/indra/llmessage/lltemplatemessagereader.cpp
index d635844ee5bb0748e2f76a773e88c1c4f6e0d9f9..40e46b0ce9758b6b173961dac2116786c30099da 100644
--- a/indra/llmessage/lltemplatemessagereader.cpp
+++ b/indra/llmessage/lltemplatemessagereader.cpp
@@ -677,7 +677,11 @@ BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender
 						// default to 0s.
 						U32 size = mvci.getSize();
 						std::vector<U8> data(size);
-						memset(&(data[0]), 0, size);
+						if(size)
+						{
+							// Nonsense test to get past GCC 4.3.1 bug with -O3
+							memset(&(data[0]), 0, size);
+						}
 						cur_data_block->addData(mvci.getName(), &(data[0]), 
 												size, mvci.getType());
 					}
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 08d654805e38330cb3dab79fbb684dc0f6c98b0b..9e341446583745279a2a9bd8ba4d6d296d431600 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -209,7 +209,7 @@ BOOL LLGLSLShader::mapAttributes(const vector<string> * attributes)
 	{ //read back channel locations
 
 		//read back reserved channels first
-		for (U32 i = 0; i < (S32) LLShaderMgr::instance()->mReservedAttribs.size(); i++)
+		for (U32 i = 0; i < LLShaderMgr::instance()->mReservedAttribs.size(); i++)
 		{
 			const char* name = LLShaderMgr::instance()->mReservedAttribs[i].c_str();
 			S32 index = glGetAttribLocationARB(mProgramObject, (const GLcharARB *)name);
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index ba95a19787f20e031786f764e4913841eaabba2b..6bb217a9c2fbebc7c3e9d3369d0872d5d0872b5c 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -99,7 +99,7 @@ mCurrAlphaSrc1(TBS_TEX_ALPHA), mCurrAlphaSrc2(TBS_PREV_ALPHA),
 mCurrColorScale(1), mCurrAlphaScale(1), mCurrTexture(0),
 mHasMipMaps(false)
 {
-	llassert_always(index < LL_NUM_TEXTURE_LAYERS);
+	llassert_always(index < (S32)LL_NUM_TEXTURE_LAYERS);
 	mIndex = index;
 }
 
@@ -141,7 +141,7 @@ void LLTexUnit::activate(void)
 {
 	if (mIndex < 0) return;
 
-	if (gGL.mCurrTextureUnitIndex != mIndex || gGL.mDirty)
+	if ((S32)gGL.mCurrTextureUnitIndex != mIndex || gGL.mDirty)
 	{
 		glActiveTextureARB(GL_TEXTURE0_ARB + mIndex);
 		gGL.mCurrTextureUnitIndex = mIndex;
@@ -821,7 +821,7 @@ void LLRender::blendFunc(eBlendFactor sfactor, eBlendFactor dfactor)
 
 LLTexUnit* LLRender::getTexUnit(U32 index)
 {
-	if ((index >= 0) && (index < mTexUnits.size()))
+	if (index < mTexUnits.size())
 	{
 		return mTexUnits[index];
 	}
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 461edbeec7bd18d0ff4f6e6544abe8261632c8fb..5d88ea464d61192dd2a82c6b784db387de90a9dd 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -811,7 +811,7 @@ U8* LLVertexBuffer::mapBuffer(S32 access)
 
 			GLint buff;
 			glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &buff);
-			if (buff != mGLBuffer)
+			if ((GLuint)buff != mGLBuffer)
 			{
 				llerrs << "Invalid GL vertex buffer bound: " << buff << llendl;
 			}
@@ -824,7 +824,7 @@ U8* LLVertexBuffer::mapBuffer(S32 access)
 		{
 			GLint buff;
 			glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &buff);
-			if (buff != mGLIndices)
+			if ((GLuint)buff != mGLIndices)
 			{
 				llerrs << "Invalid GL index buffer bound: " << buff << llendl;
 			}
@@ -1020,13 +1020,13 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
 		{
 			GLint buff;
 			glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &buff);
-			if (buff != mGLBuffer)
+			if ((GLuint)buff != mGLBuffer)
 			{
 				llerrs << "Invalid GL vertex buffer bound: " << buff << llendl;
 			}
 
 			glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &buff);
-			if (buff != mGLIndices)
+			if ((GLuint)buff != mGLIndices)
 			{
 				llerrs << "Invalid GL index buffer bound: " << buff << llendl;
 			}
@@ -1038,13 +1038,13 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
 			{
 				GLint buff;
 				glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &buff);
-				if (buff != mGLBuffer)
+				if ((GLuint)buff != mGLBuffer)
 				{
 					llerrs << "Invalid GL vertex buffer bound: " << buff << llendl;
 				}
 
 				glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &buff);
-				if (buff != mGLIndices)
+				if ((GLuint)buff != mGLIndices)
 				{
 					llerrs << "Invalid GL index buffer bound: " << buff << llendl;
 				}
diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp
index 8a7a214048acf18bd7db25728c1d4a4ceece82ef..2cb8197a670236bbefe5cd41ce2786700d5662cd 100644
--- a/indra/llui/llclipboard.cpp
+++ b/indra/llui/llclipboard.cpp
@@ -93,3 +93,44 @@ BOOL LLClipboard::canPasteString() const
 {
 	return LLView::getWindow()->isClipboardTextAvailable();
 }
+
+
+void LLClipboard::copyFromPrimarySubstring(const LLWString &src, S32 pos, S32 len, const LLUUID& source_id )
+{
+	mSourceID = source_id;
+	mString = src.substr(pos, len);
+	LLView::getWindow()->copyTextToPrimary( mString );
+}
+
+
+const LLWString& LLClipboard::getPastePrimaryWString( LLUUID* source_id )
+{
+	if( mSourceID.notNull() )
+	{
+		LLWString temp_string;
+		LLView::getWindow()->pasteTextFromPrimary(temp_string);
+
+		if( temp_string != mString )
+		{
+			mSourceID.setNull();
+			mString = temp_string;
+		}
+	}
+	else
+	{
+		LLView::getWindow()->pasteTextFromPrimary(mString);
+	}
+
+	if( source_id )
+	{
+		*source_id = mSourceID;
+	}
+
+	return mString;
+}
+
+
+BOOL LLClipboard::canPastePrimaryString() const
+{
+	return LLView::getWindow()->isPrimaryTextAvailable();
+}
diff --git a/indra/llui/llclipboard.h b/indra/llui/llclipboard.h
index 37ed1ffe584ab06365e979f836054f60ff2d732d..034a7a6aebfdd8079b5cc32399c80152f86ec79f 100644
--- a/indra/llui/llclipboard.h
+++ b/indra/llui/llclipboard.h
@@ -44,10 +44,19 @@ public:
 	LLClipboard();
 	~LLClipboard();
 
+	/* We support two flavors of clipboard.  The default is the explicitly
+	   copy-and-pasted clipboard.  The second is the so-called 'primary' clipboard
+	   which is implicitly copied upon selection on platforms which expect this
+	   (i.e. X11/Linux). */
+
 	void		copyFromSubstring(const LLWString &copy_from, S32 pos, S32 len, const LLUUID& source_id = LLUUID::null );
 	BOOL		canPasteString() const;
 	const LLWString&	getPasteWString(LLUUID* source_id = NULL);
-	
+
+	void		copyFromPrimarySubstring(const LLWString &copy_from, S32 pos, S32 len, const LLUUID& source_id = LLUUID::null );
+	BOOL		canPastePrimaryString() const;
+	const LLWString&	getPastePrimaryWString(LLUUID* source_id = NULL);	
+
 private:
 	LLUUID		mSourceID;
 	LLWString	mString;
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 94af1868bed169ce3e8aff9c8613e32732329b2e..21f8f6e5f72aec9446d601c94b6e1911ba329cee 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -1193,6 +1193,12 @@ BOOL LLFloater::handleRightMouseDown(S32 x, S32 y, MASK mask)
 	return was_minimized || LLPanel::handleRightMouseDown( x, y, mask );
 }
 
+BOOL LLFloater::handleMiddleMouseDown(S32 x, S32 y, MASK mask)
+{
+	bringToFront( x, y );
+	return LLPanel::handleMiddleMouseDown( x, y, mask );
+}
+
 
 // virtual
 BOOL LLFloater::handleDoubleClick(S32 x, S32 y, MASK mask)
@@ -2188,7 +2194,7 @@ BOOL LLFloaterView::allChildrenClosed()
 		LLView* viewp = *it;
 		LLFloater* floaterp = (LLFloater*)viewp;
 
-		if (floaterp->getVisible() && !floaterp->isDead() && floaterp->canClose())
+		if (floaterp->getVisible() && !floaterp->isDead() && floaterp->isCloseable())
 		{
 			return false;
 		}
diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h
index a8f7c211fbbd0fde5c81fcec992a40c4f7cee829..0e3d148b09765902bc6bd390fd1fdd6322881167 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -195,7 +195,7 @@ public:
 	virtual BOOL	handleMouseDown(S32 x, S32 y, MASK mask);
 	virtual BOOL	handleRightMouseDown(S32 x, S32 y, MASK mask);
 	virtual BOOL	handleDoubleClick(S32 x, S32 y, MASK mask);
-
+	virtual BOOL	handleMiddleMouseDown(S32 x, S32 y, MASK mask);
 	virtual void	draw();
 
 	virtual void	onOpen() {}
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp
index 6aa2aac48cb0637d0f0b88f340b0931a92c7c081..964254d93f7035ec6010b18ab061afbc39d6f01e 100644
--- a/indra/llui/lllineeditor.cpp
+++ b/indra/llui/lllineeditor.cpp
@@ -489,6 +489,9 @@ BOOL LLLineEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
 	// delay cursor flashing
 	mKeystrokeTimer.reset();
 
+	// take selection to 'primary' clipboard
+	updatePrimary();
+
 	return TRUE;
 }
 
@@ -571,6 +574,17 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask)
 	return TRUE;
 }
 
+BOOL LLLineEditor::handleMiddleMouseDown(S32 x, S32 y, MASK mask)
+{
+        // llinfos << "MiddleMouseDown" << llendl;
+	setFocus( TRUE );
+	if( canPastePrimary() )
+	{
+		setCursorAtLocalPos(x);
+		pastePrimary();
+	}
+	return TRUE;
+}
 
 BOOL LLLineEditor::handleHover(S32 x, S32 y, MASK mask)
 {
@@ -665,6 +679,9 @@ BOOL LLLineEditor::handleMouseUp(S32 x, S32 y, MASK mask)
 	{
 		// delay cursor flashing
 		mKeystrokeTimer.reset();
+
+		// take selection to 'primary' clipboard
+		updatePrimary();
 	}
 
 	return handled;
@@ -868,7 +885,12 @@ BOOL LLLineEditor::handleSelectionKey(KEY key, MASK mask)
 		}
 	}
 
-
+	if(handled)
+	{
+		// take selection to 'primary' clipboard
+		updatePrimary();
+	}
+ 
 	return handled;
 }
 
@@ -877,7 +899,7 @@ void LLLineEditor::deleteSelection()
 	if( !mReadOnly && hasSelection() )
 	{
 		S32 left_pos = llmin( mSelectionStart, mSelectionEnd );
-		S32 selection_length = abs( mSelectionStart - mSelectionEnd );
+		S32 selection_length = llabs( mSelectionStart - mSelectionEnd );
 
 		mText.erase(left_pos, selection_length);
 		deselect();
@@ -900,7 +922,7 @@ void LLLineEditor::cut()
 
 
 		S32 left_pos = llmin( mSelectionStart, mSelectionEnd );
-		S32 length = abs( mSelectionStart - mSelectionEnd );
+		S32 length = llabs( mSelectionStart - mSelectionEnd );
 		gClipboard.copyFromSubstring( mText.getWString(), left_pos, length );
 		deleteSelection();
 
@@ -931,7 +953,7 @@ void LLLineEditor::copy()
 	if( canCopy() )
 	{
 		S32 left_pos = llmin( mSelectionStart, mSelectionEnd );
-		S32 length = abs( mSelectionStart - mSelectionEnd );
+		S32 length = llabs( mSelectionStart - mSelectionEnd );
 		gClipboard.copyFromSubstring( mText.getWString(), left_pos, length );
 	}
 }
@@ -941,20 +963,50 @@ BOOL LLLineEditor::canPaste() const
 	return !mReadOnly && gClipboard.canPasteString(); 
 }
 
-
-// paste from clipboard
 void LLLineEditor::paste()
 {
-	if (canPaste())
+	bool is_primary = false;
+	pasteHelper(is_primary);
+}
+
+void LLLineEditor::pastePrimary()
+{
+	bool is_primary = true;
+	pasteHelper(is_primary);
+}
+
+// paste from primary (is_primary==true) or clipboard (is_primary==false)
+void LLLineEditor::pasteHelper(bool is_primary)
+{
+	bool can_paste_it;
+	if (is_primary)
+	{
+		can_paste_it = canPastePrimary();
+	}
+	else
+	{
+		can_paste_it = canPaste();
+	}
+
+	if (can_paste_it)
 	{
-		LLWString paste = gClipboard.getPasteWString();
+		LLWString paste;
+		if (is_primary)
+		{
+			paste = gClipboard.getPastePrimaryWString();
+		}
+		else 
+		{
+			paste = gClipboard.getPasteWString();
+		}
+
 		if (!paste.empty())
 		{
 			// Prepare for possible rollback
 			LLLineEditorRollback rollback(this);
 			
 			// Delete any selected characters
-			if (hasSelection())
+			if ((!is_primary) && hasSelection())
 			{
 				deleteSelection();
 			}
@@ -990,7 +1042,7 @@ void LLLineEditor::paste()
 				clean_string = clean_string.substr(0, wchars_that_fit);
 				reportBadKeystroke();
 			}
-
+ 
 			mText.insert(getCursor(), clean_string);
 			setCursor( getCursor() + (S32)clean_string.length() );
 			deselect();
@@ -1011,7 +1063,30 @@ void LLLineEditor::paste()
 	}
 }
 
-	
+// copy selection to primary
+void LLLineEditor::copyPrimary()
+{
+	if( canCopy() )
+	{
+		S32 left_pos = llmin( mSelectionStart, mSelectionEnd );
+		S32 length = llabs( mSelectionStart - mSelectionEnd );
+		gClipboard.copyFromPrimarySubstring( mText.getWString(), left_pos, length );
+	}
+}
+
+BOOL LLLineEditor::canPastePrimary() const
+{
+	return !mReadOnly && gClipboard.canPastePrimaryString(); 
+}
+
+void LLLineEditor::updatePrimary()
+{
+	if(canCopy() )
+	{
+		copyPrimary();
+	}
+}
+
 BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask)	
 {
 	BOOL handled = FALSE;
diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h
index 254ba19e5978538c6e17b8b9f424782268965c12..fc5fcc5b905217412e2dbd6978384e526742fb79 100644
--- a/indra/llui/lllineeditor.h
+++ b/indra/llui/lllineeditor.h
@@ -90,6 +90,7 @@ public:
 	/*virtual*/ BOOL	handleMouseUp(S32 x, S32 y, MASK mask);
 	/*virtual*/ BOOL	handleHover(S32 x, S32 y, MASK mask);
 	/*virtual*/ BOOL	handleDoubleClick(S32 x,S32 y,MASK mask);
+	/*virtual*/ BOOL	handleMiddleMouseDown(S32 x,S32 y,MASK mask);
 	/*virtual*/ BOOL	handleKeyHere(KEY key, MASK mask );
 	/*virtual*/ BOOL	handleUnicodeCharHere(llwchar uni_char);
 	/*virtual*/ void	onMouseCaptureLost();
@@ -97,13 +98,16 @@ public:
 	// LLEditMenuHandler overrides
 	virtual void	cut();
 	virtual BOOL	canCut() const;
-
 	virtual void	copy();
 	virtual BOOL	canCopy() const;
-
 	virtual void	paste();
 	virtual BOOL	canPaste() const;
-	
+
+	virtual void	updatePrimary();
+	virtual void	copyPrimary();
+ 	virtual void	pastePrimary();
+	virtual BOOL	canPastePrimary() const;
+
 	virtual void	doDelete();
 	virtual BOOL	canDoDelete() const;
 
@@ -217,6 +221,9 @@ public:
 	
 private:
 	// private helper methods
+
+	void                    pasteHelper(bool is_primary);
+
 	void			removeChar();
 	void			addChar(const llwchar c);
 	void			setCursorAtLocalPos(S32 local_mouse_x);
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index f2f2aae38251bad56c57b733ee272b2b0b0b7e93..5fb0e57c06ccd0b24d156629249d979db7cc5e93 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -931,7 +931,8 @@ LLMenuItemCheckGL::LLMenuItemCheckGL ( const std::string& name,
 									   void* user_data,
 									   KEY key, MASK mask ) :
 	LLMenuItemCallGL( name, label, clicked_cb, enabled_cb, user_data, key, mask ),
-	mCheckCallback( NULL )
+	mCheckCallback( NULL ),
+	mChecked(FALSE)
 {
 	setControlName(control_name, context);
 }
diff --git a/indra/llui/llresmgr.cpp b/indra/llui/llresmgr.cpp
index 32d3d1f7522ff515882fcc63972cc79e7b4c9b44..141b08c39d1cbcbfe463739d01dd7c00e4fc943f 100644
--- a/indra/llui/llresmgr.cpp
+++ b/indra/llui/llresmgr.cpp
@@ -257,6 +257,8 @@ std::string LLResMgr::getMonetaryString( S32 input ) const
 	// On the Mac, locale support is broken before 10.4, which causes things to go all pear-shaped.
 	// Fake up a conv structure with some reasonable values for the fields this function uses.
 	struct lconv fakeconv;
+	char fake_neg[2] = "-";
+	char fake_mon_group[4] = "\x03\x03\x00"; // commas every 3 digits
 	if(conv->negative_sign[0] == 0)	// Real locales all seem to have something here...
 	{
 		fakeconv = *conv;	// start with what's there.
@@ -265,8 +267,8 @@ std::string LLResMgr::getMonetaryString( S32 input ) const
 			default:  			// Unknown -- use the US defaults.
 			case LLLOCALE_USA: 
 			case LLLOCALE_UK:	// UK ends up being the same as US for the items used here.
-				fakeconv.negative_sign = "-";
-				fakeconv.mon_grouping = "\x03\x03\x00";	// commas every 3 digits
+				fakeconv.negative_sign = fake_neg;
+				fakeconv.mon_grouping = fake_mon_group;
 				fakeconv.n_sign_posn = 1; // negative sign before the string
 			break;
 		}
diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp
index 7b6c125eb10c2b6ae6305515812cbee791c8cba9..5dd4e2d0ee79e00de8917814cc9b24621bb9f2fe 100644
--- a/indra/llui/llscrolllistctrl.cpp
+++ b/indra/llui/llscrolllistctrl.cpp
@@ -835,6 +835,12 @@ void LLScrollListCtrl::updateLayout()
 		mItemListRect.mRight = getRect().getWidth() - mBorderThickness - SCROLLBAR_SIZE;
 	}
 
+	// don't allow scrolling off bottom
+	if (mScrollLines + mPageLines > getItemCount())
+	{
+		setScrollPos(llmax(0, getItemCount() - mPageLines));
+	}
+
 	mScrollbar->reshape(SCROLLBAR_SIZE, mItemListRect.getHeight() + (mDisplayColumnHeaders ? mHeadingHeight : 0));
 	mScrollbar->setPageSize( mPageLines );
 	mScrollbar->setDocSize( getItemCount() );
@@ -2663,6 +2669,11 @@ void LLScrollListCtrl::scrollToShowSelected()
 		return;
 	}
 
+	if (needsSorting() && !isSorted())
+	{
+		sortItems();
+	}	
+	
 	S32 index = getFirstSelectedIndex();
 	if (index < 0)
 	{
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index 7928887d4b37316309eaffcc746b5b13389a43dd..5e54c7a307cb21223e6473a790c29ec51fdff852 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -933,7 +933,7 @@ BOOL LLTextEditor::selectionContainsLineBreaks()
 	if (hasSelection())
 	{
 		S32 left = llmin(mSelectionStart, mSelectionEnd);
-		S32 right = left + abs(mSelectionStart - mSelectionEnd);
+		S32 right = left + llabs(mSelectionStart - mSelectionEnd);
 
 		const LLWString &wtext = mWText;
 		for( S32 i = left; i < right; i++ )
@@ -989,7 +989,7 @@ void LLTextEditor::indentSelectedLines( S32 spaces )
 	{
 		const LLWString &text = mWText;
 		S32 left = llmin( mSelectionStart, mSelectionEnd );
-		S32 right = left + abs( mSelectionStart - mSelectionEnd );
+		S32 right = left + llabs( mSelectionStart - mSelectionEnd );
 		BOOL cursor_on_right = (mSelectionEnd > mSelectionStart);
 		S32 cur = left;
 
@@ -1203,6 +1203,18 @@ BOOL LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask)
 }
 
 
+BOOL LLTextEditor::handleMiddleMouseDown(S32 x, S32 y, MASK mask)
+{
+	setFocus( TRUE );
+	if( canPastePrimary() )
+	{
+		setCursorAtLocalPos( x, y, TRUE );
+		pastePrimary();
+	}
+	return TRUE;
+}
+
+
 BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask)
 {
 	BOOL handled = FALSE;
@@ -1323,8 +1335,6 @@ BOOL LLTextEditor::handleMouseUp(S32 x, S32 y, MASK mask)
 			
 			setCursorAtLocalPos( x, y, TRUE );
 			endSelection();
-
-			updateScrollFromCursor();
 		}
 		
 		if( !hasSelection() )
@@ -1332,6 +1342,9 @@ BOOL LLTextEditor::handleMouseUp(S32 x, S32 y, MASK mask)
 			handleMouseUpOverSegment( x, y, mask );
 		}
 
+		// take selection to 'primary' clipboard
+		updatePrimary();
+
 		handled = TRUE;
 	}
 
@@ -1394,8 +1407,12 @@ BOOL LLTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
 		// delay cursor flashing
 		resetKeystrokeTimer();
 
+		// take selection to 'primary' clipboard
+		updatePrimary();
+
 		handled = TRUE;
 	}
+
 	return handled;
 }
 
@@ -1691,6 +1708,12 @@ BOOL LLTextEditor::handleSelectionKey(const KEY key, const MASK mask)
 		}
 	}
 
+	if( handled )
+	{
+		// take selection to 'primary' clipboard
+		updatePrimary();
+	}
+ 
 	return handled;
 }
 
@@ -1818,7 +1841,7 @@ void LLTextEditor::deleteSelection(BOOL group_with_next_op )
 	if( getEnabled() && hasSelection() )
 	{
 		S32 pos = llmin( mSelectionStart, mSelectionEnd );
-		S32 length = abs( mSelectionStart - mSelectionEnd );
+		S32 length = llabs( mSelectionStart - mSelectionEnd );
 	
 		remove( pos, length, group_with_next_op );
 
@@ -1841,7 +1864,7 @@ void LLTextEditor::cut()
 		return;
 	}
 	S32 left_pos = llmin( mSelectionStart, mSelectionEnd );
-	S32 length = abs( mSelectionStart - mSelectionEnd );
+	S32 length = llabs( mSelectionStart - mSelectionEnd );
 	gClipboard.copyFromSubstring( mWText, left_pos, length, mSourceID );
 	deleteSelection( FALSE );
 
@@ -1861,7 +1884,7 @@ void LLTextEditor::copy()
 		return;
 	}
 	S32 left_pos = llmin( mSelectionStart, mSelectionEnd );
-	S32 length = abs( mSelectionStart - mSelectionEnd );
+	S32 length = llabs( mSelectionStart - mSelectionEnd );
 	gClipboard.copyFromSubstring(mWText, left_pos, length, mSourceID);
 }
 
@@ -1870,22 +1893,56 @@ BOOL LLTextEditor::canPaste() const
 	return !mReadOnly && gClipboard.canPasteString();
 }
 
-
 // paste from clipboard
 void LLTextEditor::paste()
 {
-	if (!canPaste())
+	bool is_primary = false;
+	pasteHelper(is_primary);
+}
+
+// paste from primary
+void LLTextEditor::pastePrimary()
+{
+	bool is_primary = true;
+	pasteHelper(is_primary);
+}
+
+// paste from primary (itsprimary==true) or clipboard (itsprimary==false)
+void LLTextEditor::pasteHelper(bool is_primary)
+{
+	bool can_paste_it;
+	if (is_primary)
+	{
+		can_paste_it = canPastePrimary();
+	}
+	else
+	{
+		can_paste_it = canPaste();
+	}
+
+	if (!can_paste_it)
 	{
 		return;
 	}
+
 	LLUUID source_id;
-	LLWString paste = gClipboard.getPasteWString(&source_id);
+	LLWString paste;
+	if (is_primary)
+	{
+		paste = gClipboard.getPastePrimaryWString(&source_id);
+	}
+	else 
+	{
+		paste = gClipboard.getPasteWString(&source_id);
+	}
+
 	if (paste.empty())
 	{
 		return;
 	}
+
 	// Delete any selected characters (the paste replaces them)
-	if( hasSelection() )
+	if( (!is_primary) && hasSelection() )
 	{
 		deleteSelection(TRUE);
 	}
@@ -1919,6 +1976,32 @@ void LLTextEditor::paste()
 }
 
 
+
+// copy selection to primary
+void LLTextEditor::copyPrimary()
+{
+	if( !canCopy() )
+	{
+		return;
+	}
+	S32 left_pos = llmin( mSelectionStart, mSelectionEnd );
+	S32 length = llabs( mSelectionStart - mSelectionEnd );
+	gClipboard.copyFromPrimarySubstring(mWText, left_pos, length, mSourceID);
+}
+
+BOOL LLTextEditor::canPastePrimary() const
+{
+	return !mReadOnly && gClipboard.canPastePrimaryString();
+}
+
+void LLTextEditor::updatePrimary()
+{
+	if (canCopy())
+	{
+		copyPrimary();
+	}
+}
+
 BOOL LLTextEditor::handleControlKey(const KEY key, const MASK mask)	
 {
 	BOOL handled = FALSE;
@@ -1994,6 +2077,11 @@ BOOL LLTextEditor::handleControlKey(const KEY key, const MASK mask)
 		}
 	}
 
+	if (handled)
+	{
+		updatePrimary();
+	}
+
 	return handled;
 }
 
@@ -4330,13 +4418,34 @@ S32 LLTextEditor::findHTMLToken(const std::string &line, S32 pos, BOOL reverse)
 	} 
 	else
 	{
+		// adjust the search slightly, to allow matching parenthesis inside the URL
+		S32 paren_count = 0;
 		for (int index=pos; index<(S32)line.length(); index++)
 		{
 			char c = line[index];
-			S32 m2 = closers.find(c);
-			if (m2 >= 0)
+
+			if (c == '(')
 			{
-				return index;
+				paren_count++;
+			}
+			else if (c == ')')
+			{
+				if (paren_count <= 0)
+				{
+					return index;
+				}
+				else
+				{
+					paren_count--;
+				}
+			}
+			else
+			{
+				S32 m2 = closers.find(c);
+				if (m2 >= 0)
+				{
+					return index;
+				}
 			}
 		} 
 		return line.length();
diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h
index 56825e7bfef70f6c0c68b6ab18705e507268bc81..9291e1c436aaee93d67b96c2bf8cd3a08df58099 100644
--- a/indra/llui/lltexteditor.h
+++ b/indra/llui/lltexteditor.h
@@ -84,6 +84,8 @@ public:
 	virtual BOOL	handleHover(S32 x, S32 y, MASK mask);
 	virtual BOOL	handleScrollWheel(S32 x, S32 y, S32 clicks);
 	virtual BOOL	handleDoubleClick(S32 x, S32 y, MASK mask );
+	virtual BOOL	handleMiddleMouseDown(S32 x,S32 y,MASK mask);
+
 	virtual BOOL	handleKeyHere(KEY key, MASK mask );
 	virtual BOOL	handleUnicodeCharHere(llwchar uni_char);
 
@@ -112,12 +114,19 @@ public:
 	virtual BOOL	canUndo() const;
 	virtual void	redo();
 	virtual BOOL	canRedo() const;
+
 	virtual void	cut();
 	virtual BOOL	canCut() const;
 	virtual void	copy();
 	virtual BOOL	canCopy() const;
 	virtual void	paste();
 	virtual BOOL	canPaste() const;
+ 
+	virtual void	updatePrimary();
+	virtual void	copyPrimary();
+	virtual void	pastePrimary();
+	virtual BOOL	canPastePrimary() const;
+
 	virtual void	doDelete();
 	virtual BOOL	canDoDelete() const;
 	virtual void	selectAll();
@@ -430,6 +439,8 @@ private:
 	//
 	// Methods
 	//
+	void	                pasteHelper(bool is_primary);
+
 	void			updateSegments();
 	void			pruneSegments();
 
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index a3db076b17eb9b85b6b50b1e39b57552f5bf9b7e..699c76a09db82a4670fd09e294c936742160fcd5 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -987,6 +987,30 @@ BOOL LLView::handleRightMouseUp(S32 x, S32 y, MASK mask)
 	}
 	return handled;
 }
+ 
+BOOL LLView::handleMiddleMouseDown(S32 x, S32 y, MASK mask)
+{
+	LLView* handled_view = childrenHandleMiddleMouseDown( x, y, mask );
+	BOOL handled = (handled_view != NULL);
+	if( !handled && blockMouseEvent(x, y) )
+	{
+		handled = TRUE;
+		handled_view = this;
+	}
+
+	return handled;
+}
+
+BOOL LLView::handleMiddleMouseUp(S32 x, S32 y, MASK mask)
+{
+	BOOL handled = childrenHandleMiddleMouseUp( x, y, mask ) != NULL;
+	if( !handled && blockMouseEvent(x, y) )
+	{
+		handled = TRUE;
+	}
+	return handled;
+}
+
 
 LLView* LLView::childrenHandleScrollWheel(S32 x, S32 y, S32 clicks)
 {
@@ -1148,6 +1172,34 @@ LLView* LLView::childrenHandleRightMouseDown(S32 x, S32 y, MASK mask)
 	return handled_view;
 }
 
+LLView* LLView::childrenHandleMiddleMouseDown(S32 x, S32 y, MASK mask)
+{
+	LLView* handled_view = NULL;
+
+	if (getVisible() && getEnabled() )
+	{
+		for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
+		{
+			LLView* viewp = *child_it;
+			S32 local_x = x - viewp->getRect().mLeft;
+			S32 local_y = y - viewp->getRect().mBottom;
+			if (viewp->pointInView(local_x, local_y) &&
+				viewp->getVisible() &&
+				viewp->getEnabled() &&
+				viewp->handleMiddleMouseDown( local_x, local_y, mask ))
+			{
+				if (sDebugMouseHandling)
+				{
+					sMouseHandlerMessage = std::string("->") + viewp->mName + sMouseHandlerMessage;
+				}
+				handled_view = viewp;
+				break;
+			}
+		}
+	}
+	return handled_view;
+}
+
 LLView* LLView::childrenHandleDoubleClick(S32 x, S32 y, MASK mask)
 {
 	LLView* handled_view = NULL;
@@ -1233,6 +1285,32 @@ LLView* LLView::childrenHandleRightMouseUp(S32 x, S32 y, MASK mask)
 	return handled_view;
 }
 
+LLView* LLView::childrenHandleMiddleMouseUp(S32 x, S32 y, MASK mask)
+{
+	LLView* handled_view = NULL;
+	if( getVisible() && getEnabled() )
+	{
+		for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
+		{
+			LLView* viewp = *child_it;
+			S32 local_x = x - viewp->getRect().mLeft;
+			S32 local_y = y - viewp->getRect().mBottom;
+			if (viewp->pointInView(local_x, local_y) &&
+				viewp->getVisible() &&
+				viewp->getEnabled() &&
+				viewp->handleMiddleMouseUp( local_x, local_y, mask ))
+			{
+				if (sDebugMouseHandling)
+				{
+					sMouseHandlerMessage = std::string("->") + viewp->mName + sMouseHandlerMessage;
+				}
+				handled_view = viewp;
+				break;
+			}
+		}
+	}
+	return handled_view;
+}
 
 void LLView::draw()
 {
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index b5a34bd4bd4e0fb8041454aa38c0553b4dbe6843..e0e0f6ba47aee3c1584814048cb27bda76da053d 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -465,6 +465,8 @@ public:
 	/*virtual*/ BOOL	handleHover(S32 x, S32 y, MASK mask);
 	/*virtual*/ BOOL	handleMouseUp(S32 x, S32 y, MASK mask);
 	/*virtual*/ BOOL	handleMouseDown(S32 x, S32 y, MASK mask);
+	/*virtual*/ BOOL	handleMiddleMouseUp(S32 x, S32 y, MASK mask);
+	/*virtual*/ BOOL	handleMiddleMouseDown(S32 x, S32 y, MASK mask);
 	/*virtual*/ BOOL	handleDoubleClick(S32 x, S32 y, MASK mask);
 	/*virtual*/ BOOL	handleScrollWheel(S32 x, S32 y, S32 clicks);
 	/*virtual*/ BOOL	handleRightMouseDown(S32 x, S32 y, MASK mask);
@@ -603,6 +605,8 @@ protected:
 	LLView*	childrenHandleHover(S32 x, S32 y, MASK mask);
 	LLView* childrenHandleMouseUp(S32 x, S32 y, MASK mask);
 	LLView* childrenHandleMouseDown(S32 x, S32 y, MASK mask);
+	LLView* childrenHandleMiddleMouseUp(S32 x, S32 y, MASK mask);
+	LLView* childrenHandleMiddleMouseDown(S32 x, S32 y, MASK mask);
 	LLView* childrenHandleDoubleClick(S32 x, S32 y, MASK mask);
 	LLView*	childrenHandleScrollWheel(S32 x, S32 y, S32 clicks);
 	LLView* childrenHandleRightMouseDown(S32 x, S32 y, MASK mask);
diff --git a/indra/llvfs/llvfs.cpp b/indra/llvfs/llvfs.cpp
index e5ffce4ffcb6f7efae9203009129e07301bef794..97632b3496d9652d8c43ab87ae0fc2bccf2e4e9e 100644
--- a/indra/llvfs/llvfs.cpp
+++ b/indra/llvfs/llvfs.cpp
@@ -354,18 +354,17 @@ LLVFS::LLVFS(const std::string& index_filename, const std::string& data_filename
 		(mIndexFP = openAndLock(mIndexFilename, file_mode, mReadOnly))
 		)
 	{	
-		U8 *buffer = new U8[fbuf.st_size];
-		size_t nread = fread(buffer, 1, fbuf.st_size, mIndexFP);
-    
-		U8 *tmp_ptr = buffer;
-    
+		std::vector<U8> buffer(fbuf.st_size);
+    		size_t buf_offset = 0;
+		size_t nread = fread(&buffer[0], 1, fbuf.st_size, mIndexFP);
+ 
 		std::vector<LLVFSFileBlock*> files_by_loc;
 		
-		while (tmp_ptr < buffer + nread)
+		while (buf_offset < nread)
 		{
 			LLVFSFileBlock *block = new LLVFSFileBlock();
     
-			block->deserialize(tmp_ptr, (S32)(tmp_ptr - buffer));
+			block->deserialize(&buffer[buf_offset], (S32)buf_offset);
     
 			// Do sanity check on this block.
 			// Note that this skips zero size blocks, which helps VFS
@@ -389,7 +388,6 @@ LLVFS::LLVFS(const std::string& index_filename, const std::string& data_filename
 				LL_WARNS("VFS") << "Length: " << block->mLength << "\tLocation: " << block->mLocation << "\tSize: " << block->mSize << LL_ENDL;
 				LL_WARNS("VFS") << "File has bad data - VFS removed" << LL_ENDL;
 
-				delete[] buffer;
 				delete block;
 
 				unlockAndClose( mIndexFP );
@@ -412,15 +410,13 @@ LLVFS::LLVFS(const std::string& index_filename, const std::string& data_filename
 			else
 			{
 				// this is a null or bad entry, skip it
-				S32 index_loc = (S32)(tmp_ptr - buffer);
-				mIndexHoles.push_back(index_loc);
+				mIndexHoles.push_back(buf_offset);
     
 				delete block;
 			}
     
-			tmp_ptr += LLVFSFileBlock::SERIAL_SIZE;
+			buf_offset += LLVFSFileBlock::SERIAL_SIZE;
 		}
-		delete[] buffer;
 
 		std::sort(
 			files_by_loc.begin(),
@@ -861,20 +857,18 @@ BOOL LLVFS::setMaxSize(const LLUUID &file_id, const LLAssetType::EType file_type
 					if (block->mSize > 0)
 					{
 						// move the file into the new block
-						U8 *buffer = new U8[block->mSize];
+						std::vector<U8> buffer(block->mSize);
 						fseek(mDataFP, block->mLocation, SEEK_SET);
-						if (fread(buffer, block->mSize, 1, mDataFP) == 1)
+						if (fread(&buffer[0], block->mSize, 1, mDataFP) == 1)
 						{
 							fseek(mDataFP, new_data_location, SEEK_SET);
-							if (fwrite(buffer, block->mSize, 1, mDataFP) != 1)
+							if (fwrite(&buffer[0], block->mSize, 1, mDataFP) != 1)
 							{
 								llwarns << "Short write" << llendl;
 							}
 						} else {
 							llwarns << "Short read" << llendl;
 						}
-    
-						delete[] buffer;
 					}
 				}
     
@@ -1698,32 +1692,32 @@ void LLVFS::audit()
 	fflush(mIndexFP);
 
 	fseek(mIndexFP, 0, SEEK_END);
-	long index_size = ftell(mIndexFP);
+	size_t index_size = ftell(mIndexFP);
 	fseek(mIndexFP, 0, SEEK_SET);
     
 	BOOL vfs_corrupt = FALSE;
 	
-	U8 *buffer = new U8[index_size];
+	std::vector<U8> buffer(index_size);
 
-	if (fread(buffer, 1, index_size, mIndexFP) != index_size)
+	if (fread(&buffer[0], 1, index_size, mIndexFP) != index_size)
 	{
 		llwarns << "Index truncated" << llendl;
 		vfs_corrupt = TRUE;
 	}
     
-	U8 *tmp_ptr = buffer;
+	size_t buf_offset = 0;
     
 	std::map<LLVFSFileSpecifier, LLVFSFileBlock*>	found_files;
 	U32 cur_time = (U32)time(NULL);
 
 	std::vector<LLVFSFileBlock*> audit_blocks;
-	while (!vfs_corrupt && tmp_ptr < buffer + index_size)
+	while (!vfs_corrupt && buf_offset < index_size)
 	{
 		LLVFSFileBlock *block = new LLVFSFileBlock();
 		audit_blocks.push_back(block);
 		
-		block->deserialize(tmp_ptr, (S32)(tmp_ptr - buffer));
-		tmp_ptr += block->SERIAL_SIZE;
+		block->deserialize(&buffer[buf_offset], (S32)buf_offset);
+		buf_offset += block->SERIAL_SIZE;
     
 		// do sanity check on this block
 		if (block->mLength >= 0 &&
@@ -1782,8 +1776,6 @@ void LLVFS::audit()
 		}
 	}
     
-	delete[] buffer;
-
 	if (!vfs_corrupt)
 	{
 		for (fileblock_map::iterator it = mFileBlocks.begin(); it != mFileBlocks.end(); ++it)
@@ -2078,21 +2070,21 @@ void LLVFS::dumpFiles()
 		{
 			LLUUID id = file_spec.mFileID;
 			LLAssetType::EType type = file_spec.mFileType;
-			U8* buffer = new U8[size];
+			std::vector<U8> buffer(size);
 
 			unlockData();
-			getData(id, type, buffer, 0, size);
+			getData(id, type, &buffer[0], 0, size);
 			lockData();
 			
 			std::string extension = get_extension(type);
 			std::string filename = id.asString() + extension;
 			llinfos << " Writing " << filename << llendl;
 			
-			LLAPRFile outfile ;
+			LLAPRFile outfile;
 			outfile.open(filename, LL_APR_WB);
-			outfile.write(buffer, size);
+			outfile.write(&buffer[0], size);
 			outfile.close();
-			delete[] buffer;
+
 			files_extracted++;
 		}
 	}
diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt
index 95e315f38e17fec1b793bca61a89c7dff135c509..afce0c06c38cf18cf48ab01af3ba1ff404ba589c 100644
--- a/indra/llwindow/CMakeLists.txt
+++ b/indra/llwindow/CMakeLists.txt
@@ -46,6 +46,7 @@ set(llwindows_HEADER_FILES
 
 set(viewer_SOURCE_FILES
     llwindow.cpp
+    llmousehandler.cpp
     )
 
 set(viewer_HEADER_FILES
diff --git a/indra/llwindow/llmousehandler.cpp b/indra/llwindow/llmousehandler.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..daf39f8d8318f5c9df123fe80a92af7faa91ddc9
--- /dev/null
+++ b/indra/llwindow/llmousehandler.cpp
@@ -0,0 +1,63 @@
+/** 
+ * @file llmousehandler.cpp
+ * @brief LLMouseHandler class implementation
+ *
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2007, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlife.com/developers/opensource/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at http://secondlife.com/developers/opensource/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "llmousehandler.h"
+
+//virtual
+BOOL LLMouseHandler::handleAnyMouseClick(S32 x, S32 y, MASK mask, EClickType clicktype, BOOL down)
+{
+	BOOL handled = FALSE;
+	if (down)
+	{
+		switch (clicktype)
+		{
+		case CLICK_LEFT: handled = handleMouseDown(x, y, mask); break;
+		case CLICK_RIGHT: handled = handleRightMouseDown(x, y, mask); break;
+		case CLICK_MIDDLE: handled = handleMiddleMouseDown(x, y, mask); break;
+		case CLICK_DOUBLELEFT: handled = handleDoubleClick(x, y, mask); break;
+		default:
+			llwarns << "Unhandled enum." << llendl;
+		}
+	}
+	else
+	{
+		switch (clicktype)
+		{
+		case CLICK_LEFT: handled = handleMouseUp(x, y, mask); break;
+		case CLICK_RIGHT: handled = handleRightMouseUp(x, y, mask); break;
+		case CLICK_MIDDLE: handled = handleMiddleMouseUp(x, y, mask); break;
+		case CLICK_DOUBLELEFT: handled = handleDoubleClick(x, y, mask); break;
+		default:
+			llwarns << "Unhandled enum." << llendl;
+		}
+	}
+	return handled;
+}
diff --git a/indra/llwindow/llmousehandler.h b/indra/llwindow/llmousehandler.h
index f3a2edd8a202963f13ef8425d9bee4389451739a..7bd0f2eebf1ec802d719ffa5e2a591379e01b0be 100644
--- a/indra/llwindow/llmousehandler.h
+++ b/indra/llwindow/llmousehandler.h
@@ -33,9 +33,10 @@
 #ifndef LL_MOUSEHANDLER_H
 #define LL_MOUSEHANDLER_H
 
-#include "llstring.h"
+#include "linden_common.h"
+#include "llrect.h"
 
-// Abstract interface.
+// Mostly-abstract interface.
 // Intended for use via multiple inheritance. 
 // A class may have as many interfaces as it likes, but never needs to inherit one more than once.
 
@@ -49,13 +50,23 @@ public:
 		SHOW_IF_NOT_BLOCKED,
 		SHOW_ALWAYS,
 	} EShowToolTip;
+	typedef enum {
+		CLICK_LEFT,
+		CLICK_MIDDLE,
+		CLICK_RIGHT,
+		CLICK_DOUBLELEFT
+	} EClickType;
+	virtual BOOL	handleAnyMouseClick(S32 x, S32 y, MASK mask, EClickType clicktype, BOOL down);
 	virtual BOOL	handleMouseDown(S32 x, S32 y, MASK mask) = 0;
 	virtual BOOL	handleMouseUp(S32 x, S32 y, MASK mask) = 0;
-	virtual BOOL	handleHover(S32 x, S32 y, MASK mask) = 0;
-	virtual BOOL	handleScrollWheel(S32 x, S32 y, S32 clicks) = 0;
-	virtual BOOL	handleDoubleClick(S32 x, S32 y, MASK mask) = 0;
+	virtual BOOL	handleMiddleMouseDown(S32 x, S32 y, MASK mask) = 0;
+	virtual BOOL	handleMiddleMouseUp(S32 x, S32 y, MASK mask) = 0;
 	virtual BOOL	handleRightMouseDown(S32 x, S32 y, MASK mask) = 0;
 	virtual BOOL	handleRightMouseUp(S32 x, S32 y, MASK mask) = 0;
+	virtual BOOL	handleDoubleClick(S32 x, S32 y, MASK mask) = 0;
+
+	virtual BOOL	handleHover(S32 x, S32 y, MASK mask) = 0;
+	virtual BOOL	handleScrollWheel(S32 x, S32 y, S32 clicks) = 0;
 	virtual BOOL	handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen) = 0;
 	virtual EShowToolTip getShowToolTip() { return SHOW_IF_NOT_BLOCKED; };
 	virtual const std::string& getName() const = 0;
diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp
index fb4770e8476849fe72672339c64e78e112dfe8a4..7e412a14deab904580ff1fb03d913e9b2e505ee4 100644
--- a/indra/llwindow/llwindow.cpp
+++ b/indra/llwindow/llwindow.cpp
@@ -308,6 +308,28 @@ void *LLWindow::getMediaWindow()
 	return getPlatformWindow();
 }
 
+//virtual
+void LLWindow::processMiscNativeEvents()
+{
+	// do nothing unless subclassed
+}
+
+//virtual
+BOOL LLWindow::isPrimaryTextAvailable()
+{
+	return FALSE; // no
+}
+//virtual
+BOOL LLWindow::pasteTextFromPrimary(LLWString &dst)
+{
+	return FALSE; // fail
+}
+// virtual
+BOOL LLWindow::copyTextToPrimary(const LLWString &src)
+{
+	return FALSE; // fail
+}
+
 // static
 std::vector<std::string> LLWindow::getDynamicFallbackFontList()
 {
@@ -322,12 +344,6 @@ std::vector<std::string> LLWindow::getDynamicFallbackFontList()
 #endif
 }
 
-//virtual
-void LLWindow::processMiscNativeEvents()
-{
-	// do nothing unless subclassed
-}
-
 #define UTF16_IS_HIGH_SURROGATE(U) ((U16)((U) - 0xD800) < 0x0400)
 #define UTF16_IS_LOW_SURROGATE(U)  ((U16)((U) - 0xDC00) < 0x0400)
 #define UTF16_SURROGATE_PAIR_TO_UTF32(H,L) (((H) << 10) + (L) - (0xD800 << 10) - 0xDC00 + 0x00010000)
diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h
index 9e01596b81bafcdc518ea06e865c4f1f6d8f6ba7..8361771b665ab42d7c326e27140e6caa2031b784 100644
--- a/indra/llwindow/llwindow.h
+++ b/indra/llwindow/llwindow.h
@@ -144,9 +144,15 @@ public:
 	virtual void captureMouse() = 0;
 	virtual void releaseMouse() = 0;
 	virtual void setMouseClipping( BOOL b ) = 0;
+
 	virtual BOOL isClipboardTextAvailable() = 0;
 	virtual BOOL pasteTextFromClipboard(LLWString &dst) = 0;
 	virtual BOOL copyTextToClipboard(const LLWString &src) = 0;
+
+	virtual BOOL isPrimaryTextAvailable();
+	virtual BOOL pasteTextFromPrimary(LLWString &dst);
+	virtual BOOL copyTextToPrimary(const LLWString &src);
+ 
 	virtual void flashIcon(F32 seconds) = 0;
 	virtual F32 getGamma() = 0;
 	virtual BOOL setGamma(const F32 gamma) = 0; // Set the gamma
diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp
index 4f6df0f1524bcb416f5251cc84365a2faa312d75..65a40dcef4bf5e72f38aa4fd973f3249c2358b68 100644
--- a/indra/llwindow/llwindowmacosx.cpp
+++ b/indra/llwindow/llwindowmacosx.cpp
@@ -2527,19 +2527,33 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
 			}
 			mCallbacks->handleFocusLost(this);
 			break;
+			
 		case kEventWindowBoundsChanging:
 			{
+				// This is where we would constrain move/resize to a particular screen
+
+				const S32 MIN_WIDTH  = 320;
+				const S32 MIN_HEIGHT = 240;
+				
 				Rect currentBounds;
 				Rect previousBounds;
 
 				GetEventParameter(event, kEventParamCurrentBounds, typeQDRectangle, NULL, sizeof(Rect), NULL, &currentBounds);
 				GetEventParameter(event, kEventParamPreviousBounds, typeQDRectangle, NULL, sizeof(Rect), NULL, &previousBounds);
 
-				// This is where we would constrain move/resize to a particular screen
-				if(0)
+
+				if ((currentBounds.right - currentBounds.left) < MIN_WIDTH)
 				{
-					SetEventParameter(event, kEventParamCurrentBounds, typeQDRectangle, sizeof(Rect), &currentBounds);
+					currentBounds.right = currentBounds.left + MIN_WIDTH;
 				}
+
+				if ((currentBounds.bottom - currentBounds.top) < MIN_HEIGHT)
+				{
+					currentBounds.bottom = currentBounds.top + MIN_HEIGHT;
+				}
+				
+				SetEventParameter(event, kEventParamCurrentBounds, typeQDRectangle, sizeof(Rect), &currentBounds);
+				result = noErr;
 			}
 			break;
 
@@ -2597,7 +2611,6 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
 			//					BringToFront(mWindow);
 			//					result = noErr;
 			break;
-		
 		}
 		break;
 
diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp
index d6ee7acbaa7b23366a0d63656771a9186e83329f..24bd70d57f91f012351de892cd9f8febc19fd278 100644
--- a/indra/llwindow/llwindowsdl.cpp
+++ b/indra/llwindow/llwindowsdl.cpp
@@ -222,8 +222,8 @@ LLWindowSDL::LLWindowSDL(const std::string& title, S32 x, S32 y, S32 width,
 	ll_try_gtk_init();
 #endif // LL_GTK
 
-	// Get the original aspect ratio of the main device.
-	mOriginalAspectRatio = 1024.0 / 768.0;  // !!! *FIX: ? //(double)CGDisplayPixelsWide(mDisplay) / (double)CGDisplayPixelsHigh(mDisplay);
+	// Assume 4:3 aspect ratio until we know better
+	mOriginalAspectRatio = 1024.0 / 768.0;
 
 	if (title.empty())
 		mWindowTitle = "SDL Window";  // *FIX: (???)
@@ -444,14 +444,20 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
 		<< int(r_sdl_version->minor) << "."
 		<< int(r_sdl_version->patch) << llendl;
 
-	const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo( );
-	if (!videoInfo)
+	const SDL_VideoInfo *video_info = SDL_GetVideoInfo( );
+	if (!video_info)
 	{
 		llinfos << "SDL_GetVideoInfo() failed! " << SDL_GetError() << llendl;
 		setupFailure("SDL_GetVideoInfo() failed, Window creation error", "Error", OSMB_OK);
 		return FALSE;
 	}
 
+	if (video_info->current_h > 0)
+	{
+		mOriginalAspectRatio = (float)video_info->current_w / (float)video_info->current_h;
+		llinfos << "Original aspect ratio was " << video_info->current_w << ":" << video_info->current_h << "=" << mOriginalAspectRatio << llendl;
+	}
+
 	SDL_EnableUNICODE(1);
 	SDL_WM_SetCaption(mWindowTitle.c_str(), mWindowTitle.c_str());
 
@@ -643,7 +649,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
 		// fallback to letting SDL detect VRAM.
 		// note: I've not seen SDL's detection ever actually find
 		// VRAM != 0, but if SDL *does* detect it then that's a bonus.
-		gGLManager.mVRAM = videoInfo->video_mem / 1024;
+		gGLManager.mVRAM = video_info->video_mem / 1024;
 		if (gGLManager.mVRAM != 0)
 		{
 			llinfos << "SDL detected " << gGLManager.mVRAM << "MB VRAM." << llendl;
@@ -1272,6 +1278,49 @@ BOOL LLWindowSDL::copyTextToClipboard(const LLWString &text)
 	return FALSE; // failure
 }
 
+
+BOOL LLWindowSDL::isPrimaryTextAvailable()
+{
+	if (ll_try_gtk_init())
+	{
+		GtkClipboard * const clipboard =
+			gtk_clipboard_get(GDK_SELECTION_PRIMARY);
+		return gtk_clipboard_wait_is_text_available(clipboard) ?
+			TRUE : FALSE;
+	}
+	return FALSE; // failure
+}
+
+BOOL LLWindowSDL::pasteTextFromPrimary(LLWString &text)
+{
+	if (ll_try_gtk_init())
+	{
+		GtkClipboard * const clipboard =
+			gtk_clipboard_get(GDK_SELECTION_PRIMARY);
+		gchar * const data = gtk_clipboard_wait_for_text(clipboard);
+		if (data)
+		{
+			text = LLWString(utf8str_to_wstring(data));
+			g_free(data);
+			return TRUE;
+		}
+	}
+	return FALSE; // failure
+}
+
+BOOL LLWindowSDL::copyTextToPrimary(const LLWString &text)
+{
+	if (ll_try_gtk_init())
+	{
+		const std::string utf8 = wstring_to_utf8str(text);
+		GtkClipboard * const clipboard =
+			gtk_clipboard_get(GDK_SELECTION_PRIMARY);
+		gtk_clipboard_set_text(clipboard, utf8.c_str(), utf8.length());
+		return TRUE;
+	}
+	return FALSE; // failure
+}
+
 #else
 
 BOOL LLWindowSDL::isClipboardTextAvailable()
@@ -1288,6 +1337,22 @@ BOOL LLWindowSDL::copyTextToClipboard(const LLWString &s)
 {
 	return FALSE;  // unsupported
 }
+
+BOOL LLWindowSDL::isPrimaryTextAvailable()
+{
+	return FALSE; // unsupported
+}
+
+BOOL LLWindowSDL::pasteTextFromPrimary(LLWString &dst)
+{
+	return FALSE; // unsupported
+}
+
+BOOL LLWindowSDL::copyTextToPrimary(const LLWString &s)
+{
+	return FALSE;  // unsupported
+}
+
 #endif // LL_GTK
 
 LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_resolutions)
@@ -1962,14 +2027,14 @@ void LLWindowSDL::captureMouse()
 	// window, and in a less obnoxious way than SDL_WM_GrabInput
 	// which would confine the cursor to the window too.
 
-	//llinfos << "LLWindowSDL::captureMouse" << llendl;
+	lldebugs << "LLWindowSDL::captureMouse" << llendl;
 }
 
 void LLWindowSDL::releaseMouse()
 {
 	// see LWindowSDL::captureMouse()
 	
-	//llinfos << "LLWindowSDL::releaseMouse" << llendl;
+	lldebugs << "LLWindowSDL::releaseMouse" << llendl;
 }
 
 void LLWindowSDL::hideCursor()
diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h
index cebb151764ecb5c7fb21901f61089c70fc45f956..632d8fc1fad41adff91cd3eea860a6afe6b2251b 100644
--- a/indra/llwindow/llwindowsdl.h
+++ b/indra/llwindow/llwindowsdl.h
@@ -80,9 +80,15 @@ public:
 	/*virtual*/ void captureMouse();
 	/*virtual*/ void releaseMouse();
 	/*virtual*/ void setMouseClipping( BOOL b );
+
 	/*virtual*/ BOOL isClipboardTextAvailable();
 	/*virtual*/ BOOL pasteTextFromClipboard(LLWString &dst);
 	/*virtual*/ BOOL copyTextToClipboard(const LLWString & src);
+
+	/*virtual*/ BOOL isPrimaryTextAvailable();
+	/*virtual*/ BOOL pasteTextFromPrimary(LLWString &dst);
+	/*virtual*/ BOOL copyTextToPrimary(const LLWString & src);
+ 
 	/*virtual*/ void flashIcon(F32 seconds);
 	/*virtual*/ F32 getGamma();
 	/*virtual*/ BOOL setGamma(const F32 gamma); // Set the gamma
diff --git a/indra/lscript/lscript_compile/lscript_bytecode.cpp b/indra/lscript/lscript_compile/lscript_bytecode.cpp
index 9cd7d4831993b37c12af720d5a675a95f628cb82..0e46064829e572d76139c892775c1d995d7f79e4 100644
--- a/indra/lscript/lscript_compile/lscript_bytecode.cpp
+++ b/indra/lscript/lscript_compile/lscript_bytecode.cpp
@@ -312,7 +312,7 @@ void LLScriptScriptCodeChunk::build(LLFILE *efp, LLFILE *bcfp)
 		set_register(mCompleteCode, LREG_TM, mTotalSize);
 
 
-		if (fwrite(mCompleteCode, 1, mTotalSize, bcfp) != mTotalSize)
+		if (fwrite(mCompleteCode, 1, mTotalSize, bcfp) != (size_t)mTotalSize)
 		{
 			llwarns << "Short write" << llendl;
 		}
diff --git a/indra/lscript/lscript_execute/lscript_execute.cpp b/indra/lscript/lscript_execute/lscript_execute.cpp
index b2b54cdd7a7fa6fe8107cc12be16d1f2ae9a60ba..05fee9a4194235f71d1b4ab1b92258a323f868f0 100644
--- a/indra/lscript/lscript_execute/lscript_execute.cpp
+++ b/indra/lscript/lscript_execute/lscript_execute.cpp
@@ -77,7 +77,7 @@ const U64 LSL_HTTP_REQUEST_TIMEOUT = 25 * USEC_PER_SEC;
 LLScriptExecuteLSL2::LLScriptExecuteLSL2(LLFILE *fp)
 {
 	U8  sizearray[4];
-	S32 filesize;
+	size_t filesize;
 	S32 pos = 0;
 	if (fread(&sizearray, 1, 4, fp) != 4)
 	{
diff --git a/indra/lscript/lscript_execute/lscript_readlso.cpp b/indra/lscript/lscript_execute/lscript_readlso.cpp
index 3b10cc67c1aa6ababa2c380c8cd1a7aa9ff2431a..faf4fba0e0519bf46f5136cbc6fc06d51fe6f5ea 100644
--- a/indra/lscript/lscript_execute/lscript_readlso.cpp
+++ b/indra/lscript/lscript_execute/lscript_readlso.cpp
@@ -39,7 +39,7 @@
 LLScriptLSOParse::LLScriptLSOParse(LLFILE *fp)
 {
 	U8  sizearray[4];
-	S32 filesize;
+	size_t filesize;
 	S32 pos = 0;
 	if (fread(&sizearray, 1, 4, fp) != 4)
 	{
diff --git a/indra/mac_updater/mac_updater.cpp b/indra/mac_updater/mac_updater.cpp
index 3a130db2af479f92c23321195f57884fbbb87976..d2a46d4338dc7dac6d12b3005ccd789fbeb5cc13 100644
--- a/indra/mac_updater/mac_updater.cpp
+++ b/indra/mac_updater/mac_updater.cpp
@@ -68,8 +68,8 @@ EventHandlerRef gEventHandler = NULL;
 OSStatus gFailure = noErr;
 Boolean gCancelled = false;
 
-char *gUpdateURL;
-char *gProductName;
+const char *gUpdateURL;
+const char *gProductName;
 
 void *updatethreadproc(void*);
 
@@ -1032,7 +1032,7 @@ void *updatethreadproc(void*)
 		if(!mountOutput.empty())
 		{
 			const char *s = mountOutput.c_str();
-			char *prefix = "/dev/";
+			const char *prefix = "/dev/";
 			char *sub = strstr(s, prefix);
 			
 			if(sub != NULL)
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index c3d92953ce8db4f0c3ed577ad786340b45c9c529..fa7d226f164caad4cd03147bb3138788a0fdb2ef 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -279,7 +279,6 @@ set(viewer_SOURCE_FILES
     llpanelgrouplandmoney.cpp
     llpanelgroupnotices.cpp
     llpanelgrouproles.cpp
-    llpanelgroupvoting.cpp
     llpanelinput.cpp
     llpanelinventory.cpp
     llpanelland.cpp
@@ -683,7 +682,6 @@ set(viewer_HEADER_FILES
     llpanelgrouplandmoney.h
     llpanelgroupnotices.h
     llpanelgrouproles.h
-    llpanelgroupvoting.h
     llpanelinput.h
     llpanelinventory.h
     llpanelland.h
diff --git a/indra/newview/app_settings/settings_per_account.xml b/indra/newview/app_settings/settings_per_account.xml
index 90c7b116379f8d5bed8ad5ada3f777aeb0e357e9..dab88a5ec3441444d5c9d9edcd3964fd43af3553 100644
--- a/indra/newview/app_settings/settings_per_account.xml
+++ b/indra/newview/app_settings/settings_per_account.xml
@@ -11,6 +11,17 @@
         <key>Value</key>
             <string>The Resident you messaged is in &apos;busy mode&apos; which means they have requested not to be disturbed.  Your message will still be shown in their IM panel for later viewing.</string>
         </map>
+    <key>BusyModeResponse2</key>
+        <map>
+        <key>Comment</key>
+            <string>Auto response to instant messages while in busy mode, clean (unencoded) version of BusyModeResponse</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>String</string>
+        <key>Value</key>
+            <string>|TOKEN COPY BusyModeResponse|</string>
+        </map>
     <key>IMLogTimestamp</key>
         <map>
         <key>Comment</key>
diff --git a/indra/newview/linux_tools/client-readme-joystick.txt b/indra/newview/linux_tools/client-readme-joystick.txt
index 997a8b08eb0de12414dd7b032d78df80ec8810a6..4f89a73ccbe7a11c92f788b43835ea8c8edd5a1b 100644
--- a/indra/newview/linux_tools/client-readme-joystick.txt
+++ b/indra/newview/linux_tools/client-readme-joystick.txt
@@ -41,7 +41,7 @@ applications such as the Second Life Viewer, as follows:
 * Ubuntu or Gentoo Linux Configuration:
   For a quick start, you can simply paste the following line into a terminal
   before plugging in your SpaceNavigator - this only needs to be done once:
-  sudo bash -c 'echo KERNEL==\"event[0-9]*\", SYSFS{idVendor}==\"046d\", SYSFS{idProduct}==\"c626\", SYMLINK+=\"input/spacenavigator\", GROUP=\"plugdev\", MODE=\"664\" >> /etc/udev/rules.d/91-spacenavigator.rules'
+  sudo bash -c 'echo KERNEL==\"event[0-9]*\", SYSFS{idVendor}==\"046d\", SYSFS{idProduct}==\"c626\", SYMLINK+=\"input/spacenavigator\", GROUP=\"plugdev\", MODE=\"664\" > /etc/udev/rules.d/91-spacenavigator-LL.rules ; echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><deviceinfo version=\"0.2\"><device><match key=\"info.product\" contains=\"3Dconnexion SpaceNavigator\"><merge key=\"input.x11_driver\" type=\"string\"></merge></match></device></deviceinfo>" > /etc/hal/fdi/policy/3Dconnexion_SpaceNavigator_LL.fdi'
 
 For more comprehensive Linux SpaceNavigator configuration information please
 see the section 'Installing SpaceNavigator without the official driver' here:
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index a894bca619a5c64cdfa3398230231678f9baac16..3b534ce5a74030ab21b11ae26f56388a2a71b487 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -76,6 +76,7 @@
 #include "llfloaterdirectory.h"
 #include "llfloatergroupinfo.h"
 #include "llfloatergroups.h"
+#include "llfloaterland.h"
 #include "llfloatermap.h"
 #include "llfloatermute.h"
 #include "llfloatersnapshot.h"
@@ -3835,7 +3836,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 		if(constrain)
 		{
 			F32 max_dist = ( CAMERA_MODE_CUSTOMIZE_AVATAR == mCameraMode ) ?
-				APPEARANCE_MAX_ZOOM : MAX_CAMERA_DISTANCE_FROM_AGENT;
+				APPEARANCE_MAX_ZOOM : mDrawDistance;
 
 			LLVector3d camera_offset = camera_position_global
 				- gAgent.getPositionGlobal();
@@ -5950,6 +5951,9 @@ bool LLAgent::teleportCore(bool is_local)
 	LLFloaterWorldMap::hide(NULL);
 	LLFloaterDirectory::hide(NULL);
 
+	// hide land floater too - it'll be out of date
+	LLFloaterLand::hideInstance();
+	
 	LLViewerParcelMgr::getInstance()->deselectLand();
 
 	// Close all pie menus, deselect land, etc.
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 1e6d8fdf25886c5a2baf0f3b0c9e6840c959025e..43800c67fac4cf729583d8e0fa05e42db5a1809f 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -202,7 +202,6 @@ const F32 DEFAULT_AFK_TIMEOUT = 5.f * 60.f; // time with no input before user fl
 F32 gSimLastTime; // Used in LLAppViewer::init and send_stats()
 F32 gSimFrames;
 
-BOOL gAllowIdleAFK = TRUE;
 BOOL gAllowTapTapHoldRun = TRUE;
 BOOL gShowObjectUpdates = FALSE;
 BOOL gUseQuickTime = TRUE;
@@ -301,7 +300,7 @@ LLAppViewer::LLUpdaterInfo *LLAppViewer::sUpdaterInfo = NULL ;
 void idle_afk_check()
 {
 	// check idle timers
-	if (gAllowIdleAFK && (gAwayTriggerTimer.getElapsedTimeF32() > gSavedSettings.getF32("AFKTimeout")))
+	if (gSavedSettings.getBOOL("AllowIdleAFK") && (gAwayTriggerTimer.getElapsedTimeF32() > gSavedSettings.getF32("AFKTimeout")))
 	{
 		gAgent.setAFK();
 	}
@@ -394,7 +393,6 @@ static void settings_to_globals()
 	gAgent.mHideGroupTitle		= gSavedSettings.getBOOL("RenderHideGroupTitle");
 
 	gDebugWindowProc = gSavedSettings.getBOOL("DebugWindowProc");
-	gAllowIdleAFK = gSavedSettings.getBOOL("AllowIdleAFK");
 	gAllowTapTapHoldRun = gSavedSettings.getBOOL("AllowTapTapHoldRun");
 	gShowObjectUpdates = gSavedSettings.getBOOL("ShowObjectUpdates");
 	gMapScale = gSavedSettings.getF32("MapScale");
@@ -507,6 +505,7 @@ LLTextureFetch* LLAppViewer::sTextureFetch = NULL;
 
 LLAppViewer::LLAppViewer() : 
 	mMarkerFile(),
+	mLogoutMarkerFile(NULL),
 	mReportedCrash(false),
 	mNumSessions(0),
 	mPurgeCache(false),
@@ -2158,7 +2157,6 @@ void LLAppViewer::cleanupSavedSettings()
 
 	gSavedSettings.setBOOL("DebugWindowProc", gDebugWindowProc);
 		
-	gSavedSettings.setBOOL("AllowIdleAFK", gAllowIdleAFK);
 	gSavedSettings.setBOOL("AllowTapTapHoldRun", gAllowTapTapHoldRun);
 	gSavedSettings.setBOOL("ShowObjectUpdates", gShowObjectUpdates);
 	
@@ -3497,7 +3495,7 @@ void LLAppViewer::idleShutdown()
 		S32 finished_uploads = total_uploads - pending_uploads;
 		F32 percent = 100.f * finished_uploads / total_uploads;
 		gViewerWindow->setProgressPercent(percent);
-		gViewerWindow->setProgressString("Saving final data...");
+		gViewerWindow->setProgressString("Saving your settings...");
 		return;
 	}
 
@@ -3669,7 +3667,7 @@ void LLAppViewer::idleNetwork()
 	// Check that the circuit between the viewer and the agent's current
 	// region is still alive
 	LLViewerRegion *agent_region = gAgent.getRegion();
-	if (agent_region)
+	if (agent_region && (LLStartUp::getStartupState()==STATE_STARTED))
 	{
 		LLUUID this_region_id = agent_region->getRegionID();
 		bool this_region_alive = agent_region->isAlive();
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index 6d7c3c857717ec72c7db0b0a5391cf043d1e3b96..fc88c76aaf62c504de05e63d85868d56a198e5f2 100644
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -251,7 +251,6 @@ const S32 AGENT_UPDATES_PER_SECOND  = 10;
 
 extern LLSD gDebugInfo;
 
-extern BOOL	gAllowIdleAFK;
 extern BOOL	gAllowTapTapHoldRun;
 extern BOOL	gShowObjectUpdates;
 
diff --git a/indra/newview/llappviewerlinux.cpp b/indra/newview/llappviewerlinux.cpp
index 8b81478eafb6fedeeec9157343a116cf9ead860f..d02e86a5573961358ea71a9380e64e9ff5a02132 100644
--- a/indra/newview/llappviewerlinux.cpp
+++ b/indra/newview/llappviewerlinux.cpp
@@ -165,14 +165,14 @@ static inline BOOL do_basic_glibc_backtrace()
 // amazing backtrace.
 static inline BOOL do_basic_glibc_backtrace()
 {
-	void *array[MAX_STACK_TRACE_DEPTH];
+	void *stackarray[MAX_STACK_TRACE_DEPTH];
 	size_t size;
 	char **strings;
 	size_t i;
 	BOOL success = FALSE;
 
-	size = backtrace(array, MAX_STACK_TRACE_DEPTH);
-	strings = backtrace_symbols(array, size);
+	size = backtrace(stackarray, MAX_STACK_TRACE_DEPTH);
+	strings = backtrace_symbols(stackarray, size);
 
 	std::string strace_filename = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"stack_trace.log");
 	llinfos << "Opening stack trace file " << strace_filename << llendl;
@@ -186,8 +186,13 @@ static inline BOOL do_basic_glibc_backtrace()
 	if (size)
 	{
 		for (i = 0; i < size; i++)
-			fputs((std::string(strings[i])+"\n").c_str(),
-			      StraceFile);
+		{
+			// the format of the StraceFile is very specific, to allow (kludgy) machine-parsing
+			fprintf(StraceFile, "%-3d ", i);
+			fprintf(StraceFile, "%-32s\t", "unknown");
+			fprintf(StraceFile, "%p ", stackarray[i]);
+			fprintf(StraceFile, "%s\n", strings[i]);
+		}
 
 		success = TRUE;
 	}
@@ -205,7 +210,7 @@ static inline BOOL do_basic_glibc_backtrace()
 // extraction without exporting symbols (which'd cause subtle, fatal bugs).
 static inline BOOL do_elfio_glibc_backtrace()
 {
-	void *array[MAX_STACK_TRACE_DEPTH];
+	void *stackarray[MAX_STACK_TRACE_DEPTH];
 	size_t btsize;
 	char **strings;
 	BOOL success = FALSE;
@@ -222,8 +227,8 @@ static inline BOOL do_elfio_glibc_backtrace()
 	}
 
 	// get backtrace address list and basic symbol info
-	btsize = backtrace(array, MAX_STACK_TRACE_DEPTH);
-	strings = backtrace_symbols(array, btsize);
+	btsize = backtrace(stackarray, MAX_STACK_TRACE_DEPTH);
+	strings = backtrace_symbols(stackarray, btsize);
 
 	// create ELF reader for our app binary
 	IELFI* pReader;
@@ -257,7 +262,8 @@ static inline BOOL do_elfio_glibc_backtrace()
 	size_t btpos;
 	for (btpos = 0; btpos < btsize; ++btpos)
 	{
-		fprintf(StraceFile, "%d:\t", btpos);
+		// the format of the StraceFile is very specific, to allow (kludgy) machine-parsing
+		fprintf(StraceFile, "%-3d ", btpos);
 		int symidx;
 		for (symidx = 0; symidx < nSymNo; ++symidx)
 		{
@@ -266,9 +272,13 @@ static inline BOOL do_elfio_glibc_backtrace()
 					       bind, type, section))
 			{
 				// check if trace address within symbol range
-				if (uintptr_t(array[btpos]) >= value &&
-				    uintptr_t(array[btpos]) < value+ssize)
+				if (uintptr_t(stackarray[btpos]) >= value &&
+				    uintptr_t(stackarray[btpos]) < value+ssize)
 				{
+					// symbol is inside viewer
+					fprintf(StraceFile, "%-32s\t", "com.secondlife.indra.viewer");
+					fprintf(StraceFile, "%p ", stackarray[btpos]);
+
 					char *demangled_str = NULL;
 					int demangle_result = 1;
 					demangled_str =
@@ -278,20 +288,19 @@ static inline BOOL do_elfio_glibc_backtrace()
 					if (0 == demangle_result &&
 					    NULL != demangled_str) {
 						fprintf(StraceFile,
-							"ELF(%s", demangled_str);
+							"%s", demangled_str);
 						free(demangled_str);
 					}
 					else // failed demangle; print it raw
 					{
 						fprintf(StraceFile,
-							"ELF(%s", name.c_str());
+							"%s", name.c_str());
 					}
 					// print offset from symbol start
 					fprintf(StraceFile,
-						"+0x%lx) [%p]\n",
-						uintptr_t(array[btpos]) -
-						value,
-						array[btpos]);
+						" + %lu\n",
+						uintptr_t(stackarray[btpos]) -
+						value);
 					goto got_sym; // early escape
 				}
 			}
@@ -299,6 +308,8 @@ static inline BOOL do_elfio_glibc_backtrace()
 		// Fallback:
 		// Didn't find a suitable symbol in the binary - it's probably
 		// a symbol in a DSO; use glibc's idea of what it should be.
+		fprintf(StraceFile, "%-32s\t", "unknown");
+		fprintf(StraceFile, "%p ", stackarray[btpos]);
 		fprintf(StraceFile, "%s\n", strings[btpos]);
 	got_sym:;
 	}
diff --git a/indra/newview/llappviewermacosx.cpp b/indra/newview/llappviewermacosx.cpp
index 3cdcb35197947208fc310440a745b4c1edf87db0..1c32f0c564dc62ab94fbbe0e06fe512d073022b5 100644
--- a/indra/newview/llappviewermacosx.cpp
+++ b/indra/newview/llappviewermacosx.cpp
@@ -1,6 +1,6 @@
 /**
  * @file llappviewermacosx.cpp
- * @brief The LLAppViewerWin32 class definitions
+ * @brief The LLAppViewerMacOSX class definitions
  *
  * $LicenseInfo:firstyear=2007&license=viewergpl$
  * 
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 47e4a2278f4fdc0b4fdf640eba4764c884c8c662..9f4afc9f173d2f272ac26e9cfbd068a06c594810 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -1015,6 +1015,10 @@ LLSpatialBridge::LLSpatialBridge(LLDrawable* root, U32 data_mask)
 	mPartitionType = LLViewerRegion::PARTITION_VOLUME;
 	
 	mOctree->balance();
+
+	llassert(mDrawable);
+	llassert(mDrawable->getRegion());
+	llassert(mDrawable->getRegion()->getSpatialPartition(mPartitionType));
 	
 	mDrawable->getRegion()->getSpatialPartition(mPartitionType)->put(this);
 }
@@ -1315,6 +1319,10 @@ void LLSpatialBridge::move(LLDrawable *drawablep, LLSpatialGroup *curp, BOOL imm
 
 BOOL LLSpatialBridge::updateMove()
 {
+	llassert(mDrawable);
+	llassert(mDrawable->getRegion());
+	llassert(mDrawable->getRegion()->getSpatialPartition(mPartitionType));
+
 	mOctree->balance();
 	mDrawable->getRegion()->getSpatialPartition(mPartitionType)->move(this, getSpatialGroup(), TRUE);
 	return TRUE;
diff --git a/indra/newview/llfilepicker.h b/indra/newview/llfilepicker.h
index 104e0df2937bc4c506c1d749181176cc020a178d..ab2455620fee2ab9f0a40add1695eb65425bb281 100644
--- a/indra/newview/llfilepicker.h
+++ b/indra/newview/llfilepicker.h
@@ -59,6 +59,7 @@
 #include <commdlg.h>
 #endif
 
+extern "C" {
 // mostly for Linux, possible on others
 #if LL_GTK
 # include "gtk/gtk.h"
@@ -68,6 +69,7 @@
 #if LL_X11
 #include "SDL/SDL_syswm.h"
 #endif
+}
 
 class LLFilePicker
 {
diff --git a/indra/newview/llfloaterchatterbox.h b/indra/newview/llfloaterchatterbox.h
index 33aac8257e1aea14a576f1a86eaf4237e34a3bad..3adbd14370d9afb2e014143afe09a25accb02fe2 100644
--- a/indra/newview/llfloaterchatterbox.h
+++ b/indra/newview/llfloaterchatterbox.h
@@ -148,7 +148,14 @@ public:
 	{
 		if (visible(instance, key))
 		{
-			LLFloaterChatterBox::hideInstance();
+			if(instance->getHost())
+			{
+				LLFloaterChatterBox::hideInstance();
+			}
+			else
+			{
+				VisibilityPolicy<LLFloater>::hide(instance, key);
+			}
 		}
 	}
 
diff --git a/indra/newview/llfloatergesture.cpp b/indra/newview/llfloatergesture.cpp
index 658aa16429f215b5b70f93d0c40544f7a7394f25..6d39d756630e3e35298ac324a7e1bac48f66bc34 100644
--- a/indra/newview/llfloatergesture.cpp
+++ b/indra/newview/llfloatergesture.cpp
@@ -200,12 +200,7 @@ void LLFloaterGesture::refreshAll()
 		}
 		else
 		{
-			if (list->setCurrentByID(sInstance->mSelectedID))
-			{
-				LLCtrlScrollInterface *scroll = sInstance->childGetScrollInterface("gesture_list");
-				if (scroll) scroll->scrollToShowSelected();
-			}
-			else
+			if (! list->setCurrentByID(sInstance->mSelectedID))
 			{
 				list->selectFirstItem();
 			}
@@ -219,8 +214,14 @@ void LLFloaterGesture::refreshAll()
 void LLFloaterGesture::buildGestureList()
 {
 	LLCtrlListInterface *list = childGetListInterface("gesture_list");
-	if (!list) return;
+	LLCtrlScrollInterface *scroll = childGetScrollInterface("gesture_list");
 
+	if (! (list && scroll)) return;
+
+	// attempt to preserve scroll position through re-builds
+	// since we do re-build any time anything dirties
+	S32 current_scroll_pos = scroll->getScrollPos();
+	
 	list->operateOnAll(LLCtrlListInterface::OP_DELETE);
 
 	LLGestureManager::item_map_t::iterator it;
@@ -319,6 +320,8 @@ void LLFloaterGesture::buildGestureList()
 		}
 		list->addElement(element, ADD_BOTTOM);
 	}
+	
+	scroll->setScrollPos(current_scroll_pos);
 }
 
 // static
diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp
index 689f9f48d0bdb596d4faffe8ab0b9feefa23b978..3606f7ccbe8705c63a0df0bed4edef8fcbb957ed 100644
--- a/indra/newview/llfloaterimagepreview.cpp
+++ b/indra/newview/llfloaterimagepreview.cpp
@@ -72,11 +72,14 @@ const S32 PREVIEW_TEXTURE_HEIGHT = 300;
 // LLFloaterImagePreview()
 //-----------------------------------------------------------------------------
 LLFloaterImagePreview::LLFloaterImagePreview(const std::string& filename) : 
-	LLFloaterNameDesc(filename)
+	LLFloaterNameDesc(filename),
+
+	mAvatarPreview(NULL),
+	mSculptedPreview(NULL),
+	mLastMouseX(0),
+	mLastMouseY(0),
+	mImagep(NULL)
 {
-	mLastMouseX = 0;
-	mLastMouseY = 0;
-	mImagep = NULL ;
 	loadImage(mFilenameAndPath);
 }
 
@@ -815,7 +818,7 @@ void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance)
 	mVertexBuffer->getIndexStrider(index_strider);
 
 	// build vertices and normals
-	for (U32 i = 0; (S32)i < num_vertices; i++)
+	for (U32 i = 0; i < num_vertices; i++)
 	{
 		*(vertex_strider++) = vf.mVertices[i].mPosition;
 		LLVector3 normal = vf.mVertices[i].mNormal;
diff --git a/indra/newview/llfloateropenobject.cpp b/indra/newview/llfloateropenobject.cpp
index fc483dd307612504096f5fe92f38d070f35b3e60..f4984df6d9078e958cc58b97c182f3a276f3bdd5 100644
--- a/indra/newview/llfloateropenobject.cpp
+++ b/indra/newview/llfloateropenobject.cpp
@@ -80,12 +80,26 @@ void LLFloaterOpenObject::refresh()
 {
 	mPanelInventory->refresh();
 
+	std::string name;
+	BOOL enabled;
+
 	LLSelectNode* node = mObjectSelection->getFirstRootNode();
 	if (node)
 	{
-		std::string name = node->mName;
-		childSetTextArg("object_name", "[DESC]", name);
+		name = node->mName;
+		enabled = TRUE;
+	}
+	else
+	{
+		name = "";
+		enabled = FALSE;
 	}
+
+	childSetTextArg("object_name", "[DESC]", name);
+	
+	childSetEnabled("copy_to_inventory_button", enabled);
+	childSetEnabled("copy_and_wear_button", enabled);
+
 }
 
 void LLFloaterOpenObject::draw()
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index 588df7b43b724d637c8dc62fb10ef114ae8db51e..2b418b4caa2dc03107e9c900ce06acd41a8c1dbb 100644
--- a/indra/newview/llfloaterregioninfo.cpp
+++ b/indra/newview/llfloaterregioninfo.cpp
@@ -2862,20 +2862,14 @@ void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs,
 
 			S32 file_length = file.getSize();
 
-			char* buffer = new char[file_length+1];
-			if (buffer == NULL)
-			{
-				llerrs << "Memory Allocation Failed" << llendl;
-				return;
-			}
-
-			file.read((U8*)buffer, file_length);		/* Flawfinder: ignore */
+			std::vector<char> buffer(file_length+1);
+			file.read((U8*)&buffer[0], file_length);
 			// put a EOS at the end
 			buffer[file_length] = 0;
 
-			if( (file_length > 19) && !strncmp( buffer, "Linden text version", 19 ) )
+			if( (file_length > 19) && !strncmp( &buffer[0], "Linden text version", 19 ) )
 			{
-				if( !panelp->mEditor->importBuffer( buffer, file_length+1 ) )
+				if( !panelp->mEditor->importBuffer( &buffer[0], file_length+1 ) )
 				{
 					llwarns << "Problem importing estate covenant." << llendl;
 					LLNotifications::instance().add("ProblemImportingEstateCovenant");
@@ -2890,7 +2884,6 @@ void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs,
 				// Version 0 (just text, doesn't include version number)
 				panelp->sendChangeCovenantID(asset_uuid);
 			}
-			delete[] buffer;
 		}
 		else
 		{
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp
index e3b95e40587c0930f8a65f342e60a59c2a41c455..d45d9c052f448b8f13f5421a4610488eac034459 100644
--- a/indra/newview/llfloatersnapshot.cpp
+++ b/indra/newview/llfloatersnapshot.cpp
@@ -1275,7 +1275,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
 
 	LLSnapshotLivePreview* previewp = getPreviewView(floater);
 	BOOL got_bytes = previewp && previewp->getDataSize() > 0;
-	BOOL got_snap = previewp->getSnapshotUpToDate();
+	BOOL got_snap = previewp && previewp->getSnapshotUpToDate();
 
 	floater->childSetEnabled("send_btn",   shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD && got_snap && previewp->getDataSize() <= MAX_POSTCARD_DATASIZE);
 	floater->childSetEnabled("upload_btn", shot_type == LLSnapshotLivePreview::SNAPSHOT_TEXTURE  && got_snap);
@@ -1283,7 +1283,10 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
 
 	LLLocale locale(LLLocale::USER_LOCALE);
 	std::string bytes_string;
-	LLResMgr::getInstance()->getIntegerString(bytes_string, (previewp->getDataSize()) >> 10 );
+	if (got_snap)
+	{
+		LLResMgr::getInstance()->getIntegerString(bytes_string, (previewp->getDataSize()) >> 10 );
+	}
 	S32 upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
 	floater->childSetLabelArg("texture", "[AMOUNT]", llformat("%d",upload_cost));
 	floater->childSetLabelArg("upload_btn", "[AMOUNT]", llformat("%d",upload_cost));
diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp
index e2e71f51fa5f823f55890b40e14eeae1c04fab12..8326557cf808cb182c77ba24d783d9cf8e411302 100644
--- a/indra/newview/llfloaterworldmap.cpp
+++ b/indra/newview/llfloaterworldmap.cpp
@@ -1610,7 +1610,7 @@ void LLFloaterWorldMap::updateSims(bool found_null_sim)
 		childSetFocus("search_results");
 		onCommitSearchResult(NULL, this);
 	}
-	else
+	else if (num_results == 0)
 	{
 		list->addCommentText(std::string("None found."));
 		list->operateOnAll(LLCtrlListInterface::OP_DESELECT);
diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp
index 1402d241c7410885bce976990d703fb62eb08ed3..97a3bd7c50eba29950e33f09dce60a53318081f2 100644
--- a/indra/newview/llfolderview.cpp
+++ b/indra/newview/llfolderview.cpp
@@ -146,9 +146,9 @@ void LLFolderViewItem::cleanupClass()
 // Default constructor
 // NOTE: Optimize this, we call it a *lot* when opening a large inventory
 LLFolderViewItem::LLFolderViewItem( const std::string& name, LLUIImagePtr icon,
-								   S32 creation_date,
-								   LLFolderView* root,
-									LLFolderViewEventListener* listener ) :
+				    time_t creation_date,
+				    LLFolderView* root,
+				    LLFolderViewEventListener* listener ) :
 	LLUICtrl( name, LLRect(0, 0, 0, 0), TRUE, NULL, NULL, FOLLOWS_LEFT|FOLLOWS_TOP|FOLLOWS_RIGHT),
 	mLabel( name ),
 	mLabelWidth(0),
@@ -4684,7 +4684,7 @@ void LLInventoryFilter::setDateRangeLastLogoff(BOOL sl)
 
 BOOL LLInventoryFilter::isSinceLogoff()
 {
-	return (mFilterOps.mMinDate == mLastLogoff) &&
+	return (mFilterOps.mMinDate == (time_t)mLastLogoff) &&
 		(mFilterOps.mMaxDate == time_max());
 }
 
diff --git a/indra/newview/llfolderview.h b/indra/newview/llfolderview.h
index 44b076e3979b5ce5e1e40db6a144f277ee8d4d2b..3fe3095c58e8fe057c57236f334641af2a1f58c4 100644
--- a/indra/newview/llfolderview.h
+++ b/indra/newview/llfolderview.h
@@ -335,7 +335,7 @@ protected:
 	std::string					mSearchableLabel;
 	std::string					mType;
 	S32							mLabelWidth;
-	U32							mCreationDate;
+	time_t							mCreationDate;
 	LLFolderViewFolder*			mParentFolder;
 	LLFolderViewEventListener*	mListener;
 	BOOL						mIsSelected;
@@ -386,7 +386,7 @@ public:
 	void filterFromRoot( void );
 
 	// creation_date is in UTC seconds
-	LLFolderViewItem( const std::string& name, LLUIImagePtr icon, S32 creation_date, LLFolderView* root, LLFolderViewEventListener* listener );
+	LLFolderViewItem( const std::string& name, LLUIImagePtr icon, time_t creation_date, LLFolderView* root, LLFolderViewEventListener* listener );
 	virtual ~LLFolderViewItem( void );
 
 	// addToFolder() returns TRUE if it succeeds. FALSE otherwise
diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp
index 2135ea5315ad98c5c31461609fd9b32217504ff7..2dbff92ba04546274909e25498a3b59d8199e660 100644
--- a/indra/newview/llgesturemgr.cpp
+++ b/indra/newview/llgesturemgr.cpp
@@ -926,20 +926,15 @@ void LLGestureManager::onLoadComplete(LLVFS *vfs,
 		LLVFile file(vfs, asset_uuid, type, LLVFile::READ);
 		S32 size = file.getSize();
 
-		char* buffer = new char[size+1];
-		if (buffer == NULL)
-		{
-			llerrs << "Memory Allocation Failed" << llendl;
-			return;
-		}
+		std::vector<char> buffer(size+1);
 
-		file.read((U8*)buffer, size);		/* Flawfinder: ignore */
+		file.read((U8*)&buffer[0], size);
 		// ensure there's a trailing NULL so strlen will work.
 		buffer[size] = '\0';
 
 		LLMultiGesture* gesture = new LLMultiGesture();
 
-		LLDataPackerAsciiBuffer dp(buffer, size+1);
+		LLDataPackerAsciiBuffer dp(&buffer[0], size+1);
 		BOOL ok = gesture->deserialize(dp);
 
 		if (ok)
@@ -991,9 +986,6 @@ void LLGestureManager::onLoadComplete(LLVFS *vfs,
 			delete gesture;
 			gesture = NULL;
 		}
-
-		delete [] buffer;
-		buffer = NULL;
 	}
 	else
 	{
diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp
index 77ee29a449b61536521741c4cb54621e642c2bc1..003a02c3cd79df8e9af858233b422c4234711210 100644
--- a/indra/newview/llgroupmgr.cpp
+++ b/indra/newview/llgroupmgr.cpp
@@ -803,7 +803,12 @@ static void formatDateString(std::string &date_string)
 	const regex expression("([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})");
 	if (regex_match(date_string.c_str(), result, expression))
 	{
-		date_string = result[3]+"/"+result[1]+"/"+result[2];
+		std::string year = result[3];
+		std::string month = result[1];
+		std::string day = result[2];
+
+		// ISO 8601 date format
+		date_string = llformat("%04s-%02s-%02s", year.c_str(), month.c_str(), day.c_str());
 	}
 }
 
diff --git a/indra/newview/llhudeffectpointat.cpp b/indra/newview/llhudeffectpointat.cpp
index 88521df29c4672c341576e841d25990c9c21b5ef..a13ee8572f8e1f6fb574c0bcab26311079e79bdb 100644
--- a/indra/newview/llhudeffectpointat.cpp
+++ b/indra/newview/llhudeffectpointat.cpp
@@ -160,6 +160,7 @@ void LLHUDEffectPointAt::unpackData(LLMessageSystem *mesgsys, S32 blocknum)
 	LLHUDEffect::unpackData(mesgsys, blocknum);
 	LLUUID source_id;
 	LLUUID target_id;
+	U8 pointAtTypeUnpacked = 0;
 	S32 size = mesgsys->getSizeFast(_PREHASH_Effect, blocknum, _PREHASH_TypeData);
 	if (size != PKT_SIZE)
 	{
@@ -169,6 +170,9 @@ void LLHUDEffectPointAt::unpackData(LLMessageSystem *mesgsys, S32 blocknum)
 	mesgsys->getBinaryDataFast(_PREHASH_Effect, _PREHASH_TypeData, packed_data, PKT_SIZE, blocknum);
 	
 	htonmemcpy(source_id.mData, &(packed_data[SOURCE_AVATAR]), MVT_LLUUID, 16);
+	htonmemcpy(target_id.mData, &(packed_data[TARGET_OBJECT]), MVT_LLUUID, 16);
+	htonmemcpy(new_target.mdV, &(packed_data[TARGET_POS]), MVT_LLVector3d, 24);
+	htonmemcpy(&pointAtTypeUnpacked, &(packed_data[POINTAT_TYPE]), MVT_U8, 1);
 
 	LLViewerObject *objp = gObjectList.findObject(source_id);
 	if (objp && objp->isAvatar())
@@ -181,12 +185,8 @@ void LLHUDEffectPointAt::unpackData(LLMessageSystem *mesgsys, S32 blocknum)
 		return;
 	}
 
-	htonmemcpy(target_id.mData, &(packed_data[TARGET_OBJECT]), MVT_LLUUID, 16);
-
 	objp = gObjectList.findObject(target_id);
 
-	htonmemcpy(new_target.mdV, &(packed_data[TARGET_POS]), MVT_LLVector3d, 24);
-
 	if (objp)
 	{
 		setTargetObjectAndOffset(objp, new_target);
@@ -196,8 +196,6 @@ void LLHUDEffectPointAt::unpackData(LLMessageSystem *mesgsys, S32 blocknum)
 		setTargetPosGlobal(new_target);
 	}
 
-	U8 pointAtTypeUnpacked = 0;
-	htonmemcpy(&pointAtTypeUnpacked, &(packed_data[POINTAT_TYPE]), MVT_U8, 1);
 	mTargetType = (EPointAtType)pointAtTypeUnpacked;
 
 //	mKillTime = mTimer.getElapsedTimeF32() + mDuration;
diff --git a/indra/newview/llhudeffecttrail.cpp b/indra/newview/llhudeffecttrail.cpp
index 32b52f8628bbe4e01dc410282fcebd19a9c9731c..0ade6810ba0e3034057873bbddf8ccbecda95fa9 100644
--- a/indra/newview/llhudeffecttrail.cpp
+++ b/indra/newview/llhudeffecttrail.cpp
@@ -121,7 +121,7 @@ void LLHUDEffectSpiral::unpackData(LLMessageSystem *mesgsys, S32 blocknum)
 
 	LLHUDEffect::unpackData(mesgsys, blocknum);
 	LLUUID object_id, target_object_id;
-	S32 size = mesgsys->getSizeFast(_PREHASH_Effect, blocknum, _PREHASH_TypeData);
+	size_t size = mesgsys->getSizeFast(_PREHASH_Effect, blocknum, _PREHASH_TypeData);
 	if (size != EFFECT_SIZE)
 	{
 		llwarns << "Spiral effect with bad size " << size << llendl;
diff --git a/indra/newview/llimpanel.cpp b/indra/newview/llimpanel.cpp
index fcebfa70533141e14dcde8ae8658fd09e32aa099..66c2e4fe21353e2ad88ff3ce4dd629cacbfd8e14 100644
--- a/indra/newview/llimpanel.cpp
+++ b/indra/newview/llimpanel.cpp
@@ -2030,8 +2030,8 @@ void LLFloaterIMPanel::sendMsg()
 
 		LLViewerStats::getInstance()->incStat(LLViewerStats::ST_IM_COUNT);
 
+		mInputEditor->setText(LLStringUtil::null);
 	}
-	mInputEditor->setText(LLStringUtil::null);
 
 	// Don't need to actually send the typing stop message, the other
 	// client will infer it from receiving the message.
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 69a403e3883f19b1384d053d6a20070da7e54923..2697ef25f9493fa2a92b89853368946f019b9e50 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -1012,6 +1012,19 @@ BOOL LLItemBridge::isItemCopyable() const
 	LLViewerInventoryItem* item = getItem();
 	if (item)
 	{
+		// can't copy worn objects. DEV-15183
+		LLVOAvatar *avatarp = gAgent.getAvatarObject();
+		if( !avatarp )
+		{
+			return FALSE;
+		}
+
+		if( avatarp->isWearingAttachment( mUUID ) )
+		{
+			return FALSE;
+		}
+			
+
 		return (item->getPermissions().allowCopyBy(gAgent.getID()));
 	}
 	return FALSE;
@@ -4624,7 +4637,7 @@ void LLWearableBridge::onRemoveFromAvatarArrived(LLWearable* wearable,
 		{
 			EWearableType type = wearable->getType();
 	
-			if( !(type==WT_SHAPE || type==WT_SKIN || type==WT_HAIR ) ) //&&
+			if( !(type==WT_SHAPE || type==WT_SKIN || type==WT_HAIR || type==WT_EYES ) ) //&&
 				//!((!gAgent.isTeen()) && ( type==WT_UNDERPANTS || type==WT_UNDERSHIRT )) )
 			{
 				gAgent.removeWearable( type );
diff --git a/indra/newview/lllandmarklist.cpp b/indra/newview/lllandmarklist.cpp
index e8cdcdfdd6fa744f8980aed9f4487a13a7ff109a..2f43b41042b3625c61c14e27600d6b364343279a 100644
--- a/indra/newview/lllandmarklist.cpp
+++ b/indra/newview/lllandmarklist.cpp
@@ -89,11 +89,11 @@ void LLLandmarkList::processGetAssetReply(
 		LLVFile file(vfs, uuid, type);
 		S32 file_length = file.getSize();
 
-		char* buffer = new char[ file_length + 1 ];
-		file.read( (U8*)buffer, file_length);		/*Flawfinder: ignore*/
+		std::vector<char> buffer(file_length + 1);
+		file.read( (U8*)&buffer[0], file_length);
 		buffer[ file_length ] = 0;
 
-		LLLandmark* landmark = LLLandmark::constructFromString(buffer);
+		LLLandmark* landmark = LLLandmark::constructFromString(&buffer[0]);
 		if (landmark)
 		{
 			LLVector3d pos;
@@ -111,8 +111,6 @@ void LLLandmarkList::processGetAssetReply(
 			}
 			gLandmarkList.mList[ uuid ] = landmark;
 		}
-
-		delete[] buffer;
 	}
 	else
 	{
diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp
index a9b0610ed5f06d73072e3b5d1c6e1bac7501147d..1709d6465d91a347262bac5bd92f05bbfa59f7f7 100644
--- a/indra/newview/lllogchat.cpp
+++ b/indra/newview/lllogchat.cpp
@@ -50,7 +50,7 @@ std::string LLLogChat::makeLogFileName(std::string filename)
 std::string LLLogChat::cleanFileName(std::string filename)
 {
 	std::string invalidChars = "\"\'\\/?*:<>|";
-	S32 position = filename.find_first_of(invalidChars);
+	std::string::size_type position = filename.find_first_of(invalidChars);
 	while (position != filename.npos)
 	{
 		filename[position] = '_';
diff --git a/indra/newview/llmutelist.cpp b/indra/newview/llmutelist.cpp
index bfcba59975021f6731f03f91ade6bc3fd5eb4b6c..841330483c3d67a1e2ada8c9b8c7c112b002e0b6 100644
--- a/indra/newview/llmutelist.cpp
+++ b/indra/newview/llmutelist.cpp
@@ -788,8 +788,9 @@ void LLMuteList::processMuteListUpdate(LLMessageSystem* msg, void**)
 		llwarns << "Got an mute list update for the wrong agent." << llendl;
 		return;
 	}
-	std::string filename;
-	msg->getStringFast(_PREHASH_MuteData, _PREHASH_Filename, filename);
+	std::string unclean_filename;
+	msg->getStringFast(_PREHASH_MuteData, _PREHASH_Filename, unclean_filename);
+	std::string filename = LLDir::getScrubbedFileName(unclean_filename);
 	
 	std::string *local_filename_and_path = new std::string(gDirUtilp->getExpandedFilename( LL_PATH_CACHE, filename ));
 	gXferManager->requestFile(*local_filename_and_path,
diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp
index 7253d758eabaf909f9e6a9b3a19fa28af4b202c6..9d5a4ad01c879738e54e5797de6e1310611de9cf 100644
--- a/indra/newview/llpanelavatar.cpp
+++ b/indra/newview/llpanelavatar.cpp
@@ -483,11 +483,20 @@ LLPanelAvatarWeb::~LLPanelAvatarWeb()
 	};
 }
 
+void LLPanelAvatarWeb::refresh()
+{
+	if (mNavigateTo != "")
+	{
+		llinfos << "Loading " << mNavigateTo << llendl;
+		mWebBrowser->navigateTo( mNavigateTo );
+		mNavigateTo = "";
+	}
+}
+
+
 void LLPanelAvatarWeb::enableControls(BOOL self)
 {	
 	childSetEnabled("url_edit",self);
-	childSetVisible("status_text",!self && !mHome.empty());
-	childSetText("status_text", LLStringUtil::null);
 }
 
 void LLPanelAvatarWeb::setWebURL(std::string url)
@@ -511,11 +520,8 @@ void LLPanelAvatarWeb::setWebURL(std::string url)
 	else
 	{
 		childSetVisible("profile_html",false);
+		childSetVisible("status_text", false);
 	}
-
-	BOOL own_avatar = (getPanelAvatar()->getAvatarID() == gAgent.getID() );
-	childSetVisible("status_text",!own_avatar && !mHome.empty());
-	
 }
 
 // static
@@ -538,13 +544,15 @@ void LLPanelAvatarWeb::load(std::string url)
 {
 	bool have_url = (!url.empty());
 
+	
+	childSetVisible("profile_html", have_url);
+	childSetVisible("status_text", have_url);
+	childSetText("status_text", LLStringUtil::null);
+
 	if (have_url)
 	{
-		llinfos << "Loading " << url << llendl;
-		mWebBrowser->navigateTo( url );
+		mNavigateTo = url;
 	}
-
-	childSetVisible("profile_html", have_url);
 }
 
 //static
diff --git a/indra/newview/llpanelavatar.h b/indra/newview/llpanelavatar.h
index 041d50331c5bf7d22c9c727d567a1b8b79e475e5..12e1b99360c1b5b6b1f2870c6c7cfc4fbbbc8674 100644
--- a/indra/newview/llpanelavatar.h
+++ b/indra/newview/llpanelavatar.h
@@ -144,6 +144,8 @@ public:
 	/*virtual*/ ~LLPanelAvatarWeb();
 	/*virtual*/ BOOL	postBuild(void);
 
+	/*virtual*/ void refresh();
+
 	void enableControls(BOOL own_avatar);
 
 	void setWebURL(std::string url);
@@ -160,6 +162,7 @@ public:
 
 private:
 	std::string			mHome;
+	std::string         mNavigateTo;
 	LLWebBrowserCtrl*	mWebBrowser;
 };
 
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index b1a38e07a77c89bd5e216be7cd85aaf791c54eb4..e93a5be8ed5776f5cfbc4b5bd4f6eb388162708d 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -73,7 +73,6 @@ BOOL	LLPanelFace::postBuild()
 	LLTextureCtrl*	mTextureCtrl;
 	LLColorSwatchCtrl*	mColorSwatch;
 
-	LLTextBox*		mLabelTexGen;
 	LLComboBox*		mComboTexGen;
 
 	LLCheckBoxCtrl	*mCheckFullbright;
@@ -81,7 +80,6 @@ BOOL	LLPanelFace::postBuild()
 	LLTextBox*		mLabelColorTransp;
 	LLSpinCtrl*		mCtrlColorTransp;		// transparency = 1 - alpha
 
-	LLTextBox*      mLabelGlow;
 	LLSpinCtrl*     mCtrlGlow;
 
 	setMouseOpaque(FALSE);
@@ -152,7 +150,7 @@ BOOL	LLPanelFace::postBuild()
 		mCheckFullbright->setCommitCallback(LLPanelFace::onCommitFullbright);
 		mCheckFullbright->setCallbackUserData( this );
 	}
-	mLabelTexGen = getChild<LLTextBox>("tex gen");
+
 	mComboTexGen = getChild<LLComboBox>("combobox texgen");
 	if(mComboTexGen)
 	{
@@ -161,7 +159,6 @@ BOOL	LLPanelFace::postBuild()
 		mComboTexGen->setCallbackUserData( this );
 	}
 
-	mLabelGlow = getChild<LLTextBox>("glow label");
 	mCtrlGlow = getChild<LLSpinCtrl>("glow");
 	if(mCtrlGlow)
 	{
diff --git a/indra/newview/llpanelgroup.cpp b/indra/newview/llpanelgroup.cpp
index add1f3caa580d80e999252cbf08ac1fdb523e630..d9d796fd9e0d29fba649ec7251bd158c774607e1 100644
--- a/indra/newview/llpanelgroup.cpp
+++ b/indra/newview/llpanelgroup.cpp
@@ -37,7 +37,6 @@
 #include "llbutton.h"
 #include "llpanelgroupgeneral.h"
 #include "llpanelgrouproles.h"
-#include "llpanelgroupvoting.h"
 #include "llpanelgrouplandmoney.h"
 #include "llpanelgroupnotices.h"
 #include "lltabcontainer.h"
@@ -148,8 +147,6 @@ LLPanelGroup::LLPanelGroup(const std::string& filename,
 												&mID);
 	mFactoryMap["notices_tab"]	= LLCallbackMap(LLPanelGroupNotices::createTab,
 												&mID);
-	mFactoryMap["voting_tab"]	= LLCallbackMap(LLPanelGroupVoting::createTab,
-												&mID);
 	mFactoryMap["land_money_tab"]= LLCallbackMap(LLPanelGroupLandMoney::createTab,
 												 &mID);
 	// Roles sub tabs
diff --git a/indra/newview/llpanelgroupgeneral.cpp b/indra/newview/llpanelgroupgeneral.cpp
index cbf4a8740c06aa2eb4026487befcdbc63a34cc10..3dc5e032c5b41f6a152d8a4fc610c4b3f79313d7 100644
--- a/indra/newview/llpanelgroupgeneral.cpp
+++ b/indra/newview/llpanelgroupgeneral.cpp
@@ -901,7 +901,7 @@ void LLPanelGroupGeneral::updateChanged()
 
 	mChanged = FALSE;
 
-	for( int i= 0; i< LL_ARRAY_SIZE(check_list); i++ )
+	for( size_t i=0; i<LL_ARRAY_SIZE(check_list); i++ )
 	{
 		if( check_list[i] && check_list[i]->isDirty() )
 		{
diff --git a/indra/newview/llpanelgrouplandmoney.cpp b/indra/newview/llpanelgrouplandmoney.cpp
index 7c2e8981f9b8352213ded2f708d515cfcc6e97d5..6ff09e56f8c5738b7172aeb647d2af98a2766c8e 100644
--- a/indra/newview/llpanelgrouplandmoney.cpp
+++ b/indra/newview/llpanelgrouplandmoney.cpp
@@ -974,7 +974,7 @@ void LLGroupMoneyTabEventHandler::clickLaterCallback(void* data)
 void LLGroupMoneyTabEventHandler::clickTabCallback(void* data, bool from_click)
 {
 	LLGroupMoneyTabEventHandler* selfp = (LLGroupMoneyTabEventHandler*) data;
-	if ( selfp ) selfp->onClickTab();
+	if ( selfp && from_click ) selfp->onClickTab();
 }
 
 //**************************************************
diff --git a/indra/newview/llpanelgroupnotices.cpp b/indra/newview/llpanelgroupnotices.cpp
index e07259f7a1c6829c88662c02261042d256ef31d9..5824df46e23fb16e7db76fefd50ec9f0c872d992 100644
--- a/indra/newview/llpanelgroupnotices.cpp
+++ b/indra/newview/llpanelgroupnotices.cpp
@@ -56,8 +56,6 @@
 #include "llviewermessage.h"
 #include "llnotifications.h"
 
-const S32 NOTICE_DATE_STRING_SIZE = 30;
-
 /////////////////////////
 // LLPanelGroupNotices //
 /////////////////////////
@@ -170,14 +168,23 @@ BOOL LLGroupDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
 //-----------------------------------------------------------------------------
 // LLPanelGroupNotices
 //-----------------------------------------------------------------------------
-std::string build_notice_date(const time_t& the_time)
+std::string build_notice_date(const U32& the_time)
 {
-	time_t t = the_time;
-	if (!t) time(&t);
+	// ISO 8601 date format
+
+	time_t t = (time_t)the_time;
+	
+	if (!t)
+	{
+		time(&t);
+	}
+	
 	tm* lt = localtime(&t);
+	
 	//for some reason, the month is off by 1.  See other uses of
 	//"local" time in the code...
-	std::string buffer = llformat("%i/%i/%i", lt->tm_mon + 1, lt->tm_mday, lt->tm_year + 1900);
+	std::string buffer = llformat("%04i-%02i-%02i", lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday);
+	
 	return buffer;
 }
 
@@ -469,7 +476,6 @@ void LLPanelGroupNotices::processNotices(LLMessageSystem* msg)
 		msg->getBOOL("Data","HasAttachment",has_attachment,i);
 		msg->getU8("Data","AssetType",asset_type,i);
 		msg->getU32("Data","Timestamp",timestamp,i);
-		time_t t = timestamp;
 
 		LLSD row;
 		row["id"] = id;
@@ -490,13 +496,11 @@ void LLPanelGroupNotices::processNotices(LLMessageSystem* msg)
 		row["columns"][2]["column"] = "from";
 		row["columns"][2]["value"] = name;
 
-		std::string buffer = build_notice_date(t);
 		row["columns"][3]["column"] = "date";
-		row["columns"][3]["value"] = buffer;
+		row["columns"][3]["value"] = build_notice_date(timestamp);
 
-		buffer = llformat( "%u", timestamp);
 		row["columns"][4]["column"] = "sort";
-		row["columns"][4]["value"] = buffer;
+		row["columns"][4]["value"] = llformat( "%u", timestamp);
 
 		mNoticesList->addElement(row, ADD_BOTTOM);
 	}
diff --git a/indra/newview/llpanelpermissions.cpp b/indra/newview/llpanelpermissions.cpp
index da8c9a9ac7b9ab97ab0bf2355ee125aeb8ecd20a..389f06f355a349cfea4cc41eb3b631830d52051c 100644
--- a/indra/newview/llpanelpermissions.cpp
+++ b/indra/newview/llpanelpermissions.cpp
@@ -1034,7 +1034,7 @@ void LLPanelPermissions::setAllSaleInfo()
 	{
 		// Don't extract the price if it's labeled as MIXED or is empty.
 		const std::string& editPriceString = editPrice->getText();
-		if (editPriceString != getString("Cost Mixed") &&
+		if (editPriceString != getString("Cost Mixed") && editPriceString != getString("Sale Mixed") &&
 			!editPriceString.empty())
 		{
 			price = atoi(editPriceString.c_str());
@@ -1048,12 +1048,6 @@ void LLPanelPermissions::setAllSaleInfo()
 	if (price < 0)
 		sale_type = LLSaleInfo::FS_NOT;
 
-	// Force the sale price of not-for-sale items to DEFAULT_PRICE.
-	if (sale_type == LLSaleInfo::FS_NOT)
-	{
-		price = DEFAULT_PRICE;
-	}
-	// Pack up the sale info and send the update.
 	LLSaleInfo sale_info(sale_type, price);
 	LLSelectMgr::getInstance()->selectionSetObjectSaleInfo(sale_info);
 	
diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp
index ff3b9433f4833f1bfbff3f416c2eaab084256c91..76a9b80645db8e155c9d293cf62eae837053cf3a 100644
--- a/indra/newview/llpreviewgesture.cpp
+++ b/indra/newview/llpreviewgesture.cpp
@@ -920,13 +920,13 @@ void LLPreviewGesture::onLoadComplete(LLVFS *vfs,
 			LLVFile file(vfs, asset_uuid, type, LLVFile::READ);
 			S32 size = file.getSize();
 
-			char* buffer = new char[size+1];
-			file.read((U8*)buffer, size);		/*Flawfinder: ignore*/
+			std::vector<char> buffer(size+1);
+			file.read((U8*)&buffer[0], size);
 			buffer[size] = '\0';
 
 			LLMultiGesture* gesture = new LLMultiGesture();
 
-			LLDataPackerAsciiBuffer dp(buffer, size+1);
+			LLDataPackerAsciiBuffer dp(&buffer[0], size+1);
 			BOOL ok = gesture->deserialize(dp);
 
 			if (ok)
@@ -947,9 +947,6 @@ void LLPreviewGesture::onLoadComplete(LLVFS *vfs,
 			delete gesture;
 			gesture = NULL;
 
-			delete [] buffer;
-			buffer = NULL;
-
 			self->mAssetStatus = PREVIEW_ASSET_LOADED;
 		}
 		else
diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp
index 897fd6a2ee8c55726818cc810f20e9ef608407a8..4abe390bc5478fd9722e3f2a532dfd6a9dd98680 100644
--- a/indra/newview/llpreviewnotecard.cpp
+++ b/indra/newview/llpreviewnotecard.cpp
@@ -364,8 +364,8 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs,
 
 			S32 file_length = file.getSize();
 
-			char* buffer = new char[file_length+1];
-			file.read((U8*)buffer, file_length);		/*Flawfinder: ignore*/
+			std::vector<char> buffer(file_length+1);
+			file.read((U8*)&buffer[0], file_length);
 
 			// put a EOS at the end
 			buffer[file_length] = 0;
@@ -373,9 +373,9 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs,
 			
 			LLViewerTextEditor* previewEditor = preview->getChild<LLViewerTextEditor>("Notecard Editor");
 
-			if( (file_length > 19) && !strncmp( buffer, "Linden text version", 19 ) )
+			if( (file_length > 19) && !strncmp( &buffer[0], "Linden text version", 19 ) )
 			{
-				if( !previewEditor->importBuffer( buffer, file_length+1 ) )
+				if( !previewEditor->importBuffer( &buffer[0], file_length+1 ) )
 				{
 					llwarns << "Problem importing notecard" << llendl;
 				}
@@ -383,7 +383,7 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs,
 			else
 			{
 				// Version 0 (just text, doesn't include version number)
-				previewEditor->setText(LLStringExplicit(buffer));
+				previewEditor->setText(LLStringExplicit(&buffer[0]));
 			}
 
 			previewEditor->makePristine();
@@ -392,7 +392,6 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs,
 			BOOL modifiable = item && gAgent.allowOperation(PERM_MODIFY,
 								item->getPermissions(), GP_OBJECT_MANIPULATE);
 			preview->setEnabled(modifiable);
-			delete[] buffer;
 			preview->mAssetStatus = PREVIEW_ASSET_LOADED;
 		}
 		else
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 931d30c9fa3eb96343a9f02d7e43e6720c590dd9..0bacb95d2dccdb41222a02d85fe135a91126cc3f 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -314,7 +314,8 @@ LLScriptEdCore::LLScriptEdCore(
 	mForceClose( FALSE ),
 	mLastHelpToken(NULL),
 	mLiveHelpHistorySize(0),
-	mEnableSave(FALSE)
+	mEnableSave(FALSE),
+	mHasScriptData(FALSE)
 {
 	setFollowsAll();
 	setBorderVisible(FALSE);
@@ -442,12 +443,21 @@ void LLScriptEdCore::initMenu()
 	menuItem->setEnabledCallback(NULL);
 }
 
+void LLScriptEdCore::setScriptText(const std::string& text, BOOL is_valid)
+{
+	if (mEditor)
+	{
+		mEditor->setText(text);
+		mHasScriptData = is_valid;
+	}
+}
+
 BOOL LLScriptEdCore::hasChanged(void* userdata)
 {
 	LLScriptEdCore* self = (LLScriptEdCore*)userdata;
 	if (!self || !self->mEditor) return FALSE;
 
-	return !self->mEditor->isPristine() || self->mEnableSave;
+	return ((!self->mEditor->isPristine() || self->mEnableSave) && self->mHasScriptData);
 }
 
 void LLScriptEdCore::draw()
@@ -975,8 +985,8 @@ bool LLScriptEdCore::handleReloadFromServerDialog(const LLSD& notification, cons
 	case 0: // "Yes"
 		if( mLoadCallback )
 		{
-			mEditor->setText( getString("loading") );
-			mLoadCallback( mUserdata );
+			setScriptText(getString("loading"), FALSE);
+			mLoadCallback(mUserdata);
 		}
 		break;
 
@@ -1189,7 +1199,7 @@ void LLPreviewLSL::loadAsset()
 		}
 		else
 		{
-			mScriptEd->mEditor->setText(mScriptEd->getString("can_not_view"));
+			mScriptEd->setScriptText(mScriptEd->getString("can_not_view"), FALSE);
 			mScriptEd->mEditor->makePristine();
 			mScriptEd->mEditor->setEnabled(FALSE);
 			mScriptEd->mFunctions->setEnabled(FALSE);
@@ -1200,7 +1210,7 @@ void LLPreviewLSL::loadAsset()
 	}
 	else
 	{
-		mScriptEd->mEditor->setText(std::string(HELLO_LSL));
+		mScriptEd->setScriptText(std::string(HELLO_LSL), TRUE);
 		mAssetStatus = PREVIEW_ASSET_LOADED;
 	}
 }
@@ -1506,14 +1516,13 @@ void LLPreviewLSL::onLoadComplete( LLVFS *vfs, const LLUUID& asset_uuid, LLAsset
 			LLVFile file(vfs, asset_uuid, type);
 			S32 file_length = file.getSize();
 
-			char* buffer = new char[file_length+1];
-			file.read((U8*)buffer, file_length);		/*Flawfinder: ignore*/
+			std::vector<char> buffer(file_length+1);
+			file.read((U8*)&buffer[0], file_length);
 
 			// put a EOS at the end
 			buffer[file_length] = 0;
-			preview->mScriptEd->mEditor->setText(LLStringExplicit(buffer));
+			preview->mScriptEd->setScriptText(LLStringExplicit(&buffer[0]), TRUE);
 			preview->mScriptEd->mEditor->makePristine();
-			delete [] buffer;
 			LLInventoryItem* item = gInventory.getItem(*item_uuid);
 			BOOL is_modifiable = FALSE;
 			if(item
@@ -1726,7 +1735,7 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new)
 					   || !gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE))))
 			{
 				mItem = new LLViewerInventoryItem(item);
-				mScriptEd->mEditor->setText(getString("not_allowed"));
+				mScriptEd->setScriptText(getString("not_allowed"), FALSE);
 				mScriptEd->mEditor->makePristine();
 				mScriptEd->mEditor->setEnabled(FALSE);
 				mScriptEd->enableSave(FALSE);
@@ -1758,7 +1767,7 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new)
 			}
 			else
 			{
-				mScriptEd->mEditor->setText(LLStringUtil::null);
+				mScriptEd->setScriptText(LLStringUtil::null, FALSE);
 				mScriptEd->mEditor->makePristine();
 				mAssetStatus = PREVIEW_ASSET_LOADED;
 			}
@@ -1795,7 +1804,7 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new)
 			// This may be better than having a accessible null pointer around,
 			// though this newly allocated object will most likely be replaced.
 			mItem = new LLViewerInventoryItem();
-			mScriptEd->mEditor->setText(LLStringUtil::null);
+			mScriptEd->setScriptText(LLStringUtil::null, FALSE);
 			mScriptEd->mEditor->makePristine();
 			mScriptEd->mEditor->setEnabled(FALSE);
 			mAssetStatus = PREVIEW_ASSET_LOADED;
@@ -1803,7 +1812,7 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new)
 	}
 	else
 	{
-		mScriptEd->mEditor->setText(std::string(HELLO_LSL));
+		mScriptEd->setScriptText(std::string(HELLO_LSL), TRUE);
 		mScriptEd->enableSave(FALSE);
 		LLPermissions perm;
 		perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, gAgent.getGroupID());
@@ -1902,8 +1911,8 @@ void LLLiveLSLEditor::loadScriptText(LLVFS *vfs, const LLUUID &uuid, LLAssetType
 {
 	LLVFile file(vfs, uuid, type);
 	S32 file_length = file.getSize();
-	char *buffer = new char[file_length + 1];
-	file.read((U8*)buffer, file_length);		/*Flawfinder: ignore*/
+	std::vector<char> buffer(file_length + 1);
+	file.read((U8*)&buffer[0], file_length);
 
 	if (file.getLastBytesRead() != file_length ||
 		file_length <= 0)
@@ -1913,10 +1922,8 @@ void LLLiveLSLEditor::loadScriptText(LLVFS *vfs, const LLUUID &uuid, LLAssetType
 
 	buffer[file_length] = '\0';
 
-	mScriptEd->mEditor->setText(LLStringExplicit(buffer));
+	mScriptEd->setScriptText(LLStringExplicit(&buffer[0]), TRUE);
 	mScriptEd->mEditor->makePristine();
-	delete[] buffer;
-
 }
 
 
diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h
index 7f634a48a0f32180135f13f8beb3f2d113335694..eb8b4147093b01bd9cc461be0835e89b2a3c33bc 100644
--- a/indra/newview/llpreviewscript.h
+++ b/indra/newview/llpreviewscript.h
@@ -81,6 +81,8 @@ public:
 
 	BOOL			canClose();
 
+	void            setScriptText(const std::string& text, BOOL is_valid);
+
 	bool			handleSaveChangesDialog(const LLSD& notification, const LLSD& response);
 	bool			handleReloadFromServerDialog(const LLSD& notification, const LLSD& response);
 
@@ -150,6 +152,7 @@ private:
 	LLFrameTimer	mLiveHelpTimer;
 	S32				mLiveHelpHistorySize;
 	BOOL			mEnableSave;
+	BOOL			mHasScriptData;
 };
 
 
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 9aa5c37b265db4d2f7b728739a3ab77e5b3e414b..564313980d0c510004ed5ef4fcc7029434dd05ed 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -92,7 +92,6 @@ LLViewerObject* getSelectedParentObject(LLViewerObject *object) ;
 
 const S32 NUM_SELECTION_UNDO_ENTRIES = 200;
 const F32 SILHOUETTE_UPDATE_THRESHOLD_SQUARED = 0.02f;
-const S32 OWNERSHIP_COST_PER_OBJECT = 10; // Must be the same as economy_constants.price_object_claim in the database.
 const S32 MAX_ACTION_QUEUE_SIZE = 20;
 const S32 MAX_SILS_PER_FRAME = 50;
 const S32 MAX_OBJECTS_PER_PACKET = 254;
@@ -2620,11 +2619,6 @@ BOOL LLSelectMgr::selectGetPerm(U8 which_perm, U32* mask_on, U32* mask_off)
 
 
 
-BOOL LLSelectMgr::selectGetOwnershipCost(S32* out_cost)
-{
-	return mSelectedObjects->getOwnershipCost(*out_cost);
-}
-
 BOOL LLSelectMgr::selectGetPermissions(LLPermissions& result_perm)
 {
 	BOOL first = TRUE;
@@ -5869,16 +5863,6 @@ BOOL LLObjectSelection::isEmpty() const
 	return (mList.size() == 0);
 }
 
-//-----------------------------------------------------------------------------
-// getOwnershipCost()
-//-----------------------------------------------------------------------------
-BOOL LLObjectSelection::getOwnershipCost(S32 &cost)
-{
-	S32 count = getObjectCount();
-	cost = count * OWNERSHIP_COST_PER_OBJECT;
-	return (count > 0);
-}
-
 
 //-----------------------------------------------------------------------------
 // getObjectCount() - returns number of non null objects
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index 582a78551d5e56c3d9e466c070b1bece75ebe397..d6c4b5485db646083942006bf3c3e8b67844febd 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -275,8 +275,6 @@ public:
 
 	BOOL isEmpty() const;
 
-	S32 getOwnershipCost(S32 &cost);
-
 	LLSelectNode*	getFirstNode(LLSelectedNodeFunctor* func = NULL);
 	LLSelectNode*	getFirstRootNode(LLSelectedNodeFunctor* func = NULL, BOOL non_root_ok = FALSE);
 	LLViewerObject* getFirstSelectedObject(LLSelectedNodeFunctor* func, BOOL get_parent = FALSE);
@@ -552,7 +550,6 @@ public:
 	// the value found if available.
 	BOOL selectGetGroup(LLUUID& id); 
 	BOOL selectGetPerm(	U8 which_perm, U32* mask_on, U32* mask_off);	// TRUE if all have data, returns two masks, each indicating which bits are all on and all off
-	BOOL selectGetOwnershipCost(S32* cost);								// sum of all ownership costs
 
 	BOOL selectIsGroupOwned();											// TRUE if all root objects have valid data and are group owned.
 
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index bd2e157779e54fb4b9ab18a04c33b31ecc3361aa..a145e965fb9ddad2f4f04c22ddcf2c828e314561 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -116,6 +116,7 @@
 #include "llkeyboard.h"
 #include "llloginhandler.h"			// gLoginHandler, SLURL support
 #include "llpanellogin.h"
+#include "llprefsim.h"
 #include "llmutelist.h"
 #include "llnotify.h"
 #include "llpanelavatar.h"
@@ -1294,16 +1295,9 @@ bool idle_startup()
 		if (update || gSavedSettings.getBOOL("ForceMandatoryUpdate"))
 		{
 			gSavedSettings.setBOOL("ForceMandatoryUpdate", FALSE);
-			if (show_connect_box)
-			{
-				update_app(TRUE, auth_message);
-				LLStartUp::setStartupState( STATE_UPDATE_CHECK );
-				return false;
-			}
-			else
-			{
-				quit = true;
-			}
+			update_app(TRUE, auth_message);
+			LLStartUp::setStartupState( STATE_UPDATE_CHECK );
+			return false;
 		}
 
 		// Version update and we're not showing the dialog
@@ -1976,6 +1970,9 @@ bool idle_startup()
 	//---------------------------------------------------------------------
 	if (STATE_INVENTORY_SEND == LLStartUp::getStartupState())
 	{
+		// Inform simulator of our language preference
+		LLAgentLanguage::update();
+
 		// unpack thin inventory
 		LLUserAuth::options_t options;
 		options.clear();
@@ -2291,9 +2288,6 @@ bool idle_startup()
 		// JC - 7/20/2002
 		gViewerWindow->sendShapeToSim();
 
-		// Inform simulator of our language preference
-		LLAgentLanguage::update();
-
 		
 		// Ignore stipend information for now.  Money history is on the web site.
 		// if needed, show the L$ history window
@@ -2352,6 +2346,9 @@ bool idle_startup()
         //DEV-17797.  get null folder.  Any items found here moved to Lost and Found
         LLInventoryModel::findLostItems();
 
+		//DEV-10530.  do cleanup.  remove at some later date.  jan-2009
+		LLPrefsIM::cleanupBadSetting();
+
 		LLStartUp::setStartupState( STATE_PRECACHE );
 		timeout.reset();
 		return FALSE;
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index 971930d7eefcae507f50bad502bd7151a94d7df2..f36d12d638975e495bc1e50afec1873cf249f665 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -628,9 +628,16 @@ void LLStatusBar::refresh()
 	mTextParcelName->setRect(r);
 
 	// Set search bar visibility
-	childSetVisible("search_editor", search_visible);
-	childSetVisible("search_btn", search_visible);
-	childSetVisible("menubar_search_bevel_bg", search_visible);
+
+	if (gAgent.getCameraMode() != CAMERA_MODE_MOUSELOOK)
+	{
+		// don't monkey with search visibility in mouselook - it will be set
+		// with setVisibleForMouselook() below
+		childSetVisible("search_editor", search_visible);
+		childSetVisible("search_btn", search_visible);
+		childSetVisible("menubar_search_bevel_bg", search_visible);
+	}
+	
 	mSGBandwidth->setVisible(! search_visible);
 	mSGPacketLoss->setVisible(! search_visible);
 	childSetEnabled("stat_btn", ! search_visible);
@@ -643,6 +650,7 @@ void LLStatusBar::setVisibleForMouselook(bool visible)
 	childSetVisible("buycurrency", visible);
 	childSetVisible("search_editor", visible);
 	childSetVisible("search_btn", visible);
+	childSetVisible("menubar_search_bevel_bg", visible);
 	mSGBandwidth->setVisible(visible);
 	mSGPacketLoss->setVisible(visible);
 	setBackgroundVisible(visible);
diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp
index 69723f622a69ea1a52c0ce8897891161f1ffcb58..a3966ed6666583037e103412967639b0ec21da19 100644
--- a/indra/newview/lltexturecache.cpp
+++ b/indra/newview/lltexturecache.cpp
@@ -1254,7 +1254,7 @@ void LLTextureCache::purgeTextures(bool validate)
 		else if (validate)
 		{
 			// make sure file exists and is the correct size
-			S32 uuididx = entries[idx].mID.mData[0];
+			U32 uuididx = entries[idx].mID.mData[0];
 			if (uuididx == validate_idx)
 			{
  				LL_DEBUGS("TextureCache") << "Validating: " << filename << "Size: " << entries[idx].mSize << LL_ENDL;
diff --git a/indra/newview/lltool.cpp b/indra/newview/lltool.cpp
index da9f3c5bd72e434bc1f027062d3cd1027c10aed8..6a3ada0474e7254108eaa9478bdbf6115faf0203 100644
--- a/indra/newview/lltool.cpp
+++ b/indra/newview/lltool.cpp
@@ -65,7 +65,6 @@ LLTool::~LLTool()
 	}
 }
 
-
 BOOL LLTool::handleMouseDown(S32 x, S32 y, MASK mask)
 {
 	if (gDebugClicks)
@@ -125,6 +124,20 @@ BOOL LLTool::handleRightMouseUp(S32 x, S32 y, MASK mask)
 	// llinfos << "LLTool::handleRightMouseDown" << llendl;
 	return FALSE;
 }
+ 
+BOOL LLTool::handleMiddleMouseDown(S32 x,S32 y,MASK mask)
+{
+	// by default, didn't handle it
+	// llinfos << "LLTool::handleMiddleMouseDown" << llendl;
+	return FALSE;
+}
+
+BOOL LLTool::handleMiddleMouseUp(S32 x, S32 y, MASK mask)
+{
+	// by default, didn't handle it
+	// llinfos << "LLTool::handleMiddleMouseUp" << llendl;
+	return FALSE;
+}
 
 BOOL LLTool::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen)
 {
diff --git a/indra/newview/lltool.h b/indra/newview/lltool.h
index 249088fd3d386d6490f43766366251c3a09c7b7a..f954a8c243bc021dff2088f3bbfb480182008b1b 100644
--- a/indra/newview/lltool.h
+++ b/indra/newview/lltool.h
@@ -57,6 +57,9 @@ public:
 	// Virtual functions inherited from LLMouseHandler
 	virtual BOOL	handleMouseDown(S32 x, S32 y, MASK mask);
 	virtual BOOL	handleMouseUp(S32 x, S32 y, MASK mask);
+	virtual BOOL	handleMiddleMouseDown(S32 x, S32 y, MASK mask);
+	virtual BOOL	handleMiddleMouseUp(S32 x, S32 y, MASK mask);
+
 	virtual BOOL	handleHover(S32 x, S32 y, MASK mask);
 	virtual BOOL	handleScrollWheel(S32 x, S32 y, S32 clicks);
 	virtual BOOL	handleDoubleClick(S32 x, S32 y, MASK mask);
diff --git a/indra/newview/lltoolfocus.cpp b/indra/newview/lltoolfocus.cpp
index 351c02b4c0a6afa4547eea54eee8154ed3487131..4e8274a6ef72385560443ff0261cceeb302753fa 100644
--- a/indra/newview/lltoolfocus.cpp
+++ b/indra/newview/lltoolfocus.cpp
@@ -128,8 +128,8 @@ BOOL LLToolCamera::handleMouseDown(S32 x, S32 y, MASK mask)
 	gViewerWindow->hideCursor();
 
 	gViewerWindow->pickAsync(x, y, mask, pickCallback);
-	// don't steal focus from UI
-	return FALSE;
+
+	return TRUE;
 }
 
 void LLToolCamera::pickCallback(const LLPickInfo& pick_info)
diff --git a/indra/newview/lltoolgrab.cpp b/indra/newview/lltoolgrab.cpp
index ed9ca851d3d9e987dfa7056a72285cd6411e0247..d9811dac6c04274c5e379f3643dbc65f27185471 100644
--- a/indra/newview/lltoolgrab.cpp
+++ b/indra/newview/lltoolgrab.cpp
@@ -210,22 +210,29 @@ BOOL LLToolGrab::handleObjectHit(const LLPickInfo& info)
 
 	if (!objectp->usePhysics())
 	{
-		// In mouselook, we shouldn't be able to grab non-physical, 
-		// non-touchable objects.  If it has a touch handler, we
-		// do grab it (so llDetectedGrab works), but movement is
-		// blocked on the server side. JC
-		if (gAgent.cameraMouselook() && !script_touch)
+		if (script_touch)
 		{
-			mMode = GRAB_LOCKED;
-			gViewerWindow->hideCursor();
-			gViewerWindow->moveCursorToCenter();
+			mMode = GRAB_NONPHYSICAL;  // if it has a script, use the non-physical grab
 		}
 		else
 		{
-			mMode = GRAB_NONPHYSICAL;
+			// In mouselook, we shouldn't be able to grab non-physical, 
+			// non-touchable objects.  If it has a touch handler, we
+			// do grab it (so llDetectedGrab works), but movement is
+			// blocked on the server side. JC
+			if (gAgent.cameraMouselook())
+			{
+				mMode = GRAB_LOCKED;
+			}
+			else
+			{
+				mMode = GRAB_ACTIVE_CENTER;
+			}
+
+			gViewerWindow->hideCursor();
+			gViewerWindow->moveCursorToCenter();
+			
 		}
-		// Don't bail out here, go on and grab so buttons can get
-		// their "touched" event.
 	}
 	else if( !objectp->permMove() )
 	{
diff --git a/indra/newview/lltracker.cpp b/indra/newview/lltracker.cpp
index 8e81152a8920254105c0533a3699fce17320142f..d54cc798d246ac3cb6e66922734f002ec668cd94 100644
--- a/indra/newview/lltracker.cpp
+++ b/indra/newview/lltracker.cpp
@@ -294,6 +294,7 @@ void LLTracker::trackAvatar( const LLUUID& avatar_id, const std::string& name )
 	LLAvatarTracker::instance().track( avatar_id, name );
 	instance()->mTrackingStatus = TRACKING_AVATAR;
 	instance()->mLabel = name;
+	instance()->mToolTip = "";
 }
 
 
@@ -309,6 +310,7 @@ void LLTracker::trackLandmark( const LLUUID& asset_id, const LLUUID& item_id, co
 	instance()->cacheLandmarkPosition();
 	instance()->mTrackingStatus = TRACKING_LANDMARK;
 	instance()->mLabel = name;
+	instance()->mToolTip = "";
 }
 
 
diff --git a/indra/newview/lluploaddialog.cpp b/indra/newview/lluploaddialog.cpp
index 2ba87f01bd78230b75d18018ca02aeb84448d3b5..7f63972c8d67a4fbaca9b7ee954bd5ad1c271ad4 100644
--- a/indra/newview/lluploaddialog.cpp
+++ b/indra/newview/lluploaddialog.cpp
@@ -103,18 +103,10 @@ void LLUploadDialog::setMessage( const std::string& msg)
 	S32 max_msg_width = 0;
 	std::list<std::string> msg_lines;
 
-	S32 size = msg.size() + 1;// + strlen("Uploading...\n\n");
-	char* temp_msg = new char[size];
-	
-	//strcpy(temp_msg,"Uploading...\n\n");
-	if (temp_msg == NULL)
-	{
-		llerrs << "Memory Allocation Failed" << llendl;
-		return;
-	}
-	
-	strcpy( temp_msg, msg.c_str());		/* Flawfinder: ignore */
-	char* token = strtok( temp_msg, "\n" );
+	S32 size = msg.size() + 1;
+	std::vector<char> temp_msg(size); // non-const copy to make strtok happy
+	strcpy( &temp_msg[0], msg.c_str());
+	char* token = strtok( &temp_msg[0], "\n" );
 	while( token )
 	{
 		std::string tokstr(token);
@@ -123,8 +115,6 @@ void LLUploadDialog::setMessage( const std::string& msg)
 		msg_lines.push_back( tokstr );
 		token = strtok( NULL, "\n" );
 	}
-	delete[] temp_msg;
-
 
 	S32 line_height = S32( font->getLineHeight() + 0.99f );
 	S32 dialog_width = max_msg_width + 2 * HPAD;
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 2c487665d22968fa0a9407a2e8390cc224350e01..eb8cdd82b3cdf1718b2db100a83b5d2291035144 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -63,6 +63,7 @@
 #include "llviewerparcelmgr.h"
 #include "llparcel.h"
 #include "llnotify.h"
+#include "lloverlaybar.h"
 #include "llkeyboard.h"
 #include "llerrorcontrol.h"
 #include "llversionviewer.h"
@@ -269,17 +270,21 @@ static bool handleAudioStreamMusicChanged(const LLSD& newvalue)
 			if (LLViewerParcelMgr::getInstance()->getAgentParcel()
 				&& !LLViewerParcelMgr::getInstance()->getAgentParcel()->getMusicURL().empty())
 			{
-				// if stream is already playing, don't call this
-				// otherwise music will briefly stop
-				if ( !gAudiop->isInternetStreamPlaying() )
+				// if music isn't playing, start it
+				if (gOverlayBar && !gOverlayBar->musicPlaying())
 				{
-					gAudiop->startInternetStream(LLViewerParcelMgr::getInstance()->getAgentParcel()->getMusicURL());
+					LLOverlayBar::toggleMusicPlay(NULL);
 				}
 			}
 		}
 		else
 		{
-			gAudiop->stopInternetStream();
+			// if music is playing, stop it.
+			if (gOverlayBar && gOverlayBar->musicPlaying())
+				{
+					LLOverlayBar::toggleMusicPlay(NULL);
+				}
+
 		}
 	}
 	return true;
diff --git a/indra/newview/llviewerjoystick.cpp b/indra/newview/llviewerjoystick.cpp
index 652e50e20c58a10ed95ef9ec3b417c481998c68f..9f7e4d338b55ca8d59d0b8d5abbefa0b7fec1c61 100644
--- a/indra/newview/llviewerjoystick.cpp
+++ b/indra/newview/llviewerjoystick.cpp
@@ -992,6 +992,13 @@ void LLViewerJoystick::scanJoystick()
 #endif
 	updateStatus();
 
+	// App focus check Needs to happen AFTER updateStatus in case the joystick
+	// is not centred when the app loses focus.
+	if (!gFocusMgr.getAppHasFocus())
+	{
+		return;
+	}
+
 	static long toggle_flycam = 0;
 
 	if (mBtn[0] == 1)
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 96a4f74927d48801e072e7aa9bbc7cf4df3ba0bd..4fd0c8dc8a3c8fe9930d8b5ff2f391794afda663 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -762,7 +762,7 @@ void init_client_menu(LLMenuGL* menu)
 	/*menu->append(new LLMenuItemCallGL("Reload settings/colors", 
 					&handle_reload_settings, NULL, NULL));*/
 	menu->append(new LLMenuItemCallGL("Reload personal setting overrides", 
-		&reload_personal_settings_overrides, NULL, NULL, KEY_F2, MASK_CONTROL|MASK_SHIFT));
+		&reload_personal_settings_overrides, NULL, NULL, KEY_F12, MASK_CONTROL|MASK_SHIFT));
 
 	sub_menu = new LLMenuGL("HUD Info");
 	{
@@ -1084,94 +1084,95 @@ void init_debug_rendering_menu(LLMenuGL* menu)
 	//
 	sub_menu = new LLMenuGL("Types");
 	menu->appendMenu(sub_menu);
-
+	
 	sub_menu->append(new LLMenuItemCheckGL("Simple",
 											&LLPipeline::toggleRenderTypeControl, NULL,
 											&LLPipeline::hasRenderTypeControl,
-											(void*)LLPipeline::RENDER_TYPE_SIMPLE,	'1', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
+											(void*)LLPipeline::RENDER_TYPE_SIMPLE,	'1', MASK_ALT|MASK_SHIFT));
 	sub_menu->append(new LLMenuItemCheckGL("Alpha",
 											&LLPipeline::toggleRenderTypeControl, NULL,
 											&LLPipeline::hasRenderTypeControl,
-											(void*)LLPipeline::RENDER_TYPE_ALPHA, '2', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
+											(void*)LLPipeline::RENDER_TYPE_ALPHA, '2', MASK_ALT|MASK_SHIFT));
 	sub_menu->append(new LLMenuItemCheckGL("Tree",
 											&LLPipeline::toggleRenderTypeControl, NULL,
 											&LLPipeline::hasRenderTypeControl,
-											(void*)LLPipeline::RENDER_TYPE_TREE, '3', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
+											(void*)LLPipeline::RENDER_TYPE_TREE, '3', MASK_ALT|MASK_SHIFT));
 	sub_menu->append(new LLMenuItemCheckGL("Character",
 											&LLPipeline::toggleRenderTypeControl, NULL,
 											&LLPipeline::hasRenderTypeControl,
-											(void*)LLPipeline::RENDER_TYPE_AVATAR, '4', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
+											(void*)LLPipeline::RENDER_TYPE_AVATAR, '4', MASK_ALT|MASK_SHIFT));
 	sub_menu->append(new LLMenuItemCheckGL("SurfacePatch",
 											&LLPipeline::toggleRenderTypeControl, NULL,
 											&LLPipeline::hasRenderTypeControl,
-											(void*)LLPipeline::RENDER_TYPE_TERRAIN, '5', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
+											(void*)LLPipeline::RENDER_TYPE_TERRAIN, '5', MASK_ALT|MASK_SHIFT));
 	sub_menu->append(new LLMenuItemCheckGL("Sky",
 											&LLPipeline::toggleRenderTypeControl, NULL,
 											&LLPipeline::hasRenderTypeControl,
-											(void*)LLPipeline::RENDER_TYPE_SKY, '6', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
+											(void*)LLPipeline::RENDER_TYPE_SKY, '6', MASK_ALT|MASK_SHIFT));
 	sub_menu->append(new LLMenuItemCheckGL("Water",
 											&LLPipeline::toggleRenderTypeControl, NULL,
 											&LLPipeline::hasRenderTypeControl,
-											(void*)LLPipeline::RENDER_TYPE_WATER, '7', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
+											(void*)LLPipeline::RENDER_TYPE_WATER, '7', MASK_ALT|MASK_SHIFT));
 	sub_menu->append(new LLMenuItemCheckGL("Ground",
 											&LLPipeline::toggleRenderTypeControl, NULL,
 											&LLPipeline::hasRenderTypeControl,
-											(void*)LLPipeline::RENDER_TYPE_GROUND, '8', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
+											(void*)LLPipeline::RENDER_TYPE_GROUND, '8', MASK_ALT|MASK_SHIFT));
 	sub_menu->append(new LLMenuItemCheckGL("Volume",
 											&LLPipeline::toggleRenderTypeControl, NULL,
 											&LLPipeline::hasRenderTypeControl,
-											(void*)LLPipeline::RENDER_TYPE_VOLUME, '9', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
+											(void*)LLPipeline::RENDER_TYPE_VOLUME, '9', MASK_ALT|MASK_SHIFT));
 	sub_menu->append(new LLMenuItemCheckGL("Grass",
 											&LLPipeline::toggleRenderTypeControl, NULL,
 											&LLPipeline::hasRenderTypeControl,
-											(void*)LLPipeline::RENDER_TYPE_GRASS, '0', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
+											(void*)LLPipeline::RENDER_TYPE_GRASS, '0', MASK_ALT|MASK_SHIFT));
 	sub_menu->append(new LLMenuItemCheckGL("Clouds",
 											&LLPipeline::toggleRenderTypeControl, NULL,
 											&LLPipeline::hasRenderTypeControl,
-											(void*)LLPipeline::RENDER_TYPE_CLOUDS, '-', MASK_CONTROL|MASK_ALT| MASK_SHIFT));
+											(void*)LLPipeline::RENDER_TYPE_CLOUDS, '-', MASK_ALT|MASK_SHIFT));
 	sub_menu->append(new LLMenuItemCheckGL("Particles",
 											&LLPipeline::toggleRenderTypeControl, NULL,
 											&LLPipeline::hasRenderTypeControl,
-											(void*)LLPipeline::RENDER_TYPE_PARTICLES, '=', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
+											(void*)LLPipeline::RENDER_TYPE_PARTICLES, '`', MASK_ALT|MASK_SHIFT));
 	sub_menu->append(new LLMenuItemCheckGL("Bump",
 											&LLPipeline::toggleRenderTypeControl, NULL,
 											&LLPipeline::hasRenderTypeControl,
-											(void*)LLPipeline::RENDER_TYPE_BUMP, '\\', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
+											(void*)LLPipeline::RENDER_TYPE_BUMP, '\\', MASK_ALT|MASK_SHIFT));
+
 	sub_menu->createJumpKeys();
 	sub_menu = new LLMenuGL("Features");
 	menu->appendMenu(sub_menu);
 	sub_menu->append(new LLMenuItemCheckGL("UI",
 											&LLPipeline::toggleRenderDebugFeature, NULL,
 											&LLPipeline::toggleRenderDebugFeatureControl,
-											(void*)LLPipeline::RENDER_DEBUG_FEATURE_UI, KEY_F1, MASK_ALT|MASK_CONTROL));
+											(void*)LLPipeline::RENDER_DEBUG_FEATURE_UI, KEY_F1, MASK_CONTROL|MASK_SHIFT));
 	sub_menu->append(new LLMenuItemCheckGL("Selected",
 											&LLPipeline::toggleRenderDebugFeature, NULL,
 											&LLPipeline::toggleRenderDebugFeatureControl,
-											(void*)LLPipeline::RENDER_DEBUG_FEATURE_SELECTED, KEY_F2, MASK_ALT|MASK_CONTROL));
+											(void*)LLPipeline::RENDER_DEBUG_FEATURE_SELECTED, KEY_F2, MASK_CONTROL|MASK_SHIFT));
 	sub_menu->append(new LLMenuItemCheckGL("Highlighted",
 											&LLPipeline::toggleRenderDebugFeature, NULL,
 											&LLPipeline::toggleRenderDebugFeatureControl,
-											(void*)LLPipeline::RENDER_DEBUG_FEATURE_HIGHLIGHTED, KEY_F3, MASK_ALT|MASK_CONTROL));
+											(void*)LLPipeline::RENDER_DEBUG_FEATURE_HIGHLIGHTED, KEY_F3, MASK_CONTROL|MASK_SHIFT));
 	sub_menu->append(new LLMenuItemCheckGL("Dynamic Textures",
 											&LLPipeline::toggleRenderDebugFeature, NULL,
 											&LLPipeline::toggleRenderDebugFeatureControl,
-											(void*)LLPipeline::RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES, KEY_F4, MASK_ALT|MASK_CONTROL));
+											(void*)LLPipeline::RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES, KEY_F4, MASK_CONTROL|MASK_SHIFT));
 	sub_menu->append(new LLMenuItemCheckGL( "Foot Shadows", 
 											&LLPipeline::toggleRenderDebugFeature, NULL,
 											&LLPipeline::toggleRenderDebugFeatureControl,
-											(void*)LLPipeline::RENDER_DEBUG_FEATURE_FOOT_SHADOWS, KEY_F5, MASK_ALT|MASK_CONTROL));
+											(void*)LLPipeline::RENDER_DEBUG_FEATURE_FOOT_SHADOWS, KEY_F5, MASK_CONTROL|MASK_SHIFT));
 	sub_menu->append(new LLMenuItemCheckGL("Fog",
 											&LLPipeline::toggleRenderDebugFeature, NULL,
 											&LLPipeline::toggleRenderDebugFeatureControl,
-											(void*)LLPipeline::RENDER_DEBUG_FEATURE_FOG, KEY_F6, MASK_ALT|MASK_CONTROL));
+											(void*)LLPipeline::RENDER_DEBUG_FEATURE_FOG, KEY_F6, MASK_CONTROL|MASK_SHIFT));
 	sub_menu->append(new LLMenuItemCheckGL("Test FRInfo",
 											&LLPipeline::toggleRenderDebugFeature, NULL,
 											&LLPipeline::toggleRenderDebugFeatureControl,
-											(void*)LLPipeline::RENDER_DEBUG_FEATURE_FR_INFO, KEY_F8, MASK_ALT|MASK_CONTROL));
+											(void*)LLPipeline::RENDER_DEBUG_FEATURE_FR_INFO, KEY_F8, MASK_CONTROL|MASK_SHIFT));
 	sub_menu->append(new LLMenuItemCheckGL( "Flexible Objects", 
 											&LLPipeline::toggleRenderDebugFeature, NULL,
 											&LLPipeline::toggleRenderDebugFeatureControl,
-											(void*)LLPipeline::RENDER_DEBUG_FEATURE_FLEXIBLE, KEY_F9, MASK_ALT|MASK_CONTROL));
+											(void*)LLPipeline::RENDER_DEBUG_FEATURE_FLEXIBLE, KEY_F9, MASK_CONTROL|MASK_SHIFT));
 	sub_menu->createJumpKeys();
 
 	/////////////////////////////
@@ -1328,8 +1329,11 @@ void init_debug_avatar_menu(LLMenuGL* menu)
 	menu->appendMenu(sub_menu);
 
 	sub_menu = new LLMenuGL("Character Tests");
-	sub_menu->append(new LLMenuItemToggleGL("Go Away/AFK When Idle",
-		&gAllowIdleAFK));
+	sub_menu->append(new LLMenuItemCheckGL("Go Away/AFK When Idle",
+										   menu_toggle_control,
+										   NULL,
+										   menu_check_control,
+										   (void*)"AllowIdleAFK"));
 
 	sub_menu->append(new LLMenuItemCallGL("Appearance To XML", 
 		&LLVOAvatar::dumpArchetypeXML));
@@ -4730,25 +4734,29 @@ class LLWorldSetBusy : public view_listener_t
 	}
 };
 
+bool can_create_landmark()
+{
+	BOOL can = FALSE;
+	
+	LLParcel* agent_parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
+	if (agent_parcel)
+	{
+
+		if (agent_parcel->getAllowLandmark()
+			|| LLViewerParcelMgr::isParcelOwnedByAgent(agent_parcel, GP_LAND_ALLOW_LANDMARK))
+		{
+			can = TRUE;
+		}
+	}
+
+	return can;
+}
 
 class LLWorldCreateLandmark : public view_listener_t
 {
 	bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
 	{
-		LLViewerRegion* agent_region = gAgent.getRegion();
-		if(!agent_region)
-		{
-			llwarns << "No agent region" << llendl;
-			return true;
-		}
-		LLParcel* agent_parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
-		if (!agent_parcel)
-		{
-			llwarns << "No agent parcel" << llendl;
-			return true;
-		}
-		if (!agent_parcel->getAllowLandmark()
-			&& !LLViewerParcelMgr::isParcelOwnedByAgent(agent_parcel, GP_LAND_ALLOW_LANDMARK))
+		if (!can_create_landmark())
 		{
 			LLNotifications::instance().add("CannotCreateLandmarkNotOwner");
 			return true;
@@ -6284,25 +6292,28 @@ class LLToolsEnableTakeCopy : public view_listener_t
 		bool all_valid = false;
 		if (LLSelectMgr::getInstance())
 		{
-			all_valid = true;
+			if (!LLSelectMgr::getInstance()->getSelection()->isEmpty())
+			{
+				all_valid = true;
 #ifndef HACKED_GODLIKE_VIEWER
 # ifdef TOGGLE_HACKED_GODLIKE_VIEWER
-			if (LLViewerLogin::getInstance()->isInProductionGrid()
-                || !gAgent.isGodlike())
+				if (LLViewerLogin::getInstance()->isInProductionGrid()
+					|| !gAgent.isGodlike())
 # endif
-			{
-				struct f : public LLSelectedObjectFunctor
 				{
-					virtual bool apply(LLViewerObject* obj)
+					struct f : public LLSelectedObjectFunctor
 					{
-						return (!obj->permCopy() || obj->isAttachment());
-					}
-				} func;
-				const bool firstonly = true;
-				bool any_invalid = LLSelectMgr::getInstance()->getSelection()->applyToRootObjects(&func, firstonly);
-				all_valid = !any_invalid;
-			}
+						virtual bool apply(LLViewerObject* obj)
+						{
+							return (!obj->permCopy() || obj->isAttachment());
+						}
+					} func;
+					const bool firstonly = true;
+					bool any_invalid = LLSelectMgr::getInstance()->getSelection()->applyToRootObjects(&func, firstonly);
+					all_valid = !any_invalid;
+				}
 #endif // HACKED_GODLIKE_VIEWER
+			}
 		}
 
 		gMenuHolder->findControl(userdata["control"].asString())->setValue(all_valid);
@@ -6496,9 +6507,10 @@ class LLWorldEnableCreateLandmark : public view_listener_t
 {
 	bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
 	{
-		bool new_value = gAgent.isGodlike() || 
-			(gAgent.getRegion() && gAgent.getRegion()->getAllowLandmark());
+		bool new_value = can_create_landmark();
+		
 		gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
+		
 		return true;
 	}
 };
@@ -7544,8 +7556,8 @@ void initialize_menus()
 	addMenu(new LLToolsEnableUnlink(), "Tools.EnableUnlink");
 	addMenu(new LLToolsEnableBuyOrTake(), "Tools.EnableBuyOrTake");
 	addMenu(new LLToolsEnableTakeCopy(), "Tools.EnableTakeCopy");
-	addMenu(new LLToolsEnableSaveToInventory(), "Tools.SaveToInventory");
-	addMenu(new LLToolsEnableSaveToObjectInventory(), "Tools.SaveToObjectInventory");
+	addMenu(new LLToolsEnableSaveToInventory(), "Tools.EnableSaveToInventory");
+	addMenu(new LLToolsEnableSaveToObjectInventory(), "Tools.EnableSaveToObjectInventory");
 
 	/*addMenu(new LLToolsVisibleBuyObject(), "Tools.VisibleBuyObject");
 	addMenu(new LLToolsVisibleTakeObject(), "Tools.VisibleTakeObject");*/
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 2925916e2ac6396c7a679789ff42e3fe281951d5..5240fd3211a26043a30adbdcd7bfab0af2d355c5 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -658,7 +658,7 @@ void upload_new_resource(const std::string& src_filename, std::string name,
          {	 	
                  // read in the file header	 	
                  char buf[16384];		/* Flawfinder: ignore */ 	
-                 S32 read;		/* Flawfinder: ignore */	 	
+                 size_t readbytes;
                  S32  version;	 	
                  if (fscanf(in, "LindenResource\nversion %d\n", &version))	 	
                  {	 	
@@ -741,9 +741,9 @@ void upload_new_resource(const std::string& src_filename, std::string name,
                  LLFILE* out = LLFile::fopen(filename, "wb");		/* Flawfinder: ignore */	
                  if (out)	 	
                  {	 	
-                         while((read = fread(buf, 1, 16384, in)))		/* Flawfinder: ignore */	 	
+                         while((readbytes = fread(buf, 1, 16384, in)))		/* Flawfinder: ignore */	 	
                          {	 	
-							 if (fwrite(buf, 1, read, out) != read)
+							 if (fwrite(buf, 1, readbytes, out) != readbytes)
 							 {
 								 llwarns << "Short write" << llendl;
 							 }
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 6ffb19bcdfcb240c15c9886de3d194964602aed3..088ba62d0cde251376873d0b7309cd2a1e336562 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -1343,27 +1343,6 @@ void inventory_offer_handler(LLOfferInfo* info, BOOL from_task)
 	LLNotifications::instance().add(p);
 }
 
-
-bool group_vote_callback(const LLSD& notification, const LLSD& response)
-{
-	LLUUID group_id = notification["payload"]["group_id"].asUUID();
-	S32 option = LLNotification::getSelectedOption(notification, response);
-	switch(option)
-	{
-	case 0:
-		// Vote Now
-		// Open up the voting tab
-		LLFloaterGroupInfo::showFromUUID(group_id, "voting_tab");
-		break;
-	default:
-		// Vote Later or
-		// close button
-		break;
-	}
-	return false;
-}
-static LLNotificationFunctorRegistration group_vote_callback_reg("GroupVote", group_vote_callback);
-
 bool lure_callback(const LLSD& notification, const LLSD& response)
 {
 	S32 option = 0;
@@ -1514,7 +1493,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
 				// initiated by the other party) then...
 				std::string my_name;
 				gAgent.buildFullname(my_name);
-				std::string response = gSavedPerAccountSettings.getText("BusyModeResponse");
+				std::string response = gSavedPerAccountSettings.getString("BusyModeResponse2");
 				pack_instant_message(
 					gMessageSystem,
 					gAgent.getID(),
@@ -1847,17 +1826,12 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
 		LLNotifications::instance().add("InventoryDeclined", args);
 		break;
 	}
+	// TODO: _DEPRECATED suffix as part of vote removal - DEV-24856
 	case IM_GROUP_VOTE:
-	{
-		LLSD args;
-		args["NAME"] = name;
-		args["MESSAGE"] = message;
-
-		LLSD payload;
-		payload["group_id"] = session_id;
-		LLNotifications::instance().add("GroupVote", args, payload);
-	}
-	break;
+		{
+			LL_WARNS("Messaging") << "Received IM: IM_GROUP_VOTE_DEPRECATED" << LL_ENDL;
+		}
+		break;
 
 	case IM_GROUP_ELECTION_DEPRECATED:
 	{
@@ -2113,7 +2087,7 @@ void busy_message (LLMessageSystem* msg, LLUUID from_id)
 	{
 		std::string my_name;
 		gAgent.buildFullname(my_name);
-		std::string response = gSavedPerAccountSettings.getText("BusyModeResponse");
+		std::string response = gSavedPerAccountSettings.getString("BusyModeResponse2");
 		pack_instant_message(
 			gMessageSystem,
 			gAgent.getID(),
@@ -4362,11 +4336,11 @@ void mean_name_callback(const LLUUID &id, const std::string& first, const std::s
 		return;
 	}
 
-	static const int max_collision_list_size = 20;
+	static const U32 max_collision_list_size = 20;
 	if (gMeanCollisionList.size() > max_collision_list_size)
 	{
 		mean_collision_list_t::iterator iter = gMeanCollisionList.begin();
-		for (S32 i=0; i<max_collision_list_size; i++) iter++;
+		for (U32 i=0; i<max_collision_list_size; i++) iter++;
 		for_each(iter, gMeanCollisionList.end(), DeletePointer());
 		gMeanCollisionList.erase(iter, gMeanCollisionList.end());
 	}
@@ -5217,17 +5191,22 @@ static LLNotificationFunctorRegistration callback_script_dialog_reg_2("ScriptDia
 void process_script_dialog(LLMessageSystem* msg, void**)
 {
 	S32 i;
-
 	LLSD payload;
 
+	LLUUID object_id;
+	msg->getUUID("Data", "ObjectID", object_id);
+
+	if (LLMuteList::getInstance()->isMuted(object_id))
+	{
+		return;
+	}
+
 	std::string message; 
 	std::string first_name;
 	std::string last_name;
 	std::string title;
 
-	LLUUID object_id;
 	S32 chat_channel;
-	msg->getUUID("Data", "ObjectID", object_id);
 	msg->getString("Data", "FirstName", first_name);
 	msg->getString("Data", "LastName", last_name);
 	msg->getString("Data", "ObjectName", title);
@@ -5526,25 +5505,18 @@ void onCovenantLoadComplete(LLVFS *vfs,
 		
 		S32 file_length = file.getSize();
 		
-		char* buffer = new char[file_length+1];
-		if (buffer == NULL)
-		{
-			LL_ERRS("Messaging") << "Memory Allocation failed" << LL_ENDL;
-			return;
-		}
-
-		file.read((U8*)buffer, file_length);		/* Flawfinder: ignore */
-		
+		std::vector<char> buffer(file_length+1);
+		file.read((U8*)&buffer[0], file_length);		
 		// put a EOS at the end
-		buffer[file_length] = 0;
+		buffer[file_length] = '\0';
 		
-		if( (file_length > 19) && !strncmp( buffer, "Linden text version", 19 ) )
+		if( (file_length > 19) && !strncmp( &buffer[0], "Linden text version", 19 ) )
 		{
 			LLViewerTextEditor* editor =
 				new LLViewerTextEditor(std::string("temp"),
 						       LLRect(0,0,0,0),
 						       file_length+1);
-			if( !editor->importBuffer( buffer, file_length+1 ) )
+			if( !editor->importBuffer( &buffer[0], file_length+1 ) )
 			{
 				LL_WARNS("Messaging") << "Problem importing estate covenant." << LL_ENDL;
 				covenant_text = "Problem importing estate covenant.";
@@ -5554,7 +5526,6 @@ void onCovenantLoadComplete(LLVFS *vfs,
 				// Version 0 (just text, doesn't include version number)
 				covenant_text = editor->getText();
 			}
-			delete[] buffer;
 			delete editor;
 		}
 		else
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index d7313c1653343463c7f29a001d0a6026211f6b54..32c89e158cbd9377048f2108e5cf8fad071c1e7a 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -2441,7 +2441,11 @@ void LLViewerObject::processTaskInv(LLMessageSystem* msg, void** user_data)
 	msg->getS16Fast(_PREHASH_InventoryData, _PREHASH_Serial, object->mInventorySerialNum);
 	LLFilenameAndTask* ft = new LLFilenameAndTask;
 	ft->mTaskID = task_id;
-	msg->getStringFast(_PREHASH_InventoryData, _PREHASH_Filename, ft->mFilename);
+
+	std::string unclean_filename;
+	msg->getStringFast(_PREHASH_InventoryData, _PREHASH_Filename, unclean_filename);
+	ft->mFilename = LLDir::getScrubbedFileName(unclean_filename);
+	
 	if(ft->mFilename.empty())
 	{
 		lldebugs << "Task has no inventory" << llendl;
diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp
index 194029398d72751321b7fb67356b6baac4b9d677..07203ce0f4f3ecbe64ab3aa5819ab4fedeb1e916 100644
--- a/indra/newview/llviewerparcelmgr.cpp
+++ b/indra/newview/llviewerparcelmgr.cpp
@@ -650,10 +650,9 @@ BOOL LLViewerParcelMgr::agentCanBuild() const
 {
 	if (mAgentParcel)
 	{
-		return (gAgent.isGodlike()
-				|| (mAgentParcel->allowModifyBy(
-						gAgent.getID(),
-						gAgent.getGroupID())));
+		return (gAgent.isGodlike() ||
+				(mAgentParcel->allowModifyBy(gAgent.getID(), gAgent.getGroupID())) ||
+				(isParcelOwnedByAgent(mAgentParcel, GP_LAND_ALLOW_CREATE)));
 	}
 	else
 	{
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 750151ea2d46f38b52c1b11cc2f638b1e1b4afac..44d0304533fcc04c6f79cb82df41e562ac51159d 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -318,7 +318,7 @@ void LLViewerRegion::loadCache()
 
 	LLUUID cache_id;
 	nread = fread(&cache_id.mData, 1, UUID_BYTES, fp);
-	if (nread != UUID_BYTES || mCacheID != cache_id)
+	if (nread != (size_t)UUID_BYTES || mCacheID != cache_id)
 	{
 		llinfos << "Cache ID doesn't match for this region, discarding"
 			<< llendl;
@@ -394,7 +394,7 @@ void LLViewerRegion::saveCache()
 	}
 
 	// write the cache id for this sim
-	if (fwrite(&mCacheID.mData, 1, UUID_BYTES, fp) != UUID_BYTES)
+	if (fwrite(&mCacheID.mData, 1, UUID_BYTES, fp) != (size_t)UUID_BYTES)
 	{
 		llwarns << "Short write" << llendl;
 	}
@@ -1387,11 +1387,12 @@ void LLViewerRegion::unpackRegionHandshake()
 
 void LLViewerRegion::setSeedCapability(const std::string& url)
 {
-  if (getCapability("Seed") == url)
+	if (getCapability("Seed") == url)
     {
-      llwarns << "Ignoring duplicate seed capability" << llendl;
-      return;
+		// llwarns << "Ignoring duplicate seed capability" << llendl;
+		return;
     }
+	
 	delete mEventPoll;
 	mEventPoll = NULL;
 	
diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp
index 1fd31a013abf766282af8e9c8a52b07e943b586e..728509e39ca671d7e94c4873c9a22e825037cd1e 100644
--- a/indra/newview/llviewertexteditor.cpp
+++ b/indra/newview/llviewertexteditor.cpp
@@ -894,51 +894,9 @@ BOOL LLViewerTextEditor::handleHover(S32 x, S32 y, MASK mask)
 
 BOOL LLViewerTextEditor::handleMouseUp(S32 x, S32 y, MASK mask)
 {
-	BOOL	handled = FALSE;
-
-	// let scrollbar have first dibs
-	handled = LLView::childrenHandleMouseUp(x, y, mask) != NULL;
-
-	// Used to enable I Agree checkbox if the user scrolled through entire text
-	BOOL was_scrolled_to_bottom = (mScrollbar->getDocPos() == mScrollbar->getDocPosMax());
-	if (mOnScrollEndCallback && was_scrolled_to_bottom)
-	{
-		mOnScrollEndCallback(mOnScrollEndData);
-	}
-
-	if( !handled && mTakesNonScrollClicks)
-	{
-		if( mIsSelecting )
-		{
-			// Finish selection
-			if( y > getTextRect().mTop )
-			{
-				mScrollbar->setDocPos( mScrollbar->getDocPos() - 1 );
-			}
-			else
-			if( y < getTextRect().mBottom )
-			{
-				mScrollbar->setDocPos( mScrollbar->getDocPos() + 1 );
-			}
-			
-			setCursorAtLocalPos( x, y, TRUE );
-			endSelection();
-
-			updateScrollFromCursor();
-		}
-		
-		if( !hasSelection() )
-		{
-			handleMouseUpOverSegment( x, y, mask );
-		}
-
-		handled = TRUE;
-	}
-
-	// Delay cursor flashing
-	resetKeystrokeTimer();
+	BOOL handled = FALSE;
 
-	if( hasMouseCapture()  )
+	if( hasMouseCapture() )
 	{
 		if (mDragItem)
 		{
@@ -957,8 +915,15 @@ BOOL LLViewerTextEditor::handleMouseUp(S32 x, S32 y, MASK mask)
 			}
 		}
 		mDragItem = NULL;
-		gFocusMgr.setMouseCapture( NULL );
-		handled = TRUE;
+	}
+
+	handled = LLTextEditor::handleMouseUp(x,y,mask);
+
+	// Used to enable I Agree checkbox if the user scrolled through entire text
+	BOOL was_scrolled_to_bottom = (mScrollbar->getDocPos() == mScrollbar->getDocPosMax());
+	if (mOnScrollEndCallback && was_scrolled_to_bottom)
+	{
+		mOnScrollEndCallback(mOnScrollEndData);
 	}
 
 	return handled;
@@ -1000,6 +965,24 @@ BOOL LLViewerTextEditor::handleRightMouseDown(S32 x, S32 y, MASK mask)
 	return handled;
 }
 
+BOOL LLViewerTextEditor::handleMiddleMouseDown(S32 x, S32 y, MASK mask)
+{
+	BOOL	handled = FALSE;
+	handled = childrenHandleMiddleMouseDown(x, y, mask) != NULL;
+	if (!handled)
+	{
+		handled = LLTextEditor::handleMiddleMouseDown(x, y, mask);
+	}
+	return handled;
+}
+
+BOOL LLViewerTextEditor::handleMiddleMouseUp(S32 x, S32 y, MASK mask)
+{
+	BOOL handled = childrenHandleMiddleMouseUp(x, y, mask) != NULL;
+
+	return handled;
+}
+
 BOOL LLViewerTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
 {
 	BOOL	handled = FALSE;
@@ -1022,7 +1005,6 @@ BOOL LLViewerTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
 				}
 			}
 		}
-
 	
 		setCursorAtLocalPos( x, y, FALSE );
 		deselect();
@@ -1060,6 +1042,9 @@ BOOL LLViewerTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
 		// delay cursor flashing
 		resetKeystrokeTimer();
 
+		// take selection to 'primary' clipboard
+		updatePrimary();
+
 		handled = TRUE;
 	}
 	return handled;
diff --git a/indra/newview/llviewertexteditor.h b/indra/newview/llviewertexteditor.h
index 0aa9164c90f582bb52a4244db20b547360b1b438..1ed60a57feb5cfb07502cce4821bc957a3572e2a 100644
--- a/indra/newview/llviewertexteditor.h
+++ b/indra/newview/llviewertexteditor.h
@@ -59,6 +59,8 @@ public:
 	// mousehandler overrides
 	virtual BOOL	handleMouseDown(S32 x, S32 y, MASK mask);
 	virtual BOOL	handleMouseUp(S32 x, S32 y, MASK mask);
+	virtual BOOL	handleMiddleMouseDown(S32 x, S32 y, MASK mask);
+	virtual BOOL	handleMiddleMouseUp(S32 x, S32 y, MASK mask);
 	virtual BOOL	handleRightMouseDown(S32 x, S32 y, MASK mask);
 	virtual BOOL	handleHover(S32 x, S32 y, MASK mask);
 	virtual BOOL	handleDoubleClick(S32 x, S32 y, MASK mask );
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 71406d268d58cd431c3eae965f7a29ccacc3adf6..26ddf213d29ff9b7c6db12d49ec7f58f00a21de8 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -589,19 +589,46 @@ bool LLViewerWindow::shouldShowToolTipFor(LLMouseHandler *mh)
 	return false;
 }
 
-BOOL LLViewerWindow::handleMouseDown(LLWindow *window,  LLCoordGL pos, MASK mask)
+BOOL LLViewerWindow::handleAnyMouseClick(LLWindow *window,  LLCoordGL pos, MASK mask, LLMouseHandler::EClickType clicktype, BOOL down)
 {
+	std::string buttonname;
+	std::string buttonstatestr; 
+	BOOL handled = FALSE;	
 	S32 x = pos.mX;
 	S32 y = pos.mY;
 	x = llround((F32)x / mDisplayScale.mV[VX]);
 	y = llround((F32)y / mDisplayScale.mV[VY]);
 
-	LLView::sMouseHandlerMessage.clear();
-
-	if (gDebugClicks)
+	if (down)
+	{
+		buttonstatestr = "down" ;
+	}
+	else
 	{
-		llinfos << "ViewerWindow left mouse down at " << x << "," << y << llendl;
+		buttonstatestr = "up" ;
 	}
+	
+	switch (clicktype)
+	{
+	case LLMouseHandler::CLICK_LEFT:
+		mLeftMouseDown = down;
+		buttonname = "Left";
+		break;
+	case LLMouseHandler::CLICK_RIGHT:
+		mRightMouseDown = down;
+		buttonname = "Right";
+		break;
+	case LLMouseHandler::CLICK_MIDDLE:
+		mMiddleMouseDown = down;
+		buttonname = "Middle";
+		break;
+	case LLMouseHandler::CLICK_DOUBLELEFT:
+		mLeftMouseDown = down;
+		buttonname = "Left Double Click";
+		break;
+	}
+	
+	LLView::sMouseHandlerMessage.clear();
 
 	if (gMenuBarView)
 	{
@@ -609,18 +636,24 @@ BOOL LLViewerWindow::handleMouseDown(LLWindow *window,  LLCoordGL pos, MASK mask
 		gMenuBarView->resetMenuTrigger();
 	}
 
-	mLeftMouseDown = TRUE;
+	if (gDebugClicks)
+	{	
+		llinfos << "ViewerWindow " << buttonname << " mouse " << buttonstatestr << " at " << x << "," << y << llendl;
+	}
 
-	// Make sure we get a coresponding mouseup event, even if the mouse leaves the window
-	mWindow->captureMouse();
+	// Make sure we get a corresponding mouseup event, even if the mouse leaves the window
+	if (down)
+		mWindow->captureMouse();
+	else
+		mWindow->releaseMouse();
 
 	// Indicate mouse was active
 	gMouseIdleTimer.reset();
 
 	// Hide tooltips on mousedown
-	mToolTipBlocked = TRUE;
+	mToolTipBlocked = down;
 
-	// Also hide hover info on mousedown
+	// Also hide hover info on mousedown/mouseup
 	if (gHoverView)
 	{
 		gHoverView->cancelHover();
@@ -629,7 +662,7 @@ BOOL LLViewerWindow::handleMouseDown(LLWindow *window,  LLCoordGL pos, MASK mask
 	// Don't let the user move the mouse out of the window until mouse up.
 	if( LLToolMgr::getInstance()->getCurrentTool()->clipMouseWhenDown() )
 	{
-		mWindow->setMouseClipping(TRUE);
+		mWindow->setMouseClipping(down);
 	}
 
 	LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture();
@@ -640,10 +673,9 @@ BOOL LLViewerWindow::handleMouseDown(LLWindow *window,  LLCoordGL pos, MASK mask
 		mouse_captor->screenPointToLocal( x, y, &local_x, &local_y );
 		if (LLView::sDebugMouseHandling)
 		{
-			llinfos << "Left Mouse Down handled by captor " << mouse_captor->getName() << llendl;
+			llinfos << buttonname << " Mouse " << buttonstatestr << " handled by captor " << mouse_captor->getName() << llendl;
 		}
-
-		return mouse_captor->handleMouseDown(local_x, local_y, mask);
+		return mouse_captor->handleAnyMouseClick(local_x, local_y, mask, clicktype, down);
 	}
 
 	// Topmost view gets a chance before the hierarchy
@@ -652,215 +684,99 @@ BOOL LLViewerWindow::handleMouseDown(LLWindow *window,  LLCoordGL pos, MASK mask
 	{
 		S32 local_x, local_y;
 		top_ctrl->screenPointToLocal( x, y, &local_x, &local_y );
-		if (top_ctrl->pointInView(local_x, local_y))
+		if (down)
 		{
-			return top_ctrl->handleMouseDown(local_x, local_y, mask);
+			if (top_ctrl->pointInView(local_x, local_y))
+			{
+				return top_ctrl->handleAnyMouseClick(local_x, local_y, mask, clicktype, down)	;
+			}
+			else
+			{
+				gFocusMgr.setTopCtrl(NULL);
+			}
 		}
 		else
 		{
-			gFocusMgr.setTopCtrl(NULL);
+			handled = top_ctrl->pointInView(local_x, local_y) && top_ctrl->handleMouseUp(local_x, local_y, mask);
 		}
 	}
 
 	// Give the UI views a chance to process the click
-	if( mRootView->handleMouseDown(x, y, mask) )
+	if( mRootView->handleAnyMouseClick(x, y, mask, clicktype, down) )
 	{
 		if (LLView::sDebugMouseHandling)
 		{
-			llinfos << "Left Mouse Down" << LLView::sMouseHandlerMessage << llendl;
+			llinfos << buttonname << " Mouse " << buttonstatestr << " " << LLView::sMouseHandlerMessage << llendl;
 		}
 		return TRUE;
 	}
 	else if (LLView::sDebugMouseHandling)
 	{
-		llinfos << "Left Mouse Down not handled by view" << llendl;
-	}
-
-	if (gDisconnected)
-	{
-		return FALSE;
+		llinfos << buttonname << " Mouse " << buttonstatestr << " not handled by view" << llendl;
 	}
 
-	if(LLToolMgr::getInstance()->getCurrentTool()->handleMouseDown( x, y, mask ) )
+	if (down)
 	{
-		// This is necessary to force clicks in the world to cause edit
-		// boxes that might have keyboard focus to relinquish it, and hence
-		// cause a commit to update their value.  JC
-		gFocusMgr.setKeyboardFocus(NULL);
-		return TRUE;
-	}
-
-	return FALSE;
-}
-
-BOOL LLViewerWindow::handleDoubleClick(LLWindow *window,  LLCoordGL pos, MASK mask)
-{
-	S32 x = pos.mX;
-	S32 y = pos.mY;
-	x = llround((F32)x / mDisplayScale.mV[VX]);
-	y = llround((F32)y / mDisplayScale.mV[VY]);
-
-	LLView::sMouseHandlerMessage.clear();
-
-	if (gDebugClicks)
-	{
-		llinfos << "ViewerWindow left mouse double-click at " << x << "," << y << llendl;
-	}
-
-	mLeftMouseDown = TRUE;
-
-	// Hide tooltips
-	if( mToolTip )
-	{
-		mToolTip->setVisible( FALSE );
-	}
-
-	LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture();
-	if( mouse_captor )
-	{
-		S32 local_x;
-		S32 local_y;
-		mouse_captor->screenPointToLocal( x, y, &local_x, &local_y );
-		if (LLView::sDebugMouseHandling)
+		if (gDisconnected)
 		{
-			llinfos << "Left Mouse Down handled by captor " << mouse_captor->getName() << llendl;
+			return FALSE;
+		}
+	
+		if(LLToolMgr::getInstance()->getCurrentTool()->handleAnyMouseClick( x, y, mask, clicktype, down ) )
+		{
+			// This is necessary to force clicks in the world to cause edit
+			// boxes that might have keyboard focus to relinquish it, and hence
+			// cause a commit to update their value.  JC
+			gFocusMgr.setKeyboardFocus(NULL);
+			return TRUE;
 		}
-
-		return mouse_captor->handleDoubleClick(local_x, local_y, mask);
 	}
-
-	// Check for hit on UI.
-	LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl();
-	if (top_ctrl)
+	else
 	{
-		S32 local_x, local_y;
-		top_ctrl->screenPointToLocal( x, y, &local_x, &local_y );
-		if (top_ctrl->pointInView(local_x, local_y))
+		if( !handled )
 		{
-			return top_ctrl->handleDoubleClick(local_x, local_y, mask);
+			handled = mRootView->handleAnyMouseClick(x, y, mask, clicktype, down);
 		}
-		else
+	
+		if( !handled )
 		{
-			gFocusMgr.setTopCtrl(NULL);
+			LLTool *tool = LLToolMgr::getInstance()->getCurrentTool();
+			if (tool)
+			{
+				handled = tool->handleAnyMouseClick(x, y, mask, clicktype, down);
+			}
 		}
 	}
 
-	if (mRootView->handleDoubleClick(x, y, mask)) 
-	{
-		if (LLView::sDebugMouseHandling)
-		{
-			llinfos << "Left Mouse Down" << LLView::sMouseHandlerMessage << llendl;
-		}
-		return TRUE;
-	}
-	else if (LLView::sDebugMouseHandling)
-	{
-		llinfos << "Left Mouse Down not handled by view" << llendl;
-	}
+	// If we got this far on a down-click, it wasn't handled.
+	// Up-clicks, though, are always handled as far as the OS is concerned.
+	BOOL default_rtn = !down;
+	return default_rtn;
+}
 
-		// Why is this here?  JC 9/3/2002
-	if (gNoRender) 
-	{
-		return TRUE;
-	}
+BOOL LLViewerWindow::handleMouseDown(LLWindow *window,  LLCoordGL pos, MASK mask)
+{
+	BOOL down = TRUE;
+	return handleAnyMouseClick(window,pos,mask,LLMouseHandler::CLICK_LEFT,down);
+}
 
-	if(LLToolMgr::getInstance()->getCurrentTool()->handleDoubleClick( x, y, mask ) )
+BOOL LLViewerWindow::handleDoubleClick(LLWindow *window,  LLCoordGL pos, MASK mask)
+{
+	// try handling as a double-click first, then a single-click if that
+	// wasn't handled.
+	BOOL down = TRUE;
+	if (handleAnyMouseClick(window, pos, mask,
+				LLMouseHandler::CLICK_DOUBLELEFT, down))
 	{
 		return TRUE;
 	}
-
-	// if we got this far and nothing handled a double click, pass a normal mouse down
 	return handleMouseDown(window, pos, mask);
 }
 
 BOOL LLViewerWindow::handleMouseUp(LLWindow *window,  LLCoordGL pos, MASK mask)
 {
-	S32 x = pos.mX;
-	S32 y = pos.mY;
-	x = llround((F32)x / mDisplayScale.mV[VX]);
-	y = llround((F32)y / mDisplayScale.mV[VY]);
-
-	LLView::sMouseHandlerMessage.clear();
-
-	if (gDebugClicks)
-	{
-		llinfos << "ViewerWindow left mouse up" << llendl;
-	}
-
-	mLeftMouseDown = FALSE;
-
-	// Indicate mouse was active
-	gMouseIdleTimer.reset();
-
-	// Hide tooltips on mouseup
-	if( mToolTip )
-	{
-		mToolTip->setVisible( FALSE );
-	}
-
-	// Also hide hover info on mouseup
-	if (gHoverView)	gHoverView->cancelHover();
-
-	BOOL handled = FALSE;
-
-	mWindow->releaseMouse();
-
-	LLTool *tool = LLToolMgr::getInstance()->getCurrentTool();
-
-	if( tool->clipMouseWhenDown() )
-	{
-		mWindow->setMouseClipping(FALSE);
-	}
-
-	LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture();
-	if( mouse_captor )
-	{
-		S32 local_x;
-		S32 local_y;
-		mouse_captor->screenPointToLocal( x, y, &local_x, &local_y );
-		if (LLView::sDebugMouseHandling)
-		{
-			llinfos << "Left Mouse Up handled by captor " << mouse_captor->getName() << llendl;
-		}
-
-		return mouse_captor->handleMouseUp(local_x, local_y, mask);
-	}
-
-	LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl();
-	if (top_ctrl)
-	{
-		S32 local_x, local_y;
-		top_ctrl->screenPointToLocal( x, y, &local_x, &local_y );
-		handled = top_ctrl->pointInView(local_x, local_y) && top_ctrl->handleMouseUp(local_x, local_y, mask);
-	}
-
-	if( !handled )
-	{
-		handled = mRootView->handleMouseUp(x, y, mask);
-	}
-
-	if (LLView::sDebugMouseHandling)
-	{
-		if (handled)
-		{
-			llinfos << "Left Mouse Up" << LLView::sMouseHandlerMessage << llendl;
-		}
-		else 
-		{
-			llinfos << "Left Mouse Up not handled by view" << llendl;
-		}
-	}
-
-	if( !handled )
-	{
-		if (tool)
-		{
-			handled = tool->handleMouseUp(x, y, mask);
-		}
-	}
-
-	// Always handled as far as the OS is concerned.
-	return TRUE;
+	BOOL down = FALSE;
+	return handleAnyMouseClick(window,pos,mask,LLMouseHandler::CLICK_LEFT,down);
 }
 
 
@@ -871,91 +787,10 @@ BOOL LLViewerWindow::handleRightMouseDown(LLWindow *window,  LLCoordGL pos, MASK
 	x = llround((F32)x / mDisplayScale.mV[VX]);
 	y = llround((F32)y / mDisplayScale.mV[VY]);
 
-	LLView::sMouseHandlerMessage.clear();
-
-	if (gDebugClicks)
-	{
-		llinfos << "ViewerWindow right mouse down at " << x << "," << y << llendl;
-	}
-
-	if (gMenuBarView)
-	{
-		// stop ALT-key access to menu
-		gMenuBarView->resetMenuTrigger();
-	}
-
-	mRightMouseDown = TRUE;
-
-	// Make sure we get a coresponding mouseup event, even if the mouse leaves the window
-	mWindow->captureMouse();
-
-	// Hide tooltips
-	if( mToolTip )
-	{
-		mToolTip->setVisible( FALSE );
-	}
-
-	// Also hide hover info on mousedown
-	if (gHoverView)
-	{
-		gHoverView->cancelHover();
-	}
-
-	// Don't let the user move the mouse out of the window until mouse up.
-	if( LLToolMgr::getInstance()->getCurrentTool()->clipMouseWhenDown() )
-	{
-		mWindow->setMouseClipping(TRUE);
-	}
-
-	LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture();
-	if( mouse_captor )
-	{
-		S32 local_x;
-		S32 local_y;
-		mouse_captor->screenPointToLocal( x, y, &local_x, &local_y );
-		if (LLView::sDebugMouseHandling)
-		{
-			llinfos << "Right Mouse Down handled by captor " << mouse_captor->getName() << llendl;
-		}
-		return mouse_captor->handleRightMouseDown(local_x, local_y, mask);
-	}
-
-	LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl();
-	if (top_ctrl)
-	{
-		S32 local_x, local_y;
-		top_ctrl->screenPointToLocal( x, y, &local_x, &local_y );
-		if (top_ctrl->pointInView(local_x, local_y))
-		{
-			return top_ctrl->handleRightMouseDown(local_x, local_y, mask);
-		}
-		else
-		{
-			gFocusMgr.setTopCtrl(NULL);
-		}
-	}
-
-	if( mRootView->handleRightMouseDown(x, y, mask) )
-	{
-		if (LLView::sDebugMouseHandling)
-		{
-			llinfos << "Right Mouse Down" << LLView::sMouseHandlerMessage << llendl;
-		}
-		return TRUE;
-	}
-	else if (LLView::sDebugMouseHandling)
-	{
-		llinfos << "Right Mouse Down not handled by view" << llendl;
-	}
-
-	if(LLToolMgr::getInstance()->getCurrentTool()->handleRightMouseDown( x, y, mask ) )
-	{
-		// This is necessary to force clicks in the world to cause edit
-		// boxes that might have keyboard focus to relinquish it, and hence
-		// cause a commit to update their value.  JC
-		gFocusMgr.setKeyboardFocus(NULL);
-		return TRUE;
-	}
+	BOOL down = TRUE;
+	BOOL handle = handleAnyMouseClick(window,pos,mask,LLMouseHandler::CLICK_RIGHT,down);
+	if (handle)
+		return handle;
 
 	// *HACK: this should be rolled into the composite tool logic, not
 	// hardcoded at the top level.
@@ -973,107 +808,27 @@ BOOL LLViewerWindow::handleRightMouseDown(LLWindow *window,  LLCoordGL pos, MASK
 
 BOOL LLViewerWindow::handleRightMouseUp(LLWindow *window,  LLCoordGL pos, MASK mask)
 {
-	S32 x = pos.mX;
-	S32 y = pos.mY;
-	x = llround((F32)x / mDisplayScale.mV[VX]);
-	y = llround((F32)y / mDisplayScale.mV[VY]);
-
-	LLView::sMouseHandlerMessage.clear();
-
-	// Don't care about caps lock for mouse events.
-	if (gDebugClicks)
-	{
-		llinfos << "ViewerWindow right mouse up" << llendl;
-	}
-
-	mRightMouseDown = FALSE;
-
-	// Indicate mouse was active
-	gMouseIdleTimer.reset();
-
-	// Hide tooltips on mouseup
-	if( mToolTip )
-	{
-		mToolTip->setVisible( FALSE );
-	}
-
-	// Also hide hover info on mouseup
-	if (gHoverView)	gHoverView->cancelHover();
-
-	BOOL handled = FALSE;
-
-	mWindow->releaseMouse();
-
-	LLTool *tool = LLToolMgr::getInstance()->getCurrentTool();
-
-	if( tool->clipMouseWhenDown() )
-	{
-		mWindow->setMouseClipping(FALSE);
-	}
-
-	LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture();
-	if( mouse_captor )
-	{
-		S32 local_x;
-		S32 local_y;
-		mouse_captor->screenPointToLocal( x, y, &local_x, &local_y );
-		if (LLView::sDebugMouseHandling)
-		{
-			llinfos << "Right Mouse Up handled by captor " << mouse_captor->getName() << llendl;
-		}
-		return mouse_captor->handleRightMouseUp(local_x, local_y, mask);
-	}
-
-	LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl();
-	if (top_ctrl)
-	{
-		S32 local_x, local_y;
-		top_ctrl->screenPointToLocal( x, y, &local_x, &local_y );
-		handled = top_ctrl->pointInView(local_x, local_y) && top_ctrl->handleRightMouseUp(local_x, local_y, mask);
-	}
-
-	if( !handled )
-	{
-		handled = mRootView->handleRightMouseUp(x, y, mask);
-	}
-
-	if (LLView::sDebugMouseHandling)
-	{
-		if (handled)
-		{
-			llinfos << "Right Mouse Up" << LLView::sMouseHandlerMessage << llendl;
-		}
-		else 
-		{
-			llinfos << "Right Mouse Up not handled by view" << llendl;
-		}
-	}
-
-	if( !handled )
-	{
-		if (tool)
-		{
-			handled = tool->handleRightMouseUp(x, y, mask);
-		}
-	}
-
-	// Always handled as far as the OS is concerned.
-	return TRUE;
+	BOOL down = FALSE;
+ 	return handleAnyMouseClick(window,pos,mask,LLMouseHandler::CLICK_RIGHT,down);
 }
 
 BOOL LLViewerWindow::handleMiddleMouseDown(LLWindow *window,  LLCoordGL pos, MASK mask)
 {
+	BOOL down = TRUE;
 	gVoiceClient->middleMouseState(true);
-
-	// Always handled as far as the OS is concerned.
+ 	handleAnyMouseClick(window,pos,mask,LLMouseHandler::CLICK_MIDDLE,down);
+  
+  	// Always handled as far as the OS is concerned.
 	return TRUE;
 }
-
+  
 BOOL LLViewerWindow::handleMiddleMouseUp(LLWindow *window,  LLCoordGL pos, MASK mask)
 {
+	BOOL down = FALSE;
 	gVoiceClient->middleMouseState(false);
-
-	// Always handled as far as the OS is concerned.
+ 	handleAnyMouseClick(window,pos,mask,LLMouseHandler::CLICK_MIDDLE,down);
+  
+  	// Always handled as far as the OS is concerned.
 	return TRUE;
 }
 
@@ -1279,7 +1034,7 @@ BOOL LLViewerWindow::handleActivate(LLWindow *window, BOOL activated)
 	else
 	{
 		mActive = FALSE;
-		if (gAllowIdleAFK)
+		if (gSavedSettings.getBOOL("AllowIdleAFK"))
 		{
 			gAgent.setAFK();
 		}
@@ -1447,6 +1202,7 @@ LLViewerWindow::LLViewerWindow(
 	mWindowRect(0, height, width, 0),
 	mVirtualWindowRect(0, height, width, 0),
 	mLeftMouseDown(FALSE),
+	mMiddleMouseDown(FALSE),
 	mRightMouseDown(FALSE),
 	mToolTip(NULL),
 	mToolTipBlocked(FALSE),
@@ -5288,11 +5044,15 @@ void LLPickInfo::fetchResults()
 
 			// put global position into land_pos
 			LLVector3d land_pos;
-			if (gViewerWindow->mousePointOnLandGlobal(mPickPt.mX, mPickPt.mY, &land_pos))
+			if (!gViewerWindow->mousePointOnLandGlobal(mPickPt.mX, mPickPt.mY, &land_pos))
 			{
-				// Fudge the land focus a little bit above ground.
-				mPosGlobal = land_pos + LLVector3d::z_axis * 0.1f;
+				// The selected point is beyond the draw distance or is otherwise 
+				// not selectable. Return before calling mPickCallback().
+				return;
 			}
+
+			// Fudge the land focus a little bit above ground.
+			mPosGlobal = land_pos + LLVector3d::z_axis * 0.1f;
 		}
 		else
 		{
diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h
index 1520e779abd9fadde4c82dd1dbf3143496be1875..e0ddac6fa5d667866e9a501a5594e3241671eaec 100644
--- a/indra/newview/llviewerwindow.h
+++ b/indra/newview/llviewerwindow.h
@@ -49,6 +49,7 @@
 #include "llstat.h"
 #include "llalertdialog.h"
 #include "llnotifications.h"
+#include "llmousehandler.h"
 
 class LLView;
 class LLViewerObject;
@@ -59,7 +60,6 @@ class LLVelocityBar;
 class LLTextBox;
 class LLImageRaw;
 class LLHUDIcon;
-class LLMouseHandler;
 
 #define PICK_HALF_WIDTH 5
 #define PICK_DIAMETER (2 * PICK_HALF_WIDTH + 1)
@@ -83,7 +83,7 @@ public:
 
 	static bool isFlora(LLViewerObject* object);
 
-	typedef enum e_pick_type
+	typedef enum
 	{
 		PICK_OBJECT,
 		PICK_FLORA,
@@ -152,6 +152,7 @@ public:
 	/*virtual*/ BOOL handleTranslatedKeyUp(KEY key,  MASK mask);
 	/*virtual*/ void handleScanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level);
 	/*virtual*/ BOOL handleUnicodeChar(llwchar uni_char, MASK mask);	// NOT going to handle extended 
+	/*virtual*/ BOOL handleAnyMouseClick(LLWindow *window,  LLCoordGL pos, MASK mask, LLMouseHandler::EClickType clicktype, BOOL down);
 	/*virtual*/ BOOL handleMouseDown(LLWindow *window,  LLCoordGL pos, MASK mask);
 	/*virtual*/ BOOL handleMouseUp(LLWindow *window,  LLCoordGL pos, MASK mask);
 	/*virtual*/ BOOL handleCloseRequest(LLWindow *window);
@@ -214,6 +215,7 @@ public:
 	LLCoordGL		getCurrentMouseDelta()	const	{ return mCurrentMouseDelta; }
 	LLStat *		getMouseVelocityStat()		{ return &mMouseVelocityStat; }
 	BOOL			getLeftMouseDown()	const	{ return mLeftMouseDown; }
+	BOOL			getMiddleMouseDown()	const	{ return mMiddleMouseDown; }
 	BOOL			getRightMouseDown()	const	{ return mRightMouseDown; }
 
 	const LLPickInfo&	getLastPick() const { return mLastPick; }
@@ -281,7 +283,7 @@ public:
 
 	// snapshot functionality.
 	// perhaps some of this should move to llfloatershapshot?  -MG
-	typedef enum e_snapshot_type
+	typedef enum
 	{
 		SNAPSHOT_TYPE_COLOR,
 		SNAPSHOT_TYPE_DEPTH,
@@ -387,6 +389,7 @@ protected:
 	LLCoordGL		mCurrentMouseDelta;		//amount mouse moved this frame
 	LLStat			mMouseVelocityStat;
 	BOOL			mLeftMouseDown;
+	BOOL			mMiddleMouseDown;
 	BOOL			mRightMouseDown;
 
 	LLProgressView	*mProgressView;
diff --git a/indra/newview/llvlcomposition.cpp b/indra/newview/llvlcomposition.cpp
index b79d7d10ff67b7d0eccf3d0ee269211ffe1a5cf9..e52fec7909de4f7fa349cefd2efe098202bbbb7b 100644
--- a/indra/newview/llvlcomposition.cpp
+++ b/indra/newview/llvlcomposition.cpp
@@ -214,7 +214,7 @@ BOOL LLVLComposition::generateHeights(const F32 x, const F32 y,
 	return TRUE;
 }
 
-static const S32 BASE_SIZE = 128;
+static const U32 BASE_SIZE = 128;
 
 BOOL LLVLComposition::generateComposition()
 {
@@ -349,9 +349,9 @@ BOOL LLVLComposition::generateTexture(const F32 x, const F32 y,
 	tex_comps = texturep->getComponents();
 	tex_stride = tex_width * tex_comps;
 
-	S32 st_comps = 3;
-	S32 st_width = BASE_SIZE;
-	S32 st_height = BASE_SIZE;
+	U32 st_comps = 3;
+	U32 st_width = BASE_SIZE;
+	U32 st_height = BASE_SIZE;
 	
 	if (tex_comps != st_comps)
 	{
diff --git a/indra/newview/llwearable.cpp b/indra/newview/llwearable.cpp
index a5f4dc934a8c1eaf6f8a144deeacf29fb4d6174a..f705531723d55fc698eb6ff1f9e91d860dfa81bc 100644
--- a/indra/newview/llwearable.cpp
+++ b/indra/newview/llwearable.cpp
@@ -294,7 +294,7 @@ BOOL LLWearable::importFile( LLFILE* file )
 	}
 
 	// name
-	char next_char = fgetc( file );		/* Flawfinder: ignore */
+	int next_char = fgetc( file );		/* Flawfinder: ignore */
 	if( '\n' == next_char )
 	{
 		// no name
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index c9cc86bbbce595c3edfc5569e8e76ef9d79cc19c..3fdef295400d510a1c7f2cae9f9ffc3000ac0e40 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -367,9 +367,14 @@ LLVector3d	LLWorld::clipToVisibleRegions(const LLVector3d &start_pos, const LLVe
 		clip_factor = (region_coord.mV[VY] - region_width) / delta_pos_abs.mdV[VY];
 	}
 
-	// clamp to < 256 to stay in sim
+	// clamp to within region dimensions
 	LLVector3d final_region_pos = LLVector3d(region_coord) - (delta_pos * clip_factor);
-	final_region_pos.clamp(0.0, 255.999);
+	final_region_pos.mdV[VX] = llclamp(final_region_pos.mdV[VX], 0.0,
+									   (F64)(region_width - F_ALMOST_ZERO));
+	final_region_pos.mdV[VY] = llclamp(final_region_pos.mdV[VY], 0.0,
+									   (F64)(region_width - F_ALMOST_ZERO));
+	final_region_pos.mdV[VZ] = llclamp(final_region_pos.mdV[VZ], 0.0,
+									   (F64)(LLWorld::getInstance()->getRegionMaxHeight() - F_ALMOST_ZERO));
 	return regionp->getPosGlobalFromRegion(LLVector3(final_region_pos));
 }
 
diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp
index 7f8f4cc026b688cc1703705465ca23fdaf9c74be..62c4d832cfa2f1e335c5a3658155063b23accd19 100644
--- a/indra/newview/llworldmapview.cpp
+++ b/indra/newview/llworldmapview.cpp
@@ -181,11 +181,11 @@ LLWorldMapView::LLWorldMapView(const std::string& name, const LLRect& rect )
 	const S32 DIR_WIDTH = 10;
 	const S32 DIR_HEIGHT = 10;
 	LLRect major_dir_rect(  0, DIR_HEIGHT, DIR_WIDTH, 0 );
+	LLColor4 minor_color( 1.f, 1.f, 1.f, .7f );
 
 	mTextBoxNorth = new LLTextBox( std::string("N"), major_dir_rect );
+	mTextBoxNorth->setColor( minor_color );
 	addChild( mTextBoxNorth );
-
-	LLColor4 minor_color( 1.f, 1.f, 1.f, .7f );
 	
 	mTextBoxEast =	new LLTextBox( std::string("E"), major_dir_rect );
 	mTextBoxEast->setColor( minor_color );
diff --git a/install.xml b/install.xml
index 6940a425d58aa2b46896a4736960daa6b3f224cd..6f761669c91ae7fd93879c1d4274ea57f793b131 100644
--- a/install.xml
+++ b/install.xml
@@ -63,9 +63,9 @@
           <key>linux</key>
           <map>
             <key>md5sum</key>
-            <string>ce71bd658c3fa9fd7f46b7c5adacef1c</string>
+            <string>25f8a8fc4ea94169fe6222571b8d5e55</string>
             <key>url</key>
-            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/SDL-1.2.5-linux-20080818.tar.bz2</uri>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/SDL-1.2.12-linux-20081222c.tar.bz2</uri>
           </map>
           <key>windows</key>
           <map>
@@ -247,30 +247,30 @@
           <key>darwin</key>
           <map>
             <key>md5sum</key>
-            <string>c426dfaad3b662405e49ed3701a55d38</string>
+            <string>1bece4ebdc5fc3818854bc3df14b511b</string>
             <key>url</key>
-            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/curl-7.16.0-darwin-20080812.tar.bz2</uri>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/curl-7.16.4a-darwin-20090304.tar.bz2</uri>
           </map>
           <key>linux</key>
           <map>
             <key>md5sum</key>
-            <string>a88e8285b3d97a21bf43cc5f90e87eb9</string>
+            <string>0f366e421ae9c72d9659bd20a2a326d6</string>
             <key>url</key>
-            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/curl-7.16.4-linux-20081202.tar.bz2</uri>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/curl-7.16.4a-linux-20090303a.tar.bz2</uri>
           </map>
           <key>linux64</key>
           <map>
             <key>md5sum</key>
-            <string>6e9242d11d785f643f34d925a29967e7</string>
+            <string>6994192cea7ab2d885a158a3de474273</string>
             <key>url</key>
-            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/curl-7.16.4-linux64-20080909.tar.bz2</uri>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/curl-7.16.4a-linux64-20090303.tar.bz2</uri>
           </map>
           <key>windows</key>
           <map>
             <key>md5sum</key>
-            <string>d391c33898a5dbc7e7537bf0d9cda36e</string>
+            <string>8c9d135f0e7cd1fae5681d4595942ee3</string>
             <key>url</key>
-            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/curl-7.18.1-windows-20080723.tar.bz2</uri>
+            <uri>http://s3.amazonaws.com/viewer-source-downloads/install_pkgs/curl-7.16.4-windows-20090306.tar.bz2</uri>
           </map>
         </map>
       </map>