From ce7682c2a468e926d6b38e4f95bd289a8d26222c Mon Sep 17 00:00:00 2001
From: Bryan O'Sullivan <bos@lindenlab.com>
Date: Wed, 18 Jul 2007 21:22:40 +0000
Subject: [PATCH] svn merge -r64837:65485
 svn+ssh://svn.lindenlab.com/svn/linden/branches/maintenance --> release

(only inside indra)

(josh) Original log message was:
   svn merge -r64837:65485 svn+ssh://svn.lindenlab.com/svn/linden/branches/maintenance
bos updated it to be:
   svn merge -r64837:65269 svn+ssh://svn.lindenlab.com/svn/linden/branches/maintenance
However, it appears it actually was:
   svn merge -r64837:65485 svn+ssh://svn.lindenlab.com/svn/linden/branches/maintenance
... missing some file additions.
---
 indra/lib/python/indra/__init__.py         |  12 +--
 indra/llcharacter/lljoint.cpp              |  33 -------
 indra/llcharacter/lljoint.h                |   5 -
 indra/llcommon/indra_constants.h           |  10 +-
 indra/llcommon/llmemory.cpp                |   5 +-
 indra/llcommon/llmemtype.h                 |   2 +
 indra/llcommon/llprocessor.cpp             |  14 ++-
 indra/llcommon/llsdserialize_xml.cpp       |   6 +-
 indra/llcommon/llsys.cpp                   |   6 +-
 indra/llimage/llimagejpeg.h                |   9 +-
 indra/llmath/lloctree.h                    |  68 ++++++-------
 indra/llmath/lltreenode.h                  |  22 ++---
 indra/llmath/llvolume.h                    |   2 +-
 indra/llmessage/llcurl.cpp                 |   2 +-
 indra/llmessage/llhttpassetstorage.cpp     |   6 +-
 indra/llmessage/llnamevalue.cpp            |   3 +
 indra/llmessage/lluseroperation.cpp        |  21 +++-
 indra/llmessage/lluseroperation.h          |   4 +
 indra/llrender/llimagegl.h                 |   1 -
 indra/llui/llfloater.cpp                   | 106 ++++++++++++---------
 indra/llui/llfloater.h                     |   4 +
 indra/llui/llmenugl.cpp                    |  42 ++++++--
 indra/llui/lltexteditor.cpp                |  48 +++++-----
 indra/llui/lltexteditor.h                  |   4 +-
 indra/llwindow/llwindowwin32.cpp           |  12 +++
 indra/llxml/llxmlnode.h                    |   4 +
 indra/llxml/llxmlparser.h                  |   4 +
 indra/lscript/lscript_compile/indra.y      |   4 +
 indra/newview/linux_tools/wrapper.sh       |  17 ++++
 indra/newview/llface.h                     |   1 -
 indra/newview/llfloaterfriends.cpp         |   2 +-
 indra/newview/llfloaterinspect.cpp         |  19 ++--
 indra/newview/llfloaterscriptdebug.cpp     |  11 ++-
 indra/newview/llfloatersnapshot.cpp        |  19 ++--
 indra/newview/llhudeffectlookat.cpp        |  63 ++++++------
 indra/newview/llimpanel.cpp                |  34 ++++---
 indra/newview/llimpanel.h                  |   5 +-
 indra/newview/llimview.cpp                 |   9 ++
 indra/newview/llmemoryview.cpp             |  53 ++++++++++-
 indra/newview/llmemoryview.h               |   7 ++
 indra/newview/lloverlaybar.cpp             |   6 +-
 indra/newview/llpanellogin.h               |   1 +
 indra/newview/llpreviewscript.cpp          |   7 ++
 indra/newview/llselectmgr.cpp              |  33 ++++++-
 indra/newview/llselectmgr.h                |   5 +-
 indra/newview/llstartup.cpp                |  36 +++----
 indra/newview/llstatusbar.h                |   2 +-
 indra/newview/lltoolselect.cpp             |   2 +-
 indra/newview/llviewerjointattachment.cpp  |  17 ++--
 indra/newview/llviewermenu.cpp             |  31 +++---
 indra/newview/llviewermessage.cpp          |   1 +
 indra/newview/llviewerobjectlist.cpp       |   6 +-
 indra/newview/llviewerparcelmgr.cpp        |   3 +-
 indra/newview/llviewerpartsim.cpp          |   2 +-
 indra/newview/llviewerpartsource.cpp       |   6 ++
 indra/newview/llviewerprecompiledheaders.h |   2 -
 indra/newview/llviewerregion.cpp           |  80 +---------------
 indra/newview/llviewerregion.h             |  16 ++--
 indra/newview/llviewerwindow.cpp           |   4 +-
 indra/newview/llvoavatar.cpp               |   4 +-
 indra/newview/llvograss.cpp                |   5 +-
 indra/newview/llvopartgroup.cpp            |   2 +-
 indra/newview/llvotree.cpp                 |   4 +-
 indra/newview/viewer_manifest.py           |   2 +-
 indra/test/llbuffer_tut.cpp                |   2 +
 indra/win_crash_logger/resource.h          |   8 --
 indra/win_crash_logger/win_crash_logger.rc |  10 +-
 67 files changed, 577 insertions(+), 419 deletions(-)

diff --git a/indra/lib/python/indra/__init__.py b/indra/lib/python/indra/__init__.py
index bbfdbaf98d..7db53666e8 100644
--- a/indra/lib/python/indra/__init__.py
+++ b/indra/lib/python/indra/__init__.py
@@ -1,7 +1,5 @@
-"""\
-@file __init__.py
-@brief Initialization file for the indra module.
-
-Copyright (c) 2006-2007, Linden Research, Inc.
-$License$
-"""
+# @file __init__.py
+# @brief Initialization file for the indra module.
+# 
+# Copyright (c) 2006-$CurrentYear$, Linden Research, Inc.
+# $License$
diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp
index 3797b06aa1..acc64e6afd 100644
--- a/indra/llcharacter/lljoint.cpp
+++ b/indra/llcharacter/lljoint.cpp
@@ -465,39 +465,6 @@ void LLJoint::setSkinOffset( const LLVector3& offset )
 	mSkinOffset = offset;
 }
 
-//-----------------------------------------------------------------------------
-// setConstraintSilhouette()
-//-----------------------------------------------------------------------------
-void LLJoint::setConstraintSilhouette(LLDynamicArray<LLVector3>& silhouette)
-{
-	S32 i;
-
-	mConstraintSilhouette.reset();
-	for (i = 0; i < silhouette.count(); i++)
-	{
-		if (i % 2 == 1)
-		{
-			// skip normals
-			continue;
-		}
-		mConstraintSilhouette[i / 2] = silhouette[i];
-	}
-	LLQuaternion inv_parent_rotation = LLQuaternion::DEFAULT;
-
-	if (getParent())
-	{
-		inv_parent_rotation = ~getParent()->getWorldRotation();
-	}
-
-	for (i = 0; i < mConstraintSilhouette.count(); i++)
-	{
-		LLVector3 vert = mConstraintSilhouette[i];
-
-		vert -= getWorldPosition();
-		vert.normVec();
-		vert = vert * inv_parent_rotation;
-	}
-}
 
 //-----------------------------------------------------------------------------
 // clampRotation()
diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h
index 6399d0a429..aaa30f624b 100644
--- a/indra/llcharacter/lljoint.h
+++ b/indra/llcharacter/lljoint.h
@@ -65,7 +65,6 @@ protected:
 
 public:
 	U32				mDirtyFlags;
-	BOOL			mWorldRotationDirty;
 	BOOL			mUpdateXform;
 
 	// describes the skin binding pose
@@ -73,8 +72,6 @@ public:
 
 	S32				mJointNum;
 
-	LLDynamicArray<LLVector3> mConstraintSilhouette;
-
 	// child joints
 	typedef std::list<LLJoint*> child_list_t;
 	child_list_t mChildren;
@@ -151,8 +148,6 @@ public:
 
 	LLXformMatrix	*getXform() { return &mXform; }
 
-	void setConstraintSilhouette(LLDynamicArray<LLVector3>& silhouette);
-
 	void clampRotation(LLQuaternion old_rot, LLQuaternion new_rot);
 
 	virtual BOOL isAnimatable() { return TRUE; }
diff --git a/indra/llcommon/indra_constants.h b/indra/llcommon/indra_constants.h
index 7f1c48a215..4ef4d21833 100644
--- a/indra/llcommon/indra_constants.h
+++ b/indra/llcommon/indra_constants.h
@@ -110,10 +110,12 @@ const	char	CLOUD_LAYER_CODE				= '8';
 
 // keys
 // Bit masks for various keyboard modifier keys.
-const MASK MASK_NONE =		0x0000;
-const MASK MASK_CONTROL =	0x0001;
-const MASK MASK_ALT =		0x0002;
-const MASK MASK_SHIFT =		0x0004;
+const MASK MASK_NONE =			0x0000;
+const MASK MASK_CONTROL =		0x0001;		// Mapped to cmd on Macs
+const MASK MASK_ALT =			0x0002;
+const MASK MASK_SHIFT =			0x0004;
+const MASK MASK_NORMALKEYS =    0x0007;     // A real mask - only get the bits for normal modifier keys
+const MASK MASK_MAC_CONTROL =	0x0008;		// Un-mapped Ctrl key on Macs, not used on Windows
 
 // Special keys go into >128
 const KEY KEY_SPECIAL = 0x80;	// special keys start here
diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index addda19775..19b8748d2e 100644
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -49,6 +49,7 @@ S32 LLMemType::sCurType = LLMemType::MTYPE_INIT;
 S32 LLMemType::sType[LLMemType::MTYPE_MAX_DEPTH];
 S32 LLMemType::sMemCount[LLMemType::MTYPE_NUM_TYPES] = { 0 };
 S32 LLMemType::sMaxMemCount[LLMemType::MTYPE_NUM_TYPES] = { 0 };
+S32 LLMemType::sNewCount[LLMemType::MTYPE_NUM_TYPES] = { 0 };
 S32 LLMemType::sOverheadMem = 0;
 
 const char* LLMemType::sTypeDesc[LLMemType::MTYPE_NUM_TYPES] =
@@ -113,7 +114,7 @@ void LLMemType::printMem()
 	{
 		if (sMemCount[i])
 		{
-			llinfos << llformat("MEM: % 20s %03d MB (%03d MB)",sTypeDesc[i],sMemCount[i]>>20,sMaxMemCount[i]>>20) << llendl;
+			llinfos << llformat("MEM: % 20s %03d MB (%03d MB) in %06d News",sTypeDesc[i],sMemCount[i]>>20,sMaxMemCount[i]>>20, sNewCount[i]) << llendl;
 		}
 		misc_mem -= sMemCount[i];
 	}
@@ -160,6 +161,7 @@ void* ll_allocate (size_t size)
 	{
 		LLMemType::sMaxMemCount[LLMemType::sCurType] = LLMemType::sMemCount[LLMemType::sCurType];
 	}
+	LLMemType::sNewCount[LLMemType::sCurType]++;
 #endif
 	return (void*)p;
 }
@@ -185,6 +187,7 @@ void ll_release (void *pin)
 #if MEM_TRACK_TYPE
 	LLMemType::sMemCount[type] -= size;
 	LLMemType::sOverheadMem -= 4;
+	LLMemType::sNewCount[type]--;
 #endif
 	LLMemType::sTotalMem -= size;
 	free(p);
diff --git a/indra/llcommon/llmemtype.h b/indra/llcommon/llmemtype.h
index 53f7f66285..a101f35628 100644
--- a/indra/llcommon/llmemtype.h
+++ b/indra/llcommon/llmemtype.h
@@ -21,6 +21,7 @@ extern void ll_release (void *p);
 #define MEM_TRACK_TYPE (1 && MEM_TRACK_MEM)
 
 #if MEM_TRACK_TYPE
+#define MEM_DUMP_DATA 1
 #define MEM_TYPE_NEW(T) \
 static void* operator new(size_t s) { LLMemType mt(T); return ll_allocate(s); } \
 static void  operator delete(void* p) { ll_release(p); }
@@ -123,6 +124,7 @@ public:
 	static S32 sType[MTYPE_MAX_DEPTH];
 	static S32 sMemCount[MTYPE_NUM_TYPES];
 	static S32 sMaxMemCount[MTYPE_NUM_TYPES];
+	static S32 sNewCount[MTYPE_NUM_TYPES];
 	static S32 sOverheadMem;
 	static const char* sTypeDesc[MTYPE_NUM_TYPES];
 #endif
diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp
index bcabb47a66..3ff41a0104 100644
--- a/indra/llcommon/llprocessor.cpp
+++ b/indra/llcommon/llprocessor.cpp
@@ -280,7 +280,7 @@ bool CProcessor::AnalyzeIntelProcessor()
 			strcpy(CPUInfo.strFamily, "Intel Pentium");	/* Flawfinder: ignore */	
 			break;
 		case 6:			// Family = 6:  Pentium Pro (80686) processor family
-			strcpy(CPUInfo.strFamily, "Intel Pentium Pro");	/* Flawfinder: ignore */	
+			strcpy(CPUInfo.strFamily, "Intel Pentium Pro/2/3, Core");	/* Flawfinder: ignore */	
 			break;
 		case 15:		// Family = 15:  Extended family specific
 			// Masking the extended family
@@ -476,9 +476,17 @@ bool CProcessor::AnalyzeIntelProcessor()
 							break;
 					}
 					break;
+				case 0xE:		// Model = 0xE:  Intel Core Duo processor, Intel Core Solo processor, model E
+					strcpy(CPUInfo.strModel, "Intel Core Duo/Solo Processor");	 /*Flawfinder: ignore*/
+					strncat(strCPUName, "Intel Core Duo/Solo Processor", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
+					break;	
+				case 0xF:		// Model = 0xF:  Intel Core 2 Duo processor, model F
+					strcpy(CPUInfo.strModel, "Intel Core2 Duo Processor");	 /*Flawfinder: ignore*/
+					strncat(strCPUName, "Intel Core2 Duo Processor", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
+					break;	
 				default:		// *more bored*
-					strcpy(CPUInfo.strModel, "Unknown Intel Pentium Pro"); /*Flawfinder: ignore*/
-					strncat(strCPUName, "Intel Pentium Pro (Unknown model)", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
+					strcpy(CPUInfo.strModel, "Unknown Intel Pentium Pro/2/3, Core"); /*Flawfinder: ignore*/
+					strncat(strCPUName, "Intel Pentium Pro/2/3, Core (Unknown model)", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
 					break;
 			}
 			break;
diff --git a/indra/llcommon/llsdserialize_xml.cpp b/indra/llcommon/llsdserialize_xml.cpp
index de4f3197e6..4ca47ba8dc 100644
--- a/indra/llcommon/llsdserialize_xml.cpp
+++ b/indra/llcommon/llsdserialize_xml.cpp
@@ -16,7 +16,11 @@
 
 extern "C"
 {
-#include "expat/expat.h"
+#ifdef LL_STANDALONE
+# include <expat.h>
+#else
+# include "expat/expat.h"
+#endif
 }
 
 /**
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index 90cc374ade..3398f475aa 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -11,7 +11,11 @@
 #include "llsys.h"
 
 #include <iostream>
-#include <zlib/zlib.h>
+#ifdef LL_STANDALONE
+# include <zlib.h>
+#else
+# include "zlib/zlib.h"
+#endif
 
 #include "processor.h"
 
diff --git a/indra/llimage/llimagejpeg.h b/indra/llimage/llimagejpeg.h
index b068090882..a94f238ff0 100644
--- a/indra/llimage/llimagejpeg.h
+++ b/indra/llimage/llimagejpeg.h
@@ -14,8 +14,13 @@
 #include "llimage.h"
 
 extern "C" {
-#include "jpeglib/jpeglib.h"
-#include "jpeglib/jerror.h"
+#ifdef LL_STANDALONE
+# include <jpeglib.h>
+# include <jerror.h>
+#else
+# include "jpeglib/jpeglib.h"
+# include "jpeglib/jerror.h"
+#endif
 }
 
 class LLImageJPEG : public LLImageFormatted
diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h
index 97f9576767..fb1d89f3ca 100644
--- a/indra/llmath/lloctree.h
+++ b/indra/llmath/lloctree.h
@@ -75,34 +75,34 @@ public:
 		}
 	}
 
-	virtual ~LLOctreeNode()								{ BaseType::destroyListeners(); delete this->mState; }
-
-	virtual const BaseType* getParent()	const			{ return mParent; }
-	virtual void setParent(BaseType* parent)			{ mParent = (oct_node*) parent; }
-	virtual const LLVector3d& getCenter() const			{ return mCenter; }
-	virtual const LLVector3d& getSize() const			{ return mSize; }
-	virtual void setCenter(LLVector3d center)			{ mCenter = center; }
-	virtual void setSize(LLVector3d size)				{ mSize = size; }
-    virtual bool balance()								{ return getOctState()->balance(); }
-	virtual void validate()								{ getOctState()->validate(); }
-	virtual U32 getChildCount()	const					{ return getOctState()->getChildCount(); }
-	virtual oct_node* getChild(U32 index)				{ return getOctState()->getChild(index); }
-	virtual const oct_node* getChild(U32 index) const	{ return getOctState()->getChild(index); }
-	virtual U32 getElementCount() const					{ return getOctState()->getElementCount(); }
-	virtual void removeByAddress(T* data)				{ getOctState()->removeByAddress(data); }
-	virtual bool hasLeafState()	const					{ return getOctState()->isLeaf(); }
-	virtual void destroy()								{ getOctState()->destroy(); }
-	virtual oct_node* getNodeAt(T* data)				{ return getNodeAt(data->getPositionGroup(), data->getBinRadius()); }
-	virtual oct_node* getNodeAt(const LLVector3d& pos, const F64& rad) { return getOctState()->getNodeAt(pos, rad); }
-	virtual U8 getOctant() const						{ return mOctant; }
-	virtual void setOctant(U8 octant)					{ mOctant = octant; }
-	virtual const oct_state* getOctState() const		{ return (const oct_state*) BaseType::mState; }
-	virtual oct_state* getOctState()	 				{ return (oct_state*) BaseType::mState; }
-	virtual const oct_node*	getOctParent() const		{ return (const oct_node*) getParent(); }
-	virtual oct_node* getOctParent() 					{ return (oct_node*) getParent(); }
-	virtual void deleteChild(oct_node* child)			{ getOctState()->deleteChild(child); }
-
-	virtual U8 getOctant(const F64 pos[]) const	//get the octant pos is in
+	~LLOctreeNode()								{ BaseType::destroyListeners(); delete this->mState; }
+
+	inline const BaseType* getParent()	const			{ return mParent; }
+	inline void setParent(BaseType* parent)			{ mParent = (oct_node*) parent; }
+	inline const LLVector3d& getCenter() const			{ return mCenter; }
+	inline const LLVector3d& getSize() const			{ return mSize; }
+	inline void setCenter(LLVector3d center)			{ mCenter = center; }
+	inline void setSize(LLVector3d size)				{ mSize = size; }
+    inline bool balance()								{ return getOctState()->balance(); }
+	inline void validate()								{ getOctState()->validate(); }
+	inline U32 getChildCount()	const					{ return getOctState()->getChildCount(); }
+	inline oct_node* getChild(U32 index)				{ return getOctState()->getChild(index); }
+	inline const oct_node* getChild(U32 index) const	{ return getOctState()->getChild(index); }
+	inline U32 getElementCount() const					{ return getOctState()->getElementCount(); }
+	inline void removeByAddress(T* data)				{ getOctState()->removeByAddress(data); }
+	inline bool hasLeafState()	const					{ return getOctState()->isLeaf(); }
+	inline void destroy()								{ getOctState()->destroy(); }
+	inline oct_node* getNodeAt(T* data)				{ return getNodeAt(data->getPositionGroup(), data->getBinRadius()); }
+	inline oct_node* getNodeAt(const LLVector3d& pos, const F64& rad) { return getOctState()->getNodeAt(pos, rad); }
+	inline U8 getOctant() const						{ return mOctant; }
+	inline void setOctant(U8 octant)					{ mOctant = octant; }
+	inline const oct_state* getOctState() const		{ return (const oct_state*) BaseType::mState; }
+	inline oct_state* getOctState()	 				{ return (oct_state*) BaseType::mState; }
+	inline const oct_node*	getOctParent() const		{ return (const oct_node*) getParent(); }
+	inline oct_node* getOctParent() 					{ return (oct_node*) getParent(); }
+	inline void deleteChild(oct_node* child)			{ getOctState()->deleteChild(child); }
+
+	U8 getOctant(const F64 pos[]) const	//get the octant pos is in
 	{
 		U8 ret = 0;
 
@@ -122,17 +122,17 @@ public:
 		return ret;
 	}
 	
-	virtual bool isInside(const LLVector3d& pos, const F64& rad) const
+	inline bool isInside(const LLVector3d& pos, const F64& rad) const
 	{
 		return rad <= mSize.mdV[0]*2.0 && isInside(pos); 
 	}
 
-	virtual bool isInside(T* data) const			
+	inline bool isInside(T* data) const			
 	{ 
 		return isInside(data->getPositionGroup(), data->getBinRadius());
 	}
 
-	virtual bool isInside(const LLVector3d& pos) const
+	bool isInside(const LLVector3d& pos) const
 	{
 		const F64& x = pos.mdV[0];
 		const F64& y = pos.mdV[1];
@@ -148,7 +148,7 @@ public:
 		return true;
 	}
 	
-	virtual void updateMinMax()
+	void updateMinMax()
 	{
 		for (U32 i = 0; i < 3; i++)
 		{
@@ -158,12 +158,12 @@ public:
 		}
 	}
 
-	virtual oct_listener* getOctListener(U32 index) 
+	inline oct_listener* getOctListener(U32 index) 
 	{ 
 		return (oct_listener*) BaseType::getListener(index); 
 	}
 
-	bool contains(T* xform)
+	inline bool contains(T* xform)
 	{
 		return contains(xform->getBinRadius());
 	}
diff --git a/indra/llmath/lltreenode.h b/indra/llmath/lltreenode.h
index 67c6cb631a..3445730adf 100644
--- a/indra/llmath/lltreenode.h
+++ b/indra/llmath/lltreenode.h
@@ -49,17 +49,17 @@ class LLTreeNode
 public:
 	LLTreeNode(LLTreeState<T>* state)				{ setState(state); }
 	virtual ~LLTreeNode();
-	virtual LLTreeState<T>* getState()				{ return mState; }
-	virtual const LLTreeState<T>* getState() const	{ return mState; }
-
-	virtual void setState(LLTreeState<T>* state);
-	virtual void insert(T* data);
-	virtual bool remove(T* data);
-	virtual void notifyRemoval(T* data);
-	virtual U32 getListenerCount()					{ return mListeners.size(); }
-	virtual LLTreeListener<T>* getListener(U32 index) const { return mListeners[index]; }
-	virtual void addListener(LLTreeListener<T>* listener) { mListeners.push_back(listener); }
-	virtual void removeListener(U32 index) { mListeners.erase(mListeners.begin()+index); }
+	LLTreeState<T>* getState()				{ return mState; }
+	const LLTreeState<T>* getState() const	{ return mState; }
+
+	void setState(LLTreeState<T>* state);
+	void insert(T* data);
+	bool remove(T* data);
+	void notifyRemoval(T* data);
+	inline U32 getListenerCount()					{ return mListeners.size(); }
+	inline LLTreeListener<T>* getListener(U32 index) const { return mListeners[index]; }
+	inline void addListener(LLTreeListener<T>* listener) { mListeners.push_back(listener); }
+	inline void removeListener(U32 index) { mListeners.erase(mListeners.begin()+index); }
 
 protected:
 	void destroyListeners()
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 2db44d39d1..385680d7f9 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -763,7 +763,7 @@ public:
 		FLAT_MASK =		0x0100,
 		TOP_MASK =		0x0200,
 		BOTTOM_MASK =	0x0400
-	} TypeMask;
+	};
 	
 public:
 	S32 mID;
diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index bf3ea1cd6f..13ae8e4ad5 100644
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -76,7 +76,7 @@ namespace boost
 	
 	void intrusive_ptr_release(LLCurl::Responder* p)
 	{
-		if(0 == --p->mReferenceCount)
+		if(p && 0 == --p->mReferenceCount)
 		{
 			delete p;
 		}
diff --git a/indra/llmessage/llhttpassetstorage.cpp b/indra/llmessage/llhttpassetstorage.cpp
index 37b15d7822..534f1d8ca6 100644
--- a/indra/llmessage/llhttpassetstorage.cpp
+++ b/indra/llmessage/llhttpassetstorage.cpp
@@ -18,7 +18,11 @@
 #include "llvfile.h"
 #include "llvfs.h"
 
-#include "zlib/zlib.h"
+#ifdef LL_STANDALONE
+# include <zlib.h>
+#else
+# include "zlib/zlib.h"
+#endif
 
 const U32 MAX_RUNNING_REQUESTS = 1;
 const F32 MAX_PROCESSING_TIME = 0.005f;
diff --git a/indra/llmessage/llnamevalue.cpp b/indra/llmessage/llnamevalue.cpp
index 46e28ed29e..5cb4afe2f9 100644
--- a/indra/llmessage/llnamevalue.cpp
+++ b/indra/llmessage/llnamevalue.cpp
@@ -102,6 +102,9 @@ void LLNameValue::baseInit()
 	
 	mSendto = NVS_NULL;
 	mStringSendto = NameValueSendtoStrings[NVS_NULL];
+
+	mNameValueCB = NULL;
+	mUserData = NULL;
 }
 
 void LLNameValue::init(const char *name, const char *data, const char *type, const char *nvclass, const char *nvsendto, TNameValueCallback nvcb, void **user_data)
diff --git a/indra/llmessage/lluseroperation.cpp b/indra/llmessage/lluseroperation.cpp
index f7506c955c..01e0cf170b 100644
--- a/indra/llmessage/lluseroperation.cpp
+++ b/indra/llmessage/lluseroperation.cpp
@@ -22,7 +22,8 @@ LLUserOperationMgr* gUserOperationMgr = NULL;
 
 LLUserOperation::LLUserOperation(const LLUUID& agent_id)
 :	mAgentID(agent_id),
-	mTimer()
+	mTimer(),
+	mNoExpire(FALSE)
 {
 	mTransactionID.generate();
 }
@@ -31,14 +32,16 @@ LLUserOperation::LLUserOperation(const LLUUID& agent_id,
 								 const LLUUID& transaction_id) :
 	mAgentID(agent_id),
 	mTransactionID(transaction_id),
-	mTimer()
+	mTimer(),
+	mNoExpire(FALSE)
 {
 }
 
 // protected constructor which is used by base classes that determine
 // transaction, agent, et. after construction.
 LLUserOperation::LLUserOperation() :
-	mTimer()
+	mTimer(),
+	mNoExpire(FALSE)
 {
 }
 
@@ -46,11 +49,19 @@ LLUserOperation::~LLUserOperation()
 {
 }
 
+void LLUserOperation::SetNoExpireFlag(const BOOL flag)
+{
+	mNoExpire = flag;
+}
 
 BOOL LLUserOperation::isExpired()
 {
-	const F32 EXPIRE_TIME_SECS = 10.f;
-	return mTimer.getElapsedTimeF32() > EXPIRE_TIME_SECS;
+	if (!mNoExpire)
+	{
+		const F32 EXPIRE_TIME_SECS = 10.f;
+		return mTimer.getElapsedTimeF32() > EXPIRE_TIME_SECS;
+	}
+	return FALSE;
 }
 
 void LLUserOperation::expire()
diff --git a/indra/llmessage/lluseroperation.h b/indra/llmessage/lluseroperation.h
index 61456bcdce..60cde39bf0 100644
--- a/indra/llmessage/lluseroperation.h
+++ b/indra/llmessage/lluseroperation.h
@@ -28,6 +28,9 @@ public:
 	// Operation never got necessary data, so expired	
 	virtual BOOL isExpired();
 
+	// ability to mark this operation as never expiring.
+	void SetNoExpireFlag(const BOOL flag);
+
 	// Send request to the dataserver
 	virtual void sendRequest() = 0;
 
@@ -47,6 +50,7 @@ protected:
 	LLUUID mAgentID;
 	LLUUID mTransactionID;
 	LLFrameTimer mTimer;
+	BOOL   mNoExpire;			// this is used for operations that expect an answer and will wait till it gets one. 
 };
 
 
diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h
index d66c286184..18a6a9efbe 100644
--- a/indra/llrender/llimagegl.h
+++ b/indra/llrender/llimagegl.h
@@ -116,7 +116,6 @@ public:
 	// Various GL/Rendering options
 	S32 mTextureMemory;
 	mutable F32  mLastBindTime;	// last time this was bound, by discard level
-	mutable F32  mLastBindAttempt;	// last time bindTexture was called on this texture
 
 private:
 	LLPointer<LLImageRaw> mSaveData; // used for destroyGL/restoreGL
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 66642d8f34..22acf46125 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -347,18 +347,6 @@ void LLFloater::init(const LLString& title,
 			LLResizeHandle::LEFT_TOP );
 		addChild(mResizeHandle[3]);
 	}
-	else
-	{
-		mResizeBar[0]	= NULL;
-		mResizeBar[1]	= NULL;
-		mResizeBar[2]	= NULL;
-		mResizeBar[3]	= NULL;
-
-		mResizeHandle[0] = NULL;
-		mResizeHandle[1] = NULL;
-		mResizeHandle[2] = NULL;
-		mResizeHandle[3] = NULL;
-	}
 
 	// Close button.
 	if (close_btn)
@@ -372,6 +360,13 @@ void LLFloater::init(const LLString& title,
 		mButtonsEnabled[BUTTON_MINIMIZE] = TRUE;
 	}
 
+	// Keep track of whether this window has ever been dragged while it
+	// was minimized.  If it has, we'll remember its position for the
+	// next time it's minimized.
+	mHasBeenDraggedWhileMinimized = FALSE;
+	mPreviousMinimizedLeft = 0;
+	mPreviousMinimizedBottom = 0;
+
 	buildButtons();
 
 	// JC - Don't do this here, because many floaters first construct themselves,
@@ -737,6 +732,16 @@ void LLFloater::userSetShape(const LLRect& new_rect)
 			}
 		}
 	}
+	else
+	{
+		// If minimized, and origin has changed, set
+		// mHasBeenDraggedWhileMinimized to TRUE
+		if ((new_rect.mLeft != old_rect.mLeft) ||
+			(new_rect.mBottom != old_rect.mBottom))
+		{
+			mHasBeenDraggedWhileMinimized = TRUE;
+		}
+	}
 }
 
 void LLFloater::setMinimized(BOOL minimize)
@@ -749,9 +754,19 @@ void LLFloater::setMinimized(BOOL minimize)
 
 		reshape( MINIMIZED_WIDTH, LLFLOATER_HEADER_SIZE, TRUE);
 
-		S32 left, bottom;
-		gFloaterView->getMinimizePosition(&left, &bottom);
-		setOrigin( left, bottom );
+		// If the floater has been dragged while minimized in the
+		// past, then locate it at its previous minimized location.
+		// Otherwise, ask the view for a minimize position.
+		if (mHasBeenDraggedWhileMinimized)
+		{
+			setOrigin(mPreviousMinimizedLeft, mPreviousMinimizedBottom);
+		}
+		else
+		{
+			S32 left, bottom;
+			gFloaterView->getMinimizePosition(&left, &bottom);
+			setOrigin( left, bottom );
+		}
 
 		if (mButtonsEnabled[BUTTON_MINIMIZE])
 		{
@@ -804,6 +819,15 @@ void LLFloater::setMinimized(BOOL minimize)
 	}
 	else
 	{
+		// If this window has been dragged while minimized (at any time),
+		// remember its position for the next time it's minimized.
+		if (mHasBeenDraggedWhileMinimized)
+		{
+			const LLRect& currentRect = getRect();
+			mPreviousMinimizedLeft = currentRect.mLeft;
+			mPreviousMinimizedBottom = currentRect.mBottom;
+		}
+
 		reshape( mPreviousRect.getWidth(), mPreviousRect.getHeight(), TRUE );
 		setOrigin( mPreviousRect.mLeft, mPreviousRect.mBottom );
 
@@ -1020,7 +1044,6 @@ BOOL LLFloater::handleMouseDown(S32 x, S32 y, MASK mask)
 	if( mMinimized )
 	{
 		// Offer the click to the close button.
-		// Any other click = restore
 		if( mButtonsEnabled[BUTTON_CLOSE] )
 		{
 			S32 local_x = x - mButtons[BUTTON_CLOSE]->getRect().mLeft;
@@ -1034,9 +1057,22 @@ BOOL LLFloater::handleMouseDown(S32 x, S32 y, MASK mask)
 			}
 		}
 
-		// restore
-		bringToFront( x, y );
-		return TRUE;
+		// Offer the click to the restore button.
+		if( mButtonsEnabled[BUTTON_RESTORE] )
+		{
+			S32 local_x = x - mButtons[BUTTON_RESTORE]->getRect().mLeft;
+			S32 local_y = y - mButtons[BUTTON_RESTORE]->getRect().mBottom;
+
+			if (mButtons[BUTTON_RESTORE]->pointInView(local_x, local_y)
+				&& mButtons[BUTTON_RESTORE]->handleMouseDown(local_x, local_y, mask))
+			{
+				// restore button handled it, return
+				return TRUE;
+			}
+		}
+
+		// Otherwise pass to drag handle for movement
+		return mDragHandle->handleMouseDown(x, y, mask);
 	}
 	else
 	{
@@ -1448,30 +1484,14 @@ void	LLFloater::setCanResize(BOOL can_resize)
 {
 	if (mResizable && !can_resize)
 	{
-		removeChild(mResizeBar[0]);
-		removeChild(mResizeBar[1]);
-		removeChild(mResizeBar[2]);
-		removeChild(mResizeBar[3]);
-		removeChild(mResizeHandle[0]);
-		removeChild(mResizeHandle[1]);
-		removeChild(mResizeHandle[2]);
-		removeChild(mResizeHandle[3]);
-		delete mResizeBar[0];
-		delete mResizeBar[1];
-		delete mResizeBar[2];
-		delete mResizeBar[3];
-		delete mResizeHandle[0];
-		delete mResizeHandle[1];
-		delete mResizeHandle[2];
-		mResizeHandle[3] = NULL;
-		mResizeBar[0] = NULL;
-		mResizeBar[1] = NULL;
-		mResizeBar[2] = NULL;
-		mResizeBar[3] = NULL;
-		mResizeHandle[0] = NULL;
-		mResizeHandle[1] = NULL;
-		mResizeHandle[2] = NULL;
-		mResizeHandle[3] = NULL;
+		for (S32 i = 0; i < 4; i++) 
+		{
+			removeChild(mResizeBar[i], TRUE);
+			mResizeBar[i] = NULL; 
+
+			removeChild(mResizeHandle[i], TRUE);
+			mResizeHandle[i] = NULL;
+		}
 	}
 	else if (!mResizable && can_resize)
 	{
diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h
index c71f3df3e8..1491f75683 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -261,6 +261,10 @@ protected:
 	static handle_map_t	sFloaterMap;
 
 	std::vector<LLView*> mMinimizedHiddenChildren;
+
+	BOOL			mHasBeenDraggedWhileMinimized;
+	S32				mPreviousMinimizedBottom;
+	S32				mPreviousMinimizedLeft;
 };
 
 /////////////////////////////////////////////////////////////
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index 2cae50bd04..5857f49a3e 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -152,6 +152,14 @@ LLXMLNodePtr LLMenuItemGL::getXML(bool save_children) const
 		out << LLKeyboard::stringFromKey(mAcceleratorKey);
 
 		node->createChild("shortcut", TRUE)->setStringValue(out.str());
+		
+#ifdef LL_DARWIN
+		// Write in special tag if this key is really a ctrl combination on the Mac
+		if (mAcceleratorMask & MASK_MAC_CONTROL)
+		{
+			node->createChild("useMacCtrl", TRUE)->setBoolValue( TRUE );
+		}
+#endif // LL_DARWIN
 	}
 
 	return node;
@@ -184,7 +192,7 @@ BOOL LLMenuItemGL::handleKey(KEY key, MASK mask, BOOL called_from_parent)
 
 BOOL LLMenuItemGL::handleAcceleratorKey(KEY key, MASK mask)
 {
-	if( mEnabled && (!gKeyboard->getKeyRepeated(key) || mAllowKeyRepeat) && (key == mAcceleratorKey) && (mask == mAcceleratorMask) )
+	if( mEnabled && (!gKeyboard->getKeyRepeated(key) || mAllowKeyRepeat) && (key == mAcceleratorKey) && (mask == (mAcceleratorMask & MASK_NORMALKEYS)) )
 	{
 		doIt();
 		return TRUE;
@@ -216,7 +224,7 @@ BOOL LLMenuItemGL::addToAcceleratorList(std::list <LLKeyBinding*> *listp)
 		for (list_it = listp->begin(); list_it != listp->end(); ++list_it)
 		{
 			accelerator = *list_it;
-			if ((accelerator->mKey == mAcceleratorKey) && (accelerator->mMask == mAcceleratorMask))
+			if ((accelerator->mKey == mAcceleratorKey) && (accelerator->mMask == (mAcceleratorMask & MASK_NORMALKEYS)))
 			{
 
 			// *NOTE: get calling code to throw up warning or route
@@ -240,7 +248,7 @@ BOOL LLMenuItemGL::addToAcceleratorList(std::list <LLKeyBinding*> *listp)
 			if (accelerator)
 			{
 				accelerator->mKey = mAcceleratorKey;
-				accelerator->mMask = mAcceleratorMask;
+				accelerator->mMask = (mAcceleratorMask & MASK_NORMALKEYS);
 // 				accelerator->mName = mLabel;
 			}
 			listp->push_back(accelerator);//addData(accelerator);
@@ -264,7 +272,16 @@ void LLMenuItemGL::appendAcceleratorString( LLString& st )
 	// Standard Mac names for modifier keys in menu equivalents
 	// We could use the symbol characters, but they only exist in certain fonts.
 	if( mAcceleratorMask & MASK_CONTROL )
-		st.append( "Cmd-" );		// Symbol would be "\xE2\x8C\x98"
+	{
+		if ( mAcceleratorMask & MASK_MAC_CONTROL )
+		{
+			st.append( "Ctrl-" );
+		}
+		else
+		{
+			st.append( "Cmd-" );		// Symbol would be "\xE2\x8C\x98"
+		}
+	}
 	if( mAcceleratorMask & MASK_ALT )
 		st.append( "Opt-" );		// Symbol would be "\xE2\x8C\xA5"
 	if( mAcceleratorMask & MASK_SHIFT )
@@ -279,7 +296,7 @@ void LLMenuItemGL::appendAcceleratorString( LLString& st )
 #endif
 
 	LLString keystr = LLKeyboard::stringFromKey( mAcceleratorKey );
-	if ((mAcceleratorMask & (MASK_CONTROL|MASK_ALT|MASK_SHIFT)) &&
+	if ((mAcceleratorMask & MASK_NORMALKEYS) &&
 		(keystr[0] == '-' || keystr[0] == '='))
 	{
 		st.append( " " );
@@ -978,7 +995,7 @@ void LLMenuItemCallGL::buildDrawLabel( void )
 
 BOOL LLMenuItemCallGL::handleAcceleratorKey( KEY key, MASK mask )
 {
- 	if( (!gKeyboard->getKeyRepeated(key) || mAllowKeyRepeat) && (key == mAcceleratorKey) && (mask == mAcceleratorMask) )
+ 	if( (!gKeyboard->getKeyRepeated(key) || mAllowKeyRepeat) && (key == mAcceleratorKey) && (mask == (mAcceleratorMask & MASK_NORMALKEYS)) )
 	{
 		LLPointer<LLEvent> fired_event = new LLEvent(this);
 		fireEvent(fired_event, "on_build");
@@ -1945,10 +1962,23 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory
 				child->hasName(LL_MENU_ITEM_CHECK_GL_TAG))
 			{
 				MASK mask = 0;
+							
+#ifdef LL_DARWIN
+				// See if this Mac accelerator should really use the ctrl key and not get mapped to cmd
+				BOOL useMacCtrl = FALSE;
+				child->getAttributeBOOL("useMacCtrl", useMacCtrl);
+#endif // LL_DARWIN
+				
 				LLString shortcut;
 				child->getAttributeString("shortcut", shortcut);
 				if (shortcut.find("control") != shortcut.npos)
 				{
+#ifdef LL_DARWIN
+					if ( useMacCtrl )
+					{
+						mask |= MASK_MAC_CONTROL;
+					}
+#endif // LL_DARWIN
 					mask |= MASK_CONTROL;
 				}
 				if (shortcut.find("alt") != shortcut.npos)
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index 7506559b98..eb59765927 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -83,9 +83,9 @@ BOOL LLTextCmd::hasExtCharValue( llwchar value )
 }
 
 // Utility funcs
-S32 LLTextCmd::insert(LLTextEditor* editor, S32 pos, const LLWString &utf8str)
+S32 LLTextCmd::insert(LLTextEditor* editor, S32 pos, const LLWString &wstr)
 {
-	return editor->insertStringNoUndo( pos, utf8str );
+	return editor->insertStringNoUndo( pos, wstr );
 }
 S32 LLTextCmd::remove(LLTextEditor* editor, S32 pos, S32 length)
 {
@@ -102,29 +102,29 @@ class LLTextCmdInsert : public LLTextCmd
 {
 public:
 	LLTextCmdInsert(S32 pos, BOOL group_with_next, const LLWString &ws)
-		: LLTextCmd(pos, group_with_next), mString(ws)
+		: LLTextCmd(pos, group_with_next), mWString(ws)
 	{
 	}
 	virtual BOOL execute( LLTextEditor* editor, S32* delta )
 	{
-		*delta = insert(editor, mPos, mString );
-		LLWString::truncate(mString, *delta);
-		//mString = wstring_truncate(mString, *delta);
+		*delta = insert(editor, mPos, mWString );
+		LLWString::truncate(mWString, *delta);
+		//mWString = wstring_truncate(mWString, *delta);
 		return (*delta != 0);
 	}	
 	virtual S32 undo( LLTextEditor* editor )
 	{
-		remove(editor, mPos, mString.length() );
+		remove(editor, mPos, mWString.length() );
 		return mPos;
 	}
 	virtual S32 redo( LLTextEditor* editor )
 	{
-		insert(editor, mPos, mString );
-		return mPos + mString.length();
+		insert(editor, mPos, mWString );
+		return mPos + mWString.length();
 	}
 
 private:
-	LLWString mString;
+	LLWString mWString;
 };
 
 ///////////////////////////////////////////////////////////////////
@@ -133,7 +133,7 @@ class LLTextCmdAddChar : public LLTextCmd
 {
 public:
 	LLTextCmdAddChar( S32 pos, BOOL group_with_next, llwchar wc)
-		: LLTextCmd(pos, group_with_next), mString(1, wc), mBlockExtensions(FALSE)
+		: LLTextCmd(pos, group_with_next), mWString(1, wc), mBlockExtensions(FALSE)
 	{
 	}
 	virtual void blockExtensions()
@@ -142,13 +142,13 @@ public:
 	}
 	virtual BOOL canExtend(S32 pos)
 	{
-		return !mBlockExtensions && (pos == mPos + (S32)mString.length());
+		return !mBlockExtensions && (pos == mPos + (S32)mWString.length());
 	}
 	virtual BOOL execute( LLTextEditor* editor, S32* delta )
 	{
-		*delta = insert(editor, mPos, mString);
-		LLWString::truncate(mString, *delta);
-		//mString = wstring_truncate(mString, *delta);
+		*delta = insert(editor, mPos, mWString);
+		LLWString::truncate(mWString, *delta);
+		//mWString = wstring_truncate(mWString, *delta);
 		return (*delta != 0);
 	}
 	virtual BOOL extendAndExecute( LLTextEditor* editor, S32 pos, llwchar wc, S32* delta )	
@@ -159,23 +159,23 @@ public:
 		*delta = insert(editor, pos, ws);
 		if( *delta > 0 )
 		{
-			mString += wc;
+			mWString += wc;
 		}
 		return (*delta != 0);
 	}
 	virtual S32 undo( LLTextEditor* editor )
 	{
-		remove(editor, mPos, mString.length() );
+		remove(editor, mPos, mWString.length() );
 		return mPos;
 	}
 	virtual S32 redo( LLTextEditor* editor )
 	{
-		insert(editor, mPos, mString );
-		return mPos + mString.length();
+		insert(editor, mPos, mWString );
+		return mPos + mWString.length();
 	}
 
 private:
-	LLWString	mString;
+	LLWString	mWString;
 	BOOL		mBlockExtensions;
 
 };
@@ -222,14 +222,14 @@ public:
 	}
 	virtual BOOL execute( LLTextEditor* editor, S32* delta )
 	{ 
-		mString = editor->getWSubString(mPos, mLen);
+		mWString = editor->getWSubString(mPos, mLen);
 		*delta = remove(editor, mPos, mLen );
 		return (*delta != 0);
 	}
 	virtual S32 undo( LLTextEditor* editor )
 	{
-		insert(editor, mPos, mString );
-		return mPos + mString.length();
+		insert(editor, mPos, mWString );
+		return mPos + mWString.length();
 	}
 	virtual S32 redo( LLTextEditor* editor )
 	{
@@ -237,7 +237,7 @@ public:
 		return mPos;
 	}
 private:
-	LLWString	mString;
+	LLWString	mWString;
 	S32				mLen;
 };
 
diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h
index 1a82d3e8c8..0b6e291843 100644
--- a/indra/llui/lltexteditor.h
+++ b/indra/llui/lltexteditor.h
@@ -309,7 +309,7 @@ protected:
 	S32				append(const LLWString &wstr, const BOOL group_with_next_op);
 	
 	// direct operations
-	S32				insertStringNoUndo(S32 pos, const LLWString &utf8str); // returns num of chars actually inserted
+	S32				insertStringNoUndo(S32 pos, const LLWString &wstr); // returns num of chars actually inserted
 	S32 			removeStringNoUndo(S32 pos, S32 length);
 	S32				overwriteCharNoUndo(S32 pos, llwchar wc);
 	
@@ -475,7 +475,7 @@ public:
 	virtual BOOL	hasExtCharValue( llwchar value );
 
 	// Define these here so they can access LLTextEditor through the friend relationship
-	S32				insert(LLTextEditor* editor, S32 pos, const LLWString &utf8str);
+	S32				insert(LLTextEditor* editor, S32 pos, const LLWString &wstr);
 	S32 			remove(LLTextEditor* editor, S32 pos, S32 length);
 	S32				overwrite(LLTextEditor* editor, S32 pos, llwchar wc);
 	
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp
index afa78984ea..299ccc39f3 100644
--- a/indra/llwindow/llwindowwin32.cpp
+++ b/indra/llwindow/llwindowwin32.cpp
@@ -1565,6 +1565,11 @@ void LLWindowWin32::moveWindow( const LLCoordScreen& position, const LLCoordScre
 		}
 	}
 
+	// if the window was already maximized, MoveWindow seems to still set the maximized flag even if
+	// the window is smaller than maximized.
+	// So we're going to do a restore first (which is a ShowWindow call) (SL-44655).
+	ShowWindow(mWindowHandle, SW_RESTORE);
+	// NOW we can call MoveWindow
 	MoveWindow(mWindowHandle, position.mX, position.mY, size.mX, size.mY, TRUE);
 }
 
@@ -2269,6 +2274,13 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
 						<< llendl;
 				}
 
+				// There's an odd behavior with WM_SIZE that I would call a bug. If 
+				// the window is maximized, and you call MoveWindow() with a size smaller
+				// than a maximized window, it ends up sending WM_SIZE with w_param set 
+				// to SIZE_MAXIMIZED -- which isn't true. So the logic below doesn't work.
+				// (SL-44655). Fixed it by calling ShowWindow(SW_RESTORE) first (see 
+				// LLWindowWin32::moveWindow in this file). 
+
 				// If we are now restored, but we weren't before, this
 				// means that the window was un-minimized.
 				if (w_param == SIZE_RESTORED && window_imp->mLastSizeWParam != SIZE_RESTORED)
diff --git a/indra/llxml/llxmlnode.h b/indra/llxml/llxmlnode.h
index 56e66f2f9d..4084a45795 100644
--- a/indra/llxml/llxmlnode.h
+++ b/indra/llxml/llxmlnode.h
@@ -10,7 +10,11 @@
 #define LL_LLXMLNODE_H
 
 #define XML_STATIC
+#ifdef LL_STANDALONE
+#include <expat.h>
+#else
 #include "expat/expat.h"
+#endif
 #include <map>
 
 #include "indra_constants.h"
diff --git a/indra/llxml/llxmlparser.h b/indra/llxml/llxmlparser.h
index 2ef790094e..a378c15265 100644
--- a/indra/llxml/llxmlparser.h
+++ b/indra/llxml/llxmlparser.h
@@ -10,7 +10,11 @@
 #define LL_LLXMLPARSER_H
 
 #define XML_STATIC
+#ifdef LL_STANDALONE
+#include <expat.h>
+#else
 #include "expat/expat.h"
+#endif
 
 class LLXmlParser
 {
diff --git a/indra/lscript/lscript_compile/indra.y b/indra/lscript/lscript_compile/indra.y
index c7a4fd6289..49d0c38b30 100644
--- a/indra/lscript/lscript_compile/indra.y
+++ b/indra/lscript/lscript_compile/indra.y
@@ -15,6 +15,10 @@
     #define getenv getenv_workaround
     #endif
 
+    #ifdef LL_WINDOWS
+	#pragma warning( disable : 4065 )	// warning: switch statement contains 'default' but no 'case' labels
+	#endif
+
     #ifdef __cplusplus
     }
     #endif
diff --git a/indra/newview/linux_tools/wrapper.sh b/indra/newview/linux_tools/wrapper.sh
index d77da8814c..d39fc3a8d1 100755
--- a/indra/newview/linux_tools/wrapper.sh
+++ b/indra/newview/linux_tools/wrapper.sh
@@ -48,6 +48,23 @@ export SDL_VIDEO_X11_DGAMOUSE=0
 
 RUN_PATH=`dirname "$0" || echo .`
 cd "${RUN_PATH}"
+if [ -n "$LL_TCMALLOC" ]; then
+    tcmalloc_libs='/usr/lib/libtcmalloc.so.0 /usr/lib/libstacktrace.so.0 /lib/libpthread.so.0'
+    all=1
+    for f in $tcmalloc_libs; do
+        if [ ! -f $f ]; then
+	    all=0
+	fi
+    done
+    if [ $all != 1 ]; then
+        echo 'Cannot use tcmalloc libraries: components missing' 1>&2
+    else
+	export LD_PRELOAD=$(echo $tcmalloc_libs | tr ' ' :)
+	if [ -z "$HEAPCHECK" -a -z "$HEAPPROFILE" ]; then
+	    export HEAPCHECK=${HEAPCHECK:-normal}
+	fi
+    fi
+fi
 LD_LIBRARY_PATH="`pwd`"/lib:"`pwd`"/app_settings/mozilla-runtime-linux-i686:"${LD_LIBRARY_PATH}" $LL_WRAPPER bin/do-not-directly-run-secondlife-bin `cat gridargs.dat` $@ | cat
 
 echo
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index a304d52f13..3a9c76cfc1 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -21,7 +21,6 @@
 #include "lldarrayptr.h"
 #include "llvertexbuffer.h"
 #include "llviewerimage.h"
-#include "llpagemem.h"
 #include "llstat.h"
 #include "lldrawable.h"
 
diff --git a/indra/newview/llfloaterfriends.cpp b/indra/newview/llfloaterfriends.cpp
index 4f1da916fc..7e0a64c420 100644
--- a/indra/newview/llfloaterfriends.cpp
+++ b/indra/newview/llfloaterfriends.cpp
@@ -71,6 +71,7 @@ LLFloaterFriends::LLFloaterFriends() :
 	gSavedSettings.setBOOL("ShowFriends", TRUE);
 	// Builds and adds to gFloaterView
 	gUICtrlFactory->buildFloater(this, "floater_friends.xml");
+	refreshUI();
 }
 
 LLFloaterFriends::~LLFloaterFriends()
@@ -196,7 +197,6 @@ BOOL LLFloaterFriends::postBuild()
 	childSetAction("remove_btn", onClickRemove, this);
 	childSetAction("close_btn", onClickClose, this);
 
-	refreshUI();
 	return TRUE;
 }
 
diff --git a/indra/newview/llfloaterinspect.cpp b/indra/newview/llfloaterinspect.cpp
index daf3067d7b..388e8d9cbd 100644
--- a/indra/newview/llfloaterinspect.cpp
+++ b/indra/newview/llfloaterinspect.cpp
@@ -54,18 +54,21 @@ BOOL LLFloaterInspect::isVisible()
 
 void LLFloaterInspect::show(void* ignored)
 {
-	if(sInstance)
-	{
-		sInstance->open();
-	}
-	else
+	// setForceSelection ensures that the pie menu does not deselect things when it 
+	// looses the focus (this can happen with "select own objects only" enabled
+	// VWR-1471
+	BOOL forcesel = gSelectMgr->setForceSelection(TRUE);
+
+	if (!sInstance)	// first use
 	{
-		LLFloaterInspect* self = new LLFloaterInspect;
-		self->open();
+		sInstance = new LLFloaterInspect;
 	}
 
-	sInstance->mObjectSelection = gSelectMgr->getSelection();
+	sInstance->open();
 	select_tool(gToolInspect);
+	gSelectMgr->setForceSelection(forcesel);	// restore previouis value
+
+	sInstance->mObjectSelection = gSelectMgr->getSelection();
 	sInstance->refresh();
 }
 
diff --git a/indra/newview/llfloaterscriptdebug.cpp b/indra/newview/llfloaterscriptdebug.cpp
index 1cf10ae881..0ba75b71f6 100644
--- a/indra/newview/llfloaterscriptdebug.cpp
+++ b/indra/newview/llfloaterscriptdebug.cpp
@@ -31,10 +31,12 @@ LLFloaterScriptDebug*	LLFloaterScriptDebug::sInstance = NULL;
 //
 // Member Functions
 //
-LLFloaterScriptDebug::LLFloaterScriptDebug() 
-: LLMultiFloater()
+LLFloaterScriptDebug::LLFloaterScriptDebug() : 
+	LLMultiFloater()
 {
-
+	// avoid resizing of the window to match 
+	// the initial size of the tabbed-childs, whenever a tab is opened or closed
+	mAutoResize = FALSE;
 }
 
 LLFloaterScriptDebug::~LLFloaterScriptDebug()
@@ -90,6 +92,9 @@ LLFloater* LLFloaterScriptDebug::addOutputWindow(const LLUUID &object_id)
 	}
 	LLFloater::setFloaterHost(NULL);
 
+	// Tabs sometimes overlap resize handle
+	sInstance->moveResizeHandleToFront();
+
 	return floaterp;
 }
 
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp
index b47ec270e3..80e32f9c00 100644
--- a/indra/newview/llfloatersnapshot.cpp
+++ b/indra/newview/llfloatersnapshot.cpp
@@ -105,7 +105,7 @@ public:
 	void updateSnapshot(BOOL new_snapshot);
 	LLFloaterPostcard* savePostcard();
 	void saveTexture();
-	void saveLocal();
+	BOOL saveLocal();
 
 	static void onIdle( void* snapshot_preview );
 
@@ -678,9 +678,9 @@ void LLSnapshotLivePreview::saveTexture()
 	gViewerStats->incStat(LLViewerStats::ST_SNAPSHOT_COUNT );	
 }
 
-void LLSnapshotLivePreview::saveLocal()
+BOOL LLSnapshotLivePreview::saveLocal()
 {
-	gViewerWindow->saveImageNumbered(mRawImage);
+	return gViewerWindow->saveImageNumbered(mRawImage);
 }
 
 ///----------------------------------------------------------------------------
@@ -939,6 +939,8 @@ void LLFloaterSnapshot::Impl::onClickKeep(void* data)
 	
 	if (previewp)
 	{
+		BOOL succeeded = TRUE; // Only used for saveLocal for now
+
 		if (previewp->getSnapshotType() == LLSnapshotLivePreview::SNAPSHOT_POSTCARD)
 		{
 			LLFloaterPostcard* floater = previewp->savePostcard();
@@ -957,21 +959,24 @@ void LLFloaterSnapshot::Impl::onClickKeep(void* data)
 		}
 		else
 		{
-			previewp->saveLocal();
+			succeeded = previewp->saveLocal();
 		}
 
 		if (gSavedSettings.getBOOL("CloseSnapshotOnKeep"))
 		{
 			view->close();
-			// only plays sound and anim when keeping a snapshot, and closing the snapshot UI
-			gViewerWindow->playSnapshotAnimAndSound();
+			// only plays sound and anim when keeping a snapshot, and closing the snapshot UI,
+			// and only if the save succeeded (i.e. was not canceled)
+			if (succeeded)
+			{
+				gViewerWindow->playSnapshotAnimAndSound();
+			}
 		}
 		else
 		{
 			checkAutoSnapshot(previewp);
 		}
 	}
-
 }
 
 // static
diff --git a/indra/newview/llhudeffectlookat.cpp b/indra/newview/llhudeffectlookat.cpp
index 350a20607c..244583464a 100644
--- a/indra/newview/llhudeffectlookat.cpp
+++ b/indra/newview/llhudeffectlookat.cpp
@@ -422,12 +422,25 @@ void LLHUDEffectLookAt::update()
 	}
 }
 
+/**
+ * Initializes the mTargetPos member from the current mSourceObjec and mTargetObject
+ * (and possibly mTargetOffsetGlobal).
+ * When mTargetObject is another avatar, it sets mTargetPos to be their eyes.
+ * 
+ * Has the side-effect of also calling setAnimationData("LookAtPoint") with the new
+ * mTargetPos on the source object which is assumed to be an avatar.
+ */
 void LLHUDEffectLookAt::calcTargetPosition()
 {
-	LLViewerObject *targetObject = (LLViewerObject *)mTargetObject;
+	if (gNoRender)
+	{
+		return;
+	}
+
+	LLViewerObject *target_obj = (LLViewerObject *)mTargetObject;
 	LLVector3 local_offset;
 	
-	if (targetObject)
+	if (target_obj)
 	{
 		local_offset.setVec(mTargetOffsetGlobal);
 	}
@@ -436,20 +449,16 @@ void LLHUDEffectLookAt::calcTargetPosition()
 		local_offset = gAgent.getPosAgentFromGlobal(mTargetOffsetGlobal);
 	}
 
-	if (gNoRender)
-	{
-		return;
-	}
-	LLVector3 head_position = ((LLVOAvatar*)(LLViewerObject*)mSourceObject)->mHeadp->getWorldPosition();
+	LLVOAvatar* source_avatar = (LLVOAvatar*)(LLViewerObject*)mSourceObject;
 
-	if (targetObject && targetObject->mDrawable.notNull())
+	if (target_obj && target_obj->mDrawable.notNull())
 	{
-		LLQuaternion objRot;
-		if (targetObject->isAvatar())
+		LLQuaternion target_rot;
+		if (target_obj->isAvatar())
 		{
-			LLVOAvatar *avatarp = (LLVOAvatar *)targetObject;
+			LLVOAvatar *target_av = (LLVOAvatar *)target_obj;
 
-			BOOL looking_at_self = ((LLVOAvatar*)(LLViewerObject*)mSourceObject)->isSelf() && avatarp->isSelf();
+			BOOL looking_at_self = source_avatar->isSelf() && target_av->isSelf();
 
 			// if selecting self, stare forward
 			if (looking_at_self && mTargetOffsetGlobal.magVecSquared() < MIN_TARGET_OFFSET_SQUARED)
@@ -459,46 +468,46 @@ void LLHUDEffectLookAt::calcTargetPosition()
 				local_offset.setVec(mTargetOffsetGlobal);
 			}
 
-			mTargetPos = avatarp->mHeadp->getWorldPosition();
+			// look the other avatar in the eye. note: what happens if target is self? -MG
+			mTargetPos = target_av->mHeadp->getWorldPosition();
 			if (mTargetType == LOOKAT_TARGET_MOUSELOOK || mTargetType == LOOKAT_TARGET_FREELOOK)
 			{
 				// mouselook and freelook target offsets are absolute
-				objRot = LLQuaternion::DEFAULT;
+				target_rot = LLQuaternion::DEFAULT;
 			}
 			else if (looking_at_self && gAgent.cameraCustomizeAvatar())
 			{
 				// *NOTE: We have to do this because animation
 				// overrides do not set lookat behavior.
 				// *TODO: animation overrides for lookat behavior.
-				objRot = avatarp->mPelvisp->getWorldRotation();
+				target_rot = target_av->mPelvisp->getWorldRotation();
 			}
 			else
 			{
-				objRot = avatarp->mRoot.getWorldRotation();
+				target_rot = target_av->mRoot.getWorldRotation();
 			}
 		}
-		else
+		else // target obj is not an avatar
 		{
-			if (targetObject->mDrawable->getGeneration() == -1)
+			if (target_obj->mDrawable->getGeneration() == -1)
 			{
-				mTargetPos = targetObject->getPositionAgent();
-				objRot = targetObject->getWorldRotation();
+				mTargetPos = target_obj->getPositionAgent();
+				target_rot = target_obj->getWorldRotation();
 			}
 			else
 			{
-				mTargetPos = targetObject->getRenderPosition();
-				objRot = targetObject->getRenderRotation();
+				mTargetPos = target_obj->getRenderPosition();
+				target_rot = target_obj->getRenderRotation();
 			}
 		}
 
-		mTargetPos += (local_offset * objRot);
+		mTargetPos += (local_offset * target_rot);
 	}
-	else
+	else // no target obj or it's not drawable
 	{
 		mTargetPos = local_offset;
 	}
 
-	mTargetPos -= head_position;
-
-	((LLVOAvatar*)(LLViewerObject*)mSourceObject)->setAnimationData("LookAtPoint", (void *)&mTargetPos);
+	mTargetPos -= source_avatar->mHeadp->getWorldPosition();
+	source_avatar->setAnimationData("LookAtPoint", (void *)&mTargetPos);
 }
diff --git a/indra/newview/llimpanel.cpp b/indra/newview/llimpanel.cpp
index b2278f2752..015f90a180 100644
--- a/indra/newview/llimpanel.cpp
+++ b/indra/newview/llimpanel.cpp
@@ -236,11 +236,10 @@ void LLFloaterIMPanel::init(const LLString& session_label)
 			mSessionStartMsgPos = 
 				mHistoryEditor->getText().length();
 
-			bool log_to_file = false;
 			addHistoryLine(
 				session_start,
 				LLColor4::grey,
-				log_to_file);
+				false);
 		}
 	}
 }
@@ -748,7 +747,17 @@ void LLFloaterIMPanel::sendMsg()
 					history_echo += ": ";
 				}
 				history_echo += utf8_text;
+
+				
+				BOOL other_was_typing = mOtherTyping;
+
 				addHistoryLine(history_echo);
+
+				if (other_was_typing) 
+				{
+					addTypingIndicator(mOtherTypingName);
+				}
+
 			}
 		}
 		else
@@ -850,7 +859,7 @@ void LLFloaterIMPanel::processIMTyping(const LLIMInfo* im_info, BOOL typing)
 	if (typing)
 	{
 		// other user started typing
-		addTypingIndicator(im_info);
+		addTypingIndicator(im_info->mName);
 	}
 	else
 	{
@@ -860,15 +869,18 @@ void LLFloaterIMPanel::processIMTyping(const LLIMInfo* im_info, BOOL typing)
 }
 
 
-void LLFloaterIMPanel::addTypingIndicator(const LLIMInfo* im_info)
+void LLFloaterIMPanel::addTypingIndicator(const std::string &name)
 {
-	mTypingLineStartIndex = mHistoryEditor->getText().length();
-
-	LLUIString typing_start = sTypingStartString;
-	typing_start.setArg("[NAME]", im_info->mName);
-	bool log_to_file = false;
-	addHistoryLine(typing_start, LLColor4::grey, log_to_file);
-	mOtherTyping = TRUE;
+	// we may have lost a "stop-typing" packet, don't add it twice
+	if (!mOtherTyping)
+	{
+		mTypingLineStartIndex = mHistoryEditor->getText().length();
+		LLUIString typing_start = sTypingStartString;
+		typing_start.setArg("[NAME]", name);
+		addHistoryLine(typing_start, LLColor4::grey, false);
+		mOtherTypingName = name;
+		mOtherTyping = TRUE;
+	}
 }
 
 
diff --git a/indra/newview/llimpanel.h b/indra/newview/llimpanel.h
index 28ea002583..cb8042e010 100644
--- a/indra/newview/llimpanel.h
+++ b/indra/newview/llimpanel.h
@@ -105,7 +105,7 @@ private:
 	void setTyping(BOOL typing);
 
 	// Add the "User is typing..." indicator.
-	void addTypingIndicator(const LLIMInfo* im_info);
+	void addTypingIndicator(const std::string &name);
 
 	// Remove the "User is typing..." indicator.
 	void removeTypingIndicator();
@@ -145,6 +145,9 @@ private:
 	// Is other user currently typing?
 	BOOL mOtherTyping;
 
+	// name of other user who is currently typing
+	std::string mOtherTypingName;
+
 	// Where does the "User is typing..." line start?
 	S32 mTypingLineStartIndex;
 	//Where does the "Starting session..." line start?
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 5a40b4a7c1..336da9ac79 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -111,6 +111,11 @@ static LLUUID compute_session_id(EInstantMessage dialog,
 
 LLFloaterIM::LLFloaterIM() 
 {
+	// autoresize=false is necessary to avoid resizing of the IM window whenever 
+	// a session is opened or closed (it would otherwise resize the window to match
+	// the size of the im-sesssion when they were created.  This happens in 
+	// LLMultiFloater::resizeToContents() when called through LLMultiFloater::addFloater())
+	this->mAutoResize = FALSE;
 	gUICtrlFactory->buildFloater(this, "floater_im.xml");
 }
 
@@ -186,12 +191,16 @@ void LLFloaterIM::onClose(bool app_quitting)
 //virtual
 void LLFloaterIM::addFloater(LLFloater* floaterp, BOOL select_added_floater, LLTabContainer::eInsertionPoint insertion_point)
 {
+/*
+	Code removed via patch from VWR-1626
+
 	// this code is needed to fix the bug where new IMs received will resize the IM floater.
 	// SL-29075, SL-24556, and others
 	LLRect parent_rect = getRect();
 	S32 dheight = LLFLOATER_HEADER_SIZE + TABCNTR_HEADER_HEIGHT;
 	LLRect rect(0, parent_rect.getHeight()-dheight, parent_rect.getWidth(), 0);
 	floaterp->reshape(rect.getWidth(), rect.getHeight(), TRUE);
+*/
 	LLMultiFloater::addFloater(floaterp, select_added_floater, insertion_point);
 }
 
diff --git a/indra/newview/llmemoryview.cpp b/indra/newview/llmemoryview.cpp
index 7fd2572e08..4bf8f0fa73 100644
--- a/indra/newview/llmemoryview.cpp
+++ b/indra/newview/llmemoryview.cpp
@@ -25,10 +25,20 @@
 
 #include "llfasttimer.h"
 
+
+
 LLMemoryView::LLMemoryView(const std::string& name, const LLRect& rect)
-:	LLView(name, rect, TRUE)
+:	LLView(name, rect, TRUE),
+mDelay(120)
 {
 	setVisible(FALSE);
+	mDumpTimer.reset();
+
+#ifdef MEM_DUMP_DATA
+	// clear out file.
+	FILE *dump = fopen("memusagedump.txt", "w");
+	fclose(dump);
+#endif
 }
 
 LLMemoryView::~LLMemoryView()
@@ -176,7 +186,7 @@ void LLMemoryView::draw()
 			peak += maxbytes;
 			S32 mbytes = bytes >> 20;
 
-			tdesc = llformat("%s [%4d MB]",mtv_display_table[i].desc,mbytes);
+			tdesc = llformat("%s [%4d MB] in %06d NEWS",mtv_display_table[i].desc,mbytes, LLMemType::sNewCount[tidx]);
 			LLFontGL::sMonospace->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
 			
 			y -= (texth + 2);
@@ -219,7 +229,46 @@ void LLMemoryView::draw()
 		y -= (texth + 2);
 	}
 
+	dumpData();
+
 #endif
 	
 	LLView::draw();
 }
+
+void LLMemoryView::setDataDumpInterval(float delay)
+{
+	mDelay = delay;
+}
+
+void LLMemoryView::dumpData()
+{
+#if MEM_TRACK_TYPE && MEM_DUMP_DATA
+	if (mDelay && (mDumpTimer.getElapsedTimeF32() > mDelay ))
+	{
+		// reset timer
+		mDumpTimer.reset();
+		// append dump info to text file
+		FILE *dump = fopen("memusagedump.txt", "a");
+
+		if (dump)
+		{
+			// write out total memory usage
+			fprintf (dump, "Total memory in use = %09d (%03d MB)\n", LLMemType::sTotalMem, LLMemType::sTotalMem>>20);
+			fprintf (dump, "High Water Mark = %09d (%03d MB)\n\n", LLMemType::sMaxTotalMem, LLMemType::sMaxTotalMem>>20);
+			// dump out usage of 'new' for each memory type
+			for (S32 i=0; i<LLMemType::MTYPE_NUM_TYPES; i++)
+			{
+				if (LLMemType::sMemCount[i])
+				{
+					std::string outData = llformat("MEM: % 20s %09d %03d MB (%09d %03d MB) in %06d News", LLMemType::sTypeDesc[i], LLMemType::sMemCount[i], LLMemType::sMemCount[i]>>20, LLMemType::sMaxMemCount[i], LLMemType::sMaxMemCount[i]>>20, LLMemType::sNewCount[i]);
+					fprintf (dump, "%s\n", outData.c_str());
+				}
+			}
+			fprintf (dump, "\n\n");
+
+			fclose(dump);
+		}
+	}
+#endif
+}
diff --git a/indra/newview/llmemoryview.h b/indra/newview/llmemoryview.h
index f32242d06c..c566fa3b73 100644
--- a/indra/newview/llmemoryview.h
+++ b/indra/newview/llmemoryview.h
@@ -25,6 +25,13 @@ public:
 	virtual BOOL handleHover(S32 x, S32 y, MASK mask);
 	virtual void draw();
 
+private:
+	void setDataDumpInterval(float delay);
+	void dumpData();
+
+	float mDelay;
+	LLFrameTimer mDumpTimer;
+
 private:
 };
 
diff --git a/indra/newview/lloverlaybar.cpp b/indra/newview/lloverlaybar.cpp
index 27de489446..8e36297c93 100644
--- a/indra/newview/lloverlaybar.cpp
+++ b/indra/newview/lloverlaybar.cpp
@@ -101,7 +101,11 @@ LLOverlayBar::LLOverlayBar(const std::string& name, const LLRect& rect)
 	
 	if ( gAudiop )
 	{
-		mMusicRemote->setVolume ( gSavedSettings.getF32 ( "AudioLevelMusic" ) );
+		//HACK / NOT HACK
+		//maintenance patch - bhear obsoletes this, do not merge (poppy)
+		F32 audioLevelMusic = gSavedSettings.getF32 ( "AudioLevelMusic" );
+		mMusicRemote->setVolume ( audioLevelMusic );
+		gAudiop->setInternetStreamGain ( audioLevelMusic );
 		mMusicRemote->setTransportState ( LLMediaRemoteCtrl::Stop, FALSE );
 	};
 
diff --git a/indra/newview/llpanellogin.h b/indra/newview/llpanellogin.h
index 801b06ba55..d9d933400f 100644
--- a/indra/newview/llpanellogin.h
+++ b/indra/newview/llpanellogin.h
@@ -15,6 +15,7 @@
 #include "llmemory.h"
 #include "llviewerimage.h"
 #include "llstring.h"
+#include "llmd5.h"
 
 class LLTextBox;
 class LLLineEditor;
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 07e3853b27..9c9c5a9582 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -2029,6 +2029,13 @@ void LLLiveLSLEditor::saveIfNeeded()
 		return;
 	}
 	LLString utf8text = mScriptEd->mEditor->getText();
+
+	// Special case for a completely empty script - stuff in one space so it can store properly.  See SL-46889
+	if ( utf8text.size() == 0 )
+	{
+		utf8text = " ";
+	}
+
 	fputs(utf8text.c_str(), fp);
 	fclose(fp);
 	fp = NULL;
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 0ab674dfcd..54ac03a3c5 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -527,7 +527,7 @@ BOOL LLSelectMgr::removeObjectFromSelections(const LLUUID &id)
 	return object_found;
 }
 
-void LLSelectMgr::deselectObjectAndFamily(LLViewerObject* object, BOOL send_to_sim)
+void LLSelectMgr::deselectObjectAndFamily(LLViewerObject* object, BOOL send_to_sim, BOOL include_entire_object)
 {
 	// bail if nothing selected or if object wasn't selected in the first place
 	if(!object) return;
@@ -535,7 +535,30 @@ void LLSelectMgr::deselectObjectAndFamily(LLViewerObject* object, BOOL send_to_s
 
 	// Collect all of the objects, and remove them
 	LLDynamicArray<LLViewerObject*> objects;
-	object = (LLViewerObject*)object->getRoot();
+
+	if (include_entire_object)
+	{
+		// Since we're selecting a family, start at the root, but
+		// don't include an avatar.
+		LLViewerObject* root = object;
+	
+		while(!root->isAvatar() && root->getParent() && !root->isJointChild())
+		{
+			LLViewerObject* parent = (LLViewerObject*)root->getParent();
+			if (parent->isAvatar())
+			{
+				break;
+			}
+			root = parent;
+		}
+	
+		object = root;
+	}
+	else
+	{
+		object = (LLViewerObject*)object->getRoot();
+	}
+
 	object->addThisAndAllChildren(objects);
 	remove(objects);
 
@@ -5734,6 +5757,12 @@ BOOL LLSelectMgr::canSelectObject(LLViewerObject* object)
 	return TRUE;
 }
 
+BOOL LLSelectMgr::setForceSelection(BOOL force) 
+{ 
+	std::swap(mForceSelection,force); 
+	return force; 
+}
+
 LLObjectSelection::LLObjectSelection() : 
 	std::list<LLSelectNode*>(), 
 	LLRefCount(),
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index 283516671d..4986843798 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -219,7 +219,8 @@ public:
 	void updateEffects(); // Update HUD effects
 	void overrideObjectUpdates();
 
-	void setForceSelection(BOOL force) { mForceSelection = force; }
+	// Returns the previous value of mForceSelection
+	BOOL setForceSelection(BOOL force);
 
 	////////////////////////////////////////////////////////////////
 	// Selection methods
@@ -253,7 +254,7 @@ public:
 	////////////////////////////////////////////////////////////////
 
 	void deselectObjectOnly(LLViewerObject* object, BOOL send_to_sim = TRUE);
-	void deselectObjectAndFamily(LLViewerObject* object, BOOL send_to_sim = TRUE);
+	void deselectObjectAndFamily(LLViewerObject* object, BOOL send_to_sim = TRUE, BOOL include_entire_object = FALSE);
 
 	// Send deselect messages to simulator, then clear the list
 	void deselectAll();
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index be6756ad98..6d939ad3e9 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -763,12 +763,7 @@ BOOL idle_startup()
 		LLFile::mkdir(gDirUtilp->getChatLogsDir().c_str());
 		LLFile::mkdir(gDirUtilp->getPerAccountChatLogsDir().c_str());
 
-		
-#if LL_WINDOWS
-		if (gSavedSettings.getBOOL("UseDebugLogin") && show_connect_box)
-#else
 		if (show_connect_box)
-#endif
 		{
 			LLString server_label;
 			S32 domain_name_index;
@@ -779,10 +774,7 @@ BOOL idle_startup()
 			{
 				snprintf(gUserServerName, MAX_STRING, "%s", server_label.c_str());			/* Flawfinder: ignore */
 			}
-		}
 
-		if (show_connect_box)
-		{
 			LLString location;
 			LLPanelLogin::getLocation( location );
 			LLURLSimString::setString( location );
@@ -1139,8 +1131,10 @@ BOOL idle_startup()
 		case LLUserAuth::E_COULDNT_RESOLVE_HOST:
 		case LLUserAuth::E_SSL_PEER_CERTIFICATE:
 		case LLUserAuth::E_UNHANDLED_ERROR:
+		case LLUserAuth::E_SSL_CACERT:
+		case LLUserAuth::E_SSL_CONNECT_ERROR:
 		default:
-			if (auth_uri_num >= (int) auth_uris.size())
+			if (auth_uri_num >= (int) auth_uris.size() - 1)
 			{
 				emsg << "Unable to connect to " << gSecondLife << ".\n";
 				emsg << gUserAuthp->errorMessage();
@@ -1150,20 +1144,6 @@ BOOL idle_startup()
 				auth_desc = s.str();
 				gStartupState = STATE_LOGIN_AUTHENTICATE;
 				auth_uri_num++;
-				return do_normal_idle;
-			}
-			break;
-		case LLUserAuth::E_SSL_CACERT:
-		case LLUserAuth::E_SSL_CONNECT_ERROR:
-			if (auth_uri_num >= (int) auth_uris.size())
-			{
-				emsg << "Unable to establish a secure connection to the login server.\n";
-				emsg << gUserAuthp->errorMessage();
-			} else {
-				std::ostringstream s;
-				s << "Logging in (attempt " << (auth_uri_num + 1) << ").  ";
-				auth_desc = s.str();
-				gStartupState = STATE_LOGIN_AUTHENTICATE;
 				auth_uri_num++;
 				return do_normal_idle;
 			}
@@ -2342,9 +2322,15 @@ BOOL idle_startup()
 void login_show()
 {
 	llinfos << "Initializing Login Screen" << llendl;
-	
+
+#ifdef LL_RELEASE_FOR_DOWNLOAD
+	BOOL bUseDebugLogin = gSavedSettings.getBOOL("UseDebugLogin");
+#else
+	BOOL bUseDebugLogin = TRUE;
+#endif
+
 	LLPanelLogin::show(	gViewerWindow->getVirtualWindowRect(),
-						gSavedSettings.getBOOL("UseDebugLogin"),
+						bUseDebugLogin,
 						login_callback, NULL );
 
 	llinfos << "Decoding Images" << llendl;
diff --git a/indra/newview/llstatusbar.h b/indra/newview/llstatusbar.h
index 0182cae3b7..94f758f054 100644
--- a/indra/newview/llstatusbar.h
+++ b/indra/newview/llstatusbar.h
@@ -107,7 +107,7 @@ protected:
 	
 	static std::vector<std::string> sDays;
 	static std::vector<std::string> sMonths;
-	static const U32 LLStatusBar::MAX_DATE_STRING_LENGTH;
+	static const U32 MAX_DATE_STRING_LENGTH;
 };
 
 // *HACK: Status bar owns your cached money balance. JC
diff --git a/indra/newview/lltoolselect.cpp b/indra/newview/lltoolselect.cpp
index 475fc4a0d1..4068b15fbb 100644
--- a/indra/newview/lltoolselect.cpp
+++ b/indra/newview/lltoolselect.cpp
@@ -115,7 +115,7 @@ LLHandle<LLObjectSelection> LLToolSelect::handleObjectSelection(LLViewerObject *
 				}
 				else
 				{
-					gSelectMgr->deselectObjectAndFamily(object);
+					gSelectMgr->deselectObjectAndFamily(object, TRUE, TRUE);
 				}
 			}
 			else
diff --git a/indra/newview/llviewerjointattachment.cpp b/indra/newview/llviewerjointattachment.cpp
index 090276ef51..53fbd9a178 100644
--- a/indra/newview/llviewerjointattachment.cpp
+++ b/indra/newview/llviewerjointattachment.cpp
@@ -30,16 +30,17 @@ extern LLPipeline gPipeline;
 //-----------------------------------------------------------------------------
 // LLViewerJointAttachment()
 //-----------------------------------------------------------------------------
-LLViewerJointAttachment::LLViewerJointAttachment()
+LLViewerJointAttachment::LLViewerJointAttachment() :
+mJoint(NULL),
+mAttachedObject(NULL),
+mAttachmentDirty(FALSE),
+mVisibleInFirst(FALSE),
+mGroup(0),
+mIsHUDAttachment(FALSE),
+mPieSlice(-1)
 {
-	mJoint = NULL;
-	mAttachedObject = NULL;
-	mAttachmentDirty = FALSE;
-	mGroup = 0;
-	mUpdateXform = FALSE;
-	mIsHUDAttachment = FALSE;
 	mValid = FALSE;
-	mPieSlice = -1;
+	mUpdateXform = FALSE;
 }
 
 //-----------------------------------------------------------------------------
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index d6bfe66dc8..12ebca3b82 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -715,7 +715,7 @@ void init_client_menu(LLMenuGL* menu)
 	
 	// neither of these works particularly well at the moment
 	/*menu->append(new LLMenuItemCallGL(  "Reload UI XML",	&reload_ui,	
-	  				NULL, NULL, 'R', MASK_ALT | MASK_CONTROL ) );*/
+	  				NULL, NULL) );*/
 	/*menu->append(new LLMenuItemCallGL("Reload settings/colors", 
 					&handle_reload_settings, NULL, NULL));*/
 	menu->append(new LLMenuItemCallGL("Reload personal setting overrides", 
@@ -873,7 +873,7 @@ void init_client_menu(LLMenuGL* menu)
 									   (void*)"LimitSelectDistance"));
 
 	menu->append(new LLMenuItemToggleGL("Disable Camera Constraints", 
-		&LLViewerCamera::sDisableCameraConstraints));
+		&LLViewerCamera::sDisableCameraConstraints, 'C', MASK_ALT | MASK_CONTROL ));
 
 	menu->append(new LLMenuItemCheckGL("Joystick Flycam", 
 		&handle_toggle_flycam,NULL,&check_flycam,NULL));
@@ -1075,39 +1075,39 @@ void init_debug_rendering_menu(LLMenuGL* menu)
 	sub_menu->append(new LLMenuItemCheckGL("UI",
 											&LLPipeline::toggleRenderDebugFeature, NULL,
 											&LLPipeline::toggleRenderDebugFeatureControl,
-											(void*)LLPipeline::RENDER_DEBUG_FEATURE_UI, '1', MASK_ALT|MASK_CONTROL));
+											(void*)LLPipeline::RENDER_DEBUG_FEATURE_UI, KEY_F1, MASK_ALT|MASK_CONTROL));
 	sub_menu->append(new LLMenuItemCheckGL("Selected",
 											&LLPipeline::toggleRenderDebugFeature, NULL,
 											&LLPipeline::toggleRenderDebugFeatureControl,
-											(void*)LLPipeline::RENDER_DEBUG_FEATURE_SELECTED, '2', MASK_ALT|MASK_CONTROL));
+											(void*)LLPipeline::RENDER_DEBUG_FEATURE_SELECTED, KEY_F2, MASK_ALT|MASK_CONTROL));
 	sub_menu->append(new LLMenuItemCheckGL("Highlighted",
 											&LLPipeline::toggleRenderDebugFeature, NULL,
 											&LLPipeline::toggleRenderDebugFeatureControl,
-											(void*)LLPipeline::RENDER_DEBUG_FEATURE_HIGHLIGHTED, '3', MASK_ALT|MASK_CONTROL));
+											(void*)LLPipeline::RENDER_DEBUG_FEATURE_HIGHLIGHTED, KEY_F3, MASK_ALT|MASK_CONTROL));
 	sub_menu->append(new LLMenuItemCheckGL("Dynamic Textures",
 											&LLPipeline::toggleRenderDebugFeature, NULL,
 											&LLPipeline::toggleRenderDebugFeatureControl,
-											(void*)LLPipeline::RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES, '4', MASK_ALT|MASK_CONTROL));
+											(void*)LLPipeline::RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES, KEY_F4, MASK_ALT|MASK_CONTROL));
 	sub_menu->append(new LLMenuItemCheckGL( "Foot Shadows", 
 											&LLPipeline::toggleRenderDebugFeature, NULL,
 											&LLPipeline::toggleRenderDebugFeatureControl,
-											(void*)LLPipeline::RENDER_DEBUG_FEATURE_FOOT_SHADOWS, '5', MASK_ALT|MASK_CONTROL));
+											(void*)LLPipeline::RENDER_DEBUG_FEATURE_FOOT_SHADOWS, KEY_F5, MASK_ALT|MASK_CONTROL));
 	sub_menu->append(new LLMenuItemCheckGL("Fog",
 											&LLPipeline::toggleRenderDebugFeature, NULL,
 											&LLPipeline::toggleRenderDebugFeatureControl,
-											(void*)LLPipeline::RENDER_DEBUG_FEATURE_FOG, '6', MASK_ALT|MASK_CONTROL));
+											(void*)LLPipeline::RENDER_DEBUG_FEATURE_FOG, KEY_F6, MASK_ALT|MASK_CONTROL));
 	sub_menu->append(new LLMenuItemCheckGL("Palletized Textures",
 											&LLPipeline::toggleRenderDebugFeature, NULL,
 											&LLPipeline::toggleRenderDebugFeatureControl,
-											(void*)LLPipeline::RENDER_DEBUG_FEATURE_PALETTE, '7', MASK_ALT|MASK_CONTROL));
+											(void*)LLPipeline::RENDER_DEBUG_FEATURE_PALETTE, KEY_F7, MASK_ALT|MASK_CONTROL));
 	sub_menu->append(new LLMenuItemCheckGL("Test FRInfo",
 											&LLPipeline::toggleRenderDebugFeature, NULL,
 											&LLPipeline::toggleRenderDebugFeatureControl,
-											(void*)LLPipeline::RENDER_DEBUG_FEATURE_FR_INFO, '8', MASK_ALT|MASK_CONTROL));
+											(void*)LLPipeline::RENDER_DEBUG_FEATURE_FR_INFO, KEY_F8, MASK_ALT|MASK_CONTROL));
 	sub_menu->append(new LLMenuItemCheckGL( "Flexible Objects", 
 											&LLPipeline::toggleRenderDebugFeature, NULL,
 											&LLPipeline::toggleRenderDebugFeatureControl,
-											(void*)LLPipeline::RENDER_DEBUG_FEATURE_FLEXIBLE, '9', MASK_ALT|MASK_CONTROL));
+											(void*)LLPipeline::RENDER_DEBUG_FEATURE_FLEXIBLE, KEY_F9, MASK_ALT|MASK_CONTROL));
 	sub_menu->createJumpKeys();
 
 	/////////////////////////////
@@ -1279,7 +1279,7 @@ void init_debug_avatar_menu(LLMenuGL* menu)
 	menu->append(new LLMenuItemToggleGL( "Display Agent Target", &LLAgent::sDebugDisplayTarget));
 	menu->append(new LLMenuItemToggleGL( "Debug Rotation", &gDebugAvatarRotation));
 	menu->append(new LLMenuItemCallGL("Dump Attachments", handle_dump_attachments));
-	menu->append(new LLMenuItemCallGL("Rebake Textures", handle_rebake_textures));
+	menu->append(new LLMenuItemCallGL("Rebake Textures", handle_rebake_textures, NULL, NULL, 'R', MASK_ALT | MASK_CONTROL ));
 #ifndef LL_RELEASE_FOR_DOWNLOAD
 	menu->append(new LLMenuItemCallGL("Debug Avatar Textures", handle_debug_avatar_textures, NULL, NULL, 'A', MASK_SHIFT|MASK_CONTROL|MASK_ALT));
 	menu->append(new LLMenuItemCallGL("Dump Local Textures", handle_dump_avatar_local_textures, NULL, NULL, 'M', MASK_SHIFT|MASK_ALT ));	
@@ -2322,10 +2322,11 @@ void handle_buy_object(LLSaleInfo sale_info)
 		return;
 	}
 
-	if(sale_info.getSalePrice() > gStatusBar->getBalance())
+	S32 price = sale_info.getSalePrice();
+	
+	if (price > 0 && price > gStatusBar->getBalance())
 	{
-		LLFloaterBuyCurrency::buyCurrency(
-			"This object costs", sale_info.getSalePrice());
+		LLFloaterBuyCurrency::buyCurrency("This object costs", price);
 		return;
 	}
 
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 7adfba7776..3ee72b3d17 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -43,6 +43,7 @@
 #include "message.h"
 #include "sound_ids.h"
 #include "lltimer.h"
+#include "llmd5.h"
 
 #include "llagent.h"
 #include "llcallingcard.h"
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index b80aabab34..2ac131ac91 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -41,7 +41,11 @@
 #include "u64.h"
 #include "llviewerimagelist.h"
 #include "lldatapacker.h"
-#include <zlib/zlib.h>
+#ifdef LL_STANDALONE
+#include <zlib.h>
+#else
+#include "zlib/zlib.h"
+#endif
 #include "object_flags.h"
 
 extern BOOL gVelocityInterpolate;
diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp
index 21365fa3b9..ed97cd3ec2 100644
--- a/indra/newview/llviewerparcelmgr.cpp
+++ b/indra/newview/llviewerparcelmgr.cpp
@@ -160,8 +160,7 @@ LLViewerParcelMgr::~LLViewerParcelMgr()
 	delete[] mCollisionSegments;
 	mCollisionSegments = NULL;
 
-	// weird, this crashes if I use an array delete on it!
-	delete sPackedOverlay;
+	delete[] sPackedOverlay;
 	sPackedOverlay = NULL;
 
 	delete[] mAgentParcelOverlay;
diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp
index 9b7e44a523..476326147c 100644
--- a/indra/newview/llviewerpartsim.cpp
+++ b/indra/newview/llviewerpartsim.cpp
@@ -21,7 +21,7 @@
 #include "llworld.h"
 #include "pipeline.h"
 
-const S32 MAX_PART_COUNT = 4096;
+const S32 MAX_PART_COUNT = 8192; // VWR-1105
 
 const F32 PART_SIM_BOX_SIDE = 16.f;
 const F32 PART_SIM_BOX_OFFSET = 0.5f*PART_SIM_BOX_SIDE;
diff --git a/indra/newview/llviewerpartsource.cpp b/indra/newview/llviewerpartsource.cpp
index 96e8863ec8..414d94e8ad 100644
--- a/indra/newview/llviewerpartsource.cpp
+++ b/indra/newview/llviewerpartsource.cpp
@@ -285,6 +285,12 @@ void LLViewerPartSourceScript::update(const F32 dt)
 				//llwarns << "Unknown source pattern " << (S32)mPartSysData.mPattern << llendl;
 			}
 
+			if (part->mFlags & LLPartData::LL_PART_FOLLOW_SRC_MASK ||	// SVC-193, VWR-717
+				part->mFlags & LLPartData::LL_PART_TARGET_LINEAR_MASK) 
+			{
+				mPartSysData.mBurstRadius = 0; 
+			}
+
 			gWorldPointer->mPartSim.addPart(part);
 		}
 
diff --git a/indra/newview/llviewerprecompiledheaders.h b/indra/newview/llviewerprecompiledheaders.h
index e08c040855..26bf41f8a2 100644
--- a/indra/newview/llviewerprecompiledheaders.h
+++ b/indra/newview/llviewerprecompiledheaders.h
@@ -72,7 +72,6 @@
 #include "llmap.h"
 #include "llmemory.h"
 #include "llnametable.h"
-#include "llpagemem.h"
 #include "llpriqueuemap.h"
 #include "llprocessor.h"
 #include "llptrskiplist.h"
@@ -125,7 +124,6 @@
 #include "llcoordframe.h"
 #include "llcrc.h"
 #include "llinterp.h"
-#include "llmd5.h"
 #include "llperlin.h"
 #include "llplane.h"
 #include "llquantize.h"
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 7fed7ebe94..223286b1c9 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -301,89 +301,15 @@ void LLViewerRegion::sendReliableMessage()
 	gMessageSystem->sendReliable(mHost);
 }
 
-
-void LLViewerRegion::setAllowDamage(BOOL b)
-{
-	if (b)
-	{
-		mRegionFlags |=  REGION_FLAGS_ALLOW_DAMAGE;
-	}
-	else
-	{
-		mRegionFlags &= ~REGION_FLAGS_ALLOW_DAMAGE;
-	}
-}
-
-
-void LLViewerRegion::setAllowLandmark(BOOL b)
-{
-	if (b)
-	{
-		mRegionFlags |=  REGION_FLAGS_ALLOW_LANDMARK;
-	}
-	else
-	{
-		mRegionFlags &= ~REGION_FLAGS_ALLOW_LANDMARK;
-	}
-}
-
-void LLViewerRegion::setAllowSetHome(BOOL b)
-{
-	if (b)
-	{
-		mRegionFlags |=  REGION_FLAGS_ALLOW_SET_HOME;
-	}
-	else
-	{
-		mRegionFlags &= ~REGION_FLAGS_ALLOW_SET_HOME;
-	}
-}
-
-void LLViewerRegion::setResetHomeOnTeleport(BOOL b)
-{
-	if (b)
-	{
-		mRegionFlags |=  REGION_FLAGS_RESET_HOME_ON_TELEPORT;
-	}
-	else
-	{
-		mRegionFlags &= ~REGION_FLAGS_RESET_HOME_ON_TELEPORT;
-	}
-}
-
-void LLViewerRegion::setSunFixed(BOOL b)
-{
-	if (b)
-	{
-		mRegionFlags |=  REGION_FLAGS_SUN_FIXED;
-	}
-	else
-	{
-		mRegionFlags &= ~REGION_FLAGS_SUN_FIXED;
-	}
-}
-
-void LLViewerRegion::setBlockFly(BOOL b)
-{
-	if (b)
-	{
-		mRegionFlags |= REGION_FLAGS_BLOCK_FLY;
-	}
-	else
-	{
-		mRegionFlags &= ~REGION_FLAGS_BLOCK_FLY;
-	}
-}
-
-void LLViewerRegion::setAllowDirectTeleport(BOOL b)
+void LLViewerRegion::setFlags(BOOL b, U32 flags)
 {
 	if (b)
 	{
-		mRegionFlags |= REGION_FLAGS_ALLOW_DIRECT_TELEPORT;
+		mRegionFlags |=  flags;
 	}
 	else
 	{
-		mRegionFlags &= ~REGION_FLAGS_ALLOW_DIRECT_TELEPORT;
+		mRegionFlags &= ~flags;
 	}
 }
 
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index e971efeedf..ec36c0bd0b 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -63,13 +63,14 @@ public:
 	void setOriginGlobal(const LLVector3d &origin);
 	void setAgentOffset(const LLVector3d &offset);
 
-	void setAllowDamage(BOOL b);
-	void setAllowLandmark(BOOL b);
-	void setAllowSetHome(BOOL b);
-	void setResetHomeOnTeleport(BOOL b);
-	void setSunFixed(BOOL b);
-	void setBlockFly(BOOL b);
-	void setAllowDirectTeleport(BOOL b);
+	void setAllowDamage(BOOL b) { setFlags(b, REGION_FLAGS_ALLOW_DAMAGE); }
+	void setAllowLandmark(BOOL b) { setFlags(b, REGION_FLAGS_ALLOW_LANDMARK); }
+	void setAllowSetHome(BOOL b) { setFlags(b, REGION_FLAGS_ALLOW_SET_HOME); }
+	void setResetHomeOnTeleport(BOOL b) { setFlags(b, REGION_FLAGS_RESET_HOME_ON_TELEPORT); }
+	void setSunFixed(BOOL b) { setFlags(b, REGION_FLAGS_SUN_FIXED); }
+	void setBlockFly(BOOL b) { setFlags(b, REGION_FLAGS_BLOCK_FLY); }
+	void setAllowDirectTeleport(BOOL b) { setFlags(b, REGION_FLAGS_ALLOW_DIRECT_TELEPORT); }
+
 
 	inline BOOL getAllowDamage()			const;
 	inline BOOL getAllowLandmark()			const;
@@ -228,6 +229,7 @@ public:
 protected:
 	void disconnectAllNeighbors();
 	void initStats();
+	void setFlags(BOOL b, U32 flags);
 
 public:
 	LLWind  mWind;
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 5763f988de..d04dda9109 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1279,7 +1279,9 @@ BOOL LLViewerWindow::handleActivate(LLWindow *window, BOOL activated)
 	else
 	{
 		mActive = FALSE;
-		gAgent.setAFK();
+		if (gAllowIdleAFK) {
+			gAgent.setAFK();
+		}
 		send_agent_pause();
 		if (mWindow->getFullscreen() && !mIgnoreActivate)
 		{
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 540cd1f04b..12149ecf77 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -4183,7 +4183,7 @@ void LLVOAvatar::updateTextures(LLAgent &agent)
 	
 	if( render_avatar )
 	{
-		mShadowImagep->addTextureStats(mPixelArea, 1.f);
+		mShadowImagep->addTextureStats(mPixelArea);
 	}
 }
 
@@ -5790,7 +5790,7 @@ BOOL LLVOAvatar::attachObject(LLViewerObject *viewer_object)
 {
 	LLViewerJointAttachment* attachment = getTargetAttachmentPoint(viewer_object);
 
-	if (!attachment->addObject(viewer_object))
+	if (!attachment || !attachment->addObject(viewer_object))
 	{
 		return FALSE;
 	}
diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp
index 418a810f6a..fc1d8f1711 100644
--- a/indra/newview/llvograss.cpp
+++ b/indra/newview/llvograss.cpp
@@ -316,16 +316,13 @@ void LLVOGrass::setPixelAreaAndAngle(LLAgent &agent)
 // BUG could speed this up by caching the relative_position and range calculations
 void LLVOGrass::updateTextures(LLAgent &agent)
 {
-	F32 texel_area_ratio = 1.f;
-	F32 cos_angle = 1.f;
-
 	if (getTEImage(0))
 	{
 		if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA))
 		{
 			setDebugText(llformat("%4.0f", fsqrtf(mPixelArea)));
 		}
-		getTEImage(0)->addTextureStats(mPixelArea, texel_area_ratio, cos_angle);
+		getTEImage(0)->addTextureStats(mPixelArea);
 	}
 }
 
diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp
index 9995a8e462..4c0855be29 100644
--- a/indra/newview/llvopartgroup.cpp
+++ b/indra/newview/llvopartgroup.cpp
@@ -415,7 +415,7 @@ void LLParticlePartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_co
 			drawablep->updateFaceSize(j);
 
 			LLFace* facep = drawablep->getFace(j);
-			if (!facep->hasGeometry())
+			if ( !facep || !facep->hasGeometry())
 			{
 				continue;
 			}
diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp
index f67188ff05..bc0f0c5662 100644
--- a/indra/newview/llvotree.cpp
+++ b/indra/newview/llvotree.cpp
@@ -386,15 +386,13 @@ void LLVOTree::setPixelAreaAndAngle(LLAgent &agent)
 
 void LLVOTree::updateTextures(LLAgent &agent)
 {
-	F32 texel_area_ratio = 1.f;
-	F32 cos_angle = 1.f;
 	if (mTreeImagep)
 	{
 		if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA))
 		{
 			setDebugText(llformat("%4.0f", fsqrtf(mPixelArea)));
 		}
-		mTreeImagep->addTextureStats(mPixelArea, texel_area_ratio, cos_angle);
+		mTreeImagep->addTextureStats(mPixelArea);
 	}
 
 }
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index b310ea515c..4acef46474 100755
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -413,7 +413,7 @@ class Linux_i686Manifest(LinuxManifest):
                         self.path("libstdc++.so.6")
                         self.path("libuuid.so", "libuuid.so.1")
                         self.path("libSDL-1.2.so.0")
-                        #self.path("libresolv.so") - don't bundle
+                        self.path("libELFIO.so")
                         #self.path("libtcmalloc.so.0") - bugged
                         #self.path("libstacktrace.so.0") - probably bugged
                         self.path("libllkdu.so", "../bin/libllkdu.so") # llkdu goes in bin for some reason
diff --git a/indra/test/llbuffer_tut.cpp b/indra/test/llbuffer_tut.cpp
index f403181efa..4ac72d59d3 100644
--- a/indra/test/llbuffer_tut.cpp
+++ b/indra/test/llbuffer_tut.cpp
@@ -11,8 +11,10 @@
 #include <tut/tut.h>
 #include "lltut.h"
 #include "llbuffer.h"
+#include "llerror.h"
 #include "llmemtype.h"
 
+
 namespace tut
 {
 	struct buffer
diff --git a/indra/win_crash_logger/resource.h b/indra/win_crash_logger/resource.h
index 19233df390..ee6bf3d575 100644
--- a/indra/win_crash_logger/resource.h
+++ b/indra/win_crash_logger/resource.h
@@ -1,11 +1,3 @@
-/** 
- * @file resource.h
- * @brief Resources for windows crash logger
- *
- * Copyright (c) 2003-$CurrentYear$, Linden Research, Inc.
- * $License$
- */
-
 //{{NO_DEPENDENCIES}}
 // Microsoft Visual C++ generated include file.
 // Used by win_crash_logger.rc
diff --git a/indra/win_crash_logger/win_crash_logger.rc b/indra/win_crash_logger/win_crash_logger.rc
index f4c7eaa337..2c46859b95 100644
--- a/indra/win_crash_logger/win_crash_logger.rc
+++ b/indra/win_crash_logger/win_crash_logger.rc
@@ -81,14 +81,10 @@ BEGIN
                     BS_AUTOCHECKBOX | WS_TABSTOP,4,106,89,13
     LTEXT           "Sending crash reports is the best way to help us improve the quality of %s.",
                     IDC_STATIC_MOTIVATION,4,38,288,8
-    LTEXT           "If you continue to experience this problem, please try one of the following:",
+    LTEXT           "If you continue to experience this problem, please try:",
                     IDC_STATIC,4,57,251,8
-    LTEXT           "- Contact support by email at support@lindenlab.com",
-                    IDC_STATIC,4,67,179,8
-    LTEXT           "- If you can log-in, please contact Live Help by using menu Help > Live Help.",
-                    IDC_STATIC,4,87,249,8
-    LTEXT           "- Search the Second Life Knowledge Base at http://secondlife.com/knowledgebase/",
-                    IDC_STATIC,4,77,281,8,SS_NOTIFY
+    LTEXT           "- Contacting support by visiting http://www.secondlife.com/support",
+                    IDC_STATIC,4,67,231,8
 END
 
 IDD_PREVREPORTBOX DIALOG  100, 100, 232, 213
-- 
GitLab