From e61a10ec5b6b84fcb5c27e8e308022d0094f8736 Mon Sep 17 00:00:00 2001
From: Josh Bell <josh@lindenlab.com>
Date: Mon, 4 Jun 2007 18:46:59 +0000
Subject: [PATCH] svn merge -r 62602:62831
 svn+ssh://svn.lindenlab.com/svn/linden/branches/maintenance --> release

---
 doc/contributions.txt                         |   2 +-
 indra/llaudio/llaudiodecodemgr.cpp            |   4 +-
 indra/llcommon/llerror.cpp                    |   7 +
 indra/llcommon/llevent.h                      |   2 +-
 indra/llcommon/llthread.h                     |   3 +-
 indra/llimage/llimageworker.cpp               |   4 +-
 indra/llimage/llimageworker.h                 |   3 +-
 indra/llmath/lloctree.h                       |   1 -
 indra/llmath/lltreenode.h                     |   1 -
 indra/llmath/llvolume.h                       |  22 +-
 indra/llmessage/llhttpnode.h                  |   7 +-
 indra/llui/llpanel.cpp                        |  17 +-
 indra/llui/llpanel.h                          |   2 +-
 indra/llui/lluictrlfactory.cpp                |  11 +-
 indra/llui/lluictrlfactory.h                  |   4 +-
 indra/llui/llview.cpp                         |  17 +-
 indra/llui/llview.h                           |   4 +-
 indra/llvfs/lllfsthread.h                     |   3 +-
 indra/llxml/llxmlnode.h                       |   2 +-
 indra/lscript/lscript_compile/indra.l         |   7 -
 .../installers/windows/installer_template.nsi | 361 +++++++++++-------
 indra/newview/linux_tools/wrapper.sh          |   9 +-
 indra/newview/llagent.h                       |   5 +-
 indra/newview/lldrawable.h                    |   2 +-
 indra/newview/llfloatergesture.cpp            |   1 -
 indra/newview/llfloaterpreference.cpp         |   1 +
 indra/newview/llfolderview.cpp                |   3 +-
 indra/newview/llhudeffecttrail.cpp            |  12 +-
 indra/newview/llhudobject.h                   |   2 +-
 indra/newview/llinventorybridge.cpp           |   3 +
 indra/newview/lloverlaybar.cpp                |  21 -
 indra/newview/llpanelgroup.cpp                |   6 +-
 indra/newview/llpanelgroupgeneral.cpp         |   6 +-
 indra/newview/llpanelgrouplandmoney.cpp       |   4 +-
 indra/newview/llpanelgroupnotices.cpp         |   4 +-
 indra/newview/llpanelgrouproles.cpp           |  12 +-
 indra/newview/llpanelobject.cpp               |   3 +
 indra/newview/llselectmgr.cpp                 |  20 +-
 indra/newview/llselectmgr.h                   |   7 +-
 indra/newview/llspatialpartition.cpp          |   2 +-
 indra/newview/llspatialpartition.h            |   7 +-
 indra/newview/llstartup.cpp                   |  17 +-
 indra/newview/lltoolbrush.cpp                 |   3 +-
 indra/newview/lltoolselectland.cpp            |   3 +-
 indra/newview/llviewerinventory.h             |   6 +-
 indra/newview/llviewermenu.cpp                | 336 ++++++++--------
 indra/newview/llviewermessage.cpp             |   6 +-
 indra/newview/llviewerobject.cpp              |   4 +-
 indra/newview/llviewerobject.h                |   2 +-
 indra/newview/llviewerparcelmgr.cpp           |  17 +-
 indra/newview/llviewerparcelmgr.h             |   7 +-
 indra/newview/llviewerpartsim.cpp             |   4 +-
 indra/newview/llviewerpartsim.h               |   7 +-
 indra/newview/llviewerpartsource.cpp          |  14 +-
 indra/newview/llviewerpartsource.h            |   6 +-
 indra/newview/llvoclouds.h                    |   3 +-
 indra/newview/llvograss.h                     |   4 +-
 indra/newview/llvoground.h                    |   3 +-
 indra/newview/llvopartgroup.h                 |   4 +-
 indra/newview/llvosky.cpp                     |   5 +-
 indra/newview/llvosky.h                       |   5 +-
 indra/newview/llvosurfacepatch.h              |   3 +-
 indra/newview/llvotextbubble.h                |   3 +-
 indra/newview/llvotree.h                      |   4 +-
 indra/newview/llvovolume.h                    |   4 +-
 indra/newview/llvowater.h                     |   1 -
 indra/newview/pipeline.cpp                    |   2 -
 indra/newview/pipeline.h                      |   2 +-
 indra/newview/secondlife-i686.supp            | 175 +++++++++
 indra/newview/viewer_manifest.py              |   1 +
 70 files changed, 794 insertions(+), 471 deletions(-)
 create mode 100644 indra/newview/secondlife-i686.supp

diff --git a/doc/contributions.txt b/doc/contributions.txt
index 1f7ab9e0562..72e79f3bf1c 100644
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -20,7 +20,7 @@ Jacek Antonelli - VWR-165, VWR-188
 Joghert LeSabre - VWR-64
 Kage Pixel - VWR-11
 Kunnis Basiat - VWR-82
-Nicholaz Beresford - VWR-793, VWR-794, VWR-802, VWR-803, VWR-804, VWR-805, VWR-808, VWR-809, VWR-810, VWR-823, VWR-870
+Nicholaz Beresford - VWR-793, VWR-794, VWR-802, VWR-803, VWR-804, VWR-805, VWR-808, VWR-809, VWR-810, VWR-823, VWR-869, VWR-870, VWR-871, VWR-908, VWR-966
 Paul Churchill - VWR-20
 Paula Innis - VWR-30
 Peekay Semyorka - VWR-7, VWR-19, VWR-49
diff --git a/indra/llaudio/llaudiodecodemgr.cpp b/indra/llaudio/llaudiodecodemgr.cpp
index 348175675e1..1b4c952e8e3 100644
--- a/indra/llaudio/llaudiodecodemgr.cpp
+++ b/indra/llaudio/llaudiodecodemgr.cpp
@@ -53,7 +53,6 @@ class LLVorbisDecodeState : public LLRefCount
 	};
 	
 	LLVorbisDecodeState(const LLUUID &uuid, const LLString &out_filename);
-	virtual ~LLVorbisDecodeState();
 
 	BOOL initDecode();
 	BOOL decodeSection(); // Return TRUE if done.
@@ -65,7 +64,10 @@ class LLVorbisDecodeState : public LLRefCount
 	BOOL isValid() const				{ return mValid; }
 	BOOL isDone() const					{ return mDone; }
 	const LLUUID &getUUID() const		{ return mUUID; }
+
 protected:
+	virtual ~LLVorbisDecodeState();
+
 	BOOL mValid;
 	BOOL mDone;
 	LLAtomicS32 mBytesRead;
diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp
index 5964993928e..4f8dc514581 100644
--- a/indra/llcommon/llerror.cpp
+++ b/indra/llcommon/llerror.cpp
@@ -20,6 +20,7 @@ extern apr_thread_mutex_t *gLogMutexp;
 #include "lllivefile.h"
 #include "llsd.h"
 #include "llsdserialize.h"
+#include "llstl.h"
 
 #include <algorithm>
 #include <cctype>
@@ -390,6 +391,12 @@ namespace LLError
 				shouldLogCallCounter(0)
 			{ }
 		
+		~Settings()
+		{
+			for_each(recorders.begin(), recorders.end(),
+					 DeletePointer());
+		}
+		
 		static Settings*& getPtr();
 	};
 	
diff --git a/indra/llcommon/llevent.h b/indra/llcommon/llevent.h
index a3f6b0e9427..6a71a9cbadc 100644
--- a/indra/llcommon/llevent.h
+++ b/indra/llcommon/llevent.h
@@ -68,12 +68,12 @@ class LLEventListener : public LLThreadSafeRefCount
 class LLSimpleListener : public LLEventListener
 {
 public:
-	virtual ~LLSimpleListener();
 	void clearDispatchers();
 	virtual bool handleAttach(LLEventDispatcher *dispatcher);
 	virtual bool handleDetach(LLEventDispatcher *dispatcher);
 
 protected:
+	~LLSimpleListener();
 	std::vector<LLEventDispatcher *> mDispatchers;
 };
 
diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h
index ce5daa938cc..659f73bee74 100644
--- a/indra/llcommon/llthread.h
+++ b/indra/llcommon/llthread.h
@@ -219,8 +219,9 @@ class LLThreadSafeRefCount
 // Pure virtual class
 class LLResponder : public LLThreadSafeRefCount
 {
-public:
+protected:
 	virtual ~LLResponder();
+public:
 	virtual void completed(bool success) = 0;
 };
 
diff --git a/indra/llimage/llimageworker.cpp b/indra/llimage/llimageworker.cpp
index 297482a2229..1e625fbe289 100644
--- a/indra/llimage/llimageworker.cpp
+++ b/indra/llimage/llimageworker.cpp
@@ -30,7 +30,9 @@ void LLImageWorker::cleanupClass()
 
 //----------------------------------------------------------------------------
 
-LLImageWorker::LLImageWorker(LLImageFormatted* image, U32 priority, S32 discard, LLResponder* responder)
+LLImageWorker::LLImageWorker(LLImageFormatted* image, U32 priority,
+							 S32 discard,
+							 LLPointer<LLResponder> responder)
 	: LLWorkerClass(sWorkerThread, "Image"),
 	  mFormattedImage(image),
 	  mDecodedType(-1),
diff --git a/indra/llimage/llimageworker.h b/indra/llimage/llimageworker.h
index 6e9ecacc894..763936d772e 100644
--- a/indra/llimage/llimageworker.h
+++ b/indra/llimage/llimageworker.h
@@ -21,7 +21,8 @@ class LLImageWorker : public LLWorkerClass
 
 	// LLWorkerThread
 public:
-	LLImageWorker(LLImageFormatted* image, U32 priority, S32 discard, LLResponder* responder = NULL);
+	LLImageWorker(LLImageFormatted* image, U32 priority, S32 discard,
+				  LLPointer<LLResponder> responder);
 	~LLImageWorker();
 
 	// called from WORKER THREAD, returns TRUE if done
diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h
index f7ad3632061..97f95767671 100644
--- a/indra/llmath/lloctree.h
+++ b/indra/llmath/lloctree.h
@@ -37,7 +37,6 @@ class LLOctreeListener: public LLTreeListener<T>
 	typedef LLTreeListener<T> BaseType;
 	typedef LLOctreeNode<T> oct_node;
 
-	virtual ~LLOctreeListener() { };
 	virtual void handleChildAddition(const oct_node* parent, oct_node* child) = 0;
 	virtual void handleChildRemoval(const oct_node* parent, const oct_node* child) = 0;
 };
diff --git a/indra/llmath/lltreenode.h b/indra/llmath/lltreenode.h
index cdc52cf90ac..67c6cb631a4 100644
--- a/indra/llmath/lltreenode.h
+++ b/indra/llmath/lltreenode.h
@@ -37,7 +37,6 @@ template <class T>
 class LLTreeListener: public LLRefCount
 {
 public:
-	virtual ~LLTreeListener() { };
 	virtual void handleInsertion(const LLTreeNode<T>* node, T* data) = 0;
 	virtual void handleRemoval(const LLTreeNode<T>* node, T* data) = 0;
 	virtual void handleDestruction(const LLTreeNode<T>* node) = 0;
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 3ce3058887b..23c29ae3109 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -615,12 +615,14 @@ class LLVolumeParams
 class LLProfile
 {
 public:
-	LLProfile(const LLProfileParams &params) : mParams(params)
+	LLProfile(const LLProfileParams &params)
+		: mParams(params),
+		  mOpen(FALSE),
+		  mConcave(FALSE),
+		  mDirty(TRUE),
+		  mTotalOut(0),
+		  mTotal(2)
 	{
-		mTotal    = 2;
-		mTotalOut = 0;
-		mDirty    = TRUE;
-		mConcave = FALSE;
 	}
 
 	~LLProfile();
@@ -690,11 +692,13 @@ class LLPath
 	};
 
 public:
-	LLPath(const LLPathParams &params) : mParams(params)
+	LLPath(const LLPathParams &params)
+		: mParams(params),
+		  mOpen(FALSE),
+		  mTotal(0),
+		  mDirty(TRUE),
+		  mStep(1)
 	{
-		mOpen      = FALSE;
-		mDirty     = TRUE;
-		mStep      = 1;
 	}
 
 	virtual ~LLPath();
diff --git a/indra/llmessage/llhttpnode.h b/indra/llmessage/llhttpnode.h
index 1e799c18b9d..971926b579a 100644
--- a/indra/llmessage/llhttpnode.h
+++ b/indra/llmessage/llhttpnode.h
@@ -68,9 +68,10 @@ class LLHTTPNode
 
 		class Response : public LLRefCount
 		{
-		public:
+		protected:
 			virtual ~Response();
 
+		public:
 			virtual void result(const LLSD&) = 0;
 			virtual void status(S32 code, const std::string& message) = 0;
 
@@ -205,7 +206,6 @@ class LLSimpleResponse : public LLHTTPNode::Response
 {
 public:
 	static LLPointer<LLSimpleResponse> create();
-	~LLSimpleResponse();
 	
 	void result(const LLSD& result);
 	void status(S32 code, const std::string& message);
@@ -215,6 +215,9 @@ class LLSimpleResponse : public LLHTTPNode::Response
 	S32 mCode;
 	std::string mMessage;
 
+protected:
+	~LLSimpleResponse();
+
 private:
 	LLSimpleResponse() {;} // Must be accessed through LLPointer.
 };
diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp
index 316764474b9..37feffd4b0f 100644
--- a/indra/llui/llpanel.cpp
+++ b/indra/llui/llpanel.cpp
@@ -569,7 +569,7 @@ LLView* LLPanel::fromXML(LLXMLNodePtr node, LLView* parentp, LLUICtrlFactory *fa
 	return panelp;
 }
 
-void LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
+BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
 {
 	LLString name("panel");
 	node->getAttributeString("name", name);
@@ -585,12 +585,23 @@ void LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *f
 
 	LLString xml_filename;
 	node->getAttributeString("filename", xml_filename);
+
+	BOOL didPost;
+
 	if (!xml_filename.empty())
 	{
-		factory->buildPanel(this, xml_filename, NULL);
+		didPost = factory->buildPanel(this, xml_filename, NULL);
+	} else {
+		didPost = FALSE;
 	}
 	
-	postBuild();
+	if (!didPost)
+	{
+		postBuild();
+		didPost = TRUE;
+	}
+
+	return didPost;
 }
 
 void LLPanel::setPanelParameters(LLXMLNodePtr node, LLView* parentp)
diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h
index fdf4a117d45..f06797a7f86 100644
--- a/indra/llui/llpanel.h
+++ b/indra/llui/llpanel.h
@@ -115,7 +115,7 @@ class LLPanel : public LLUICtrl
 
 	virtual LLXMLNodePtr getXML(bool save_children = true) const;
 	static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
-	void initPanelXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
+	BOOL initPanelXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
 	void setPanelParameters(LLXMLNodePtr node, LLView *parentp);
 
 	// ** Wrappers for setting child properties by name ** -TomY
diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp
index 64102081895..1d149b63e2a 100644
--- a/indra/llui/lluictrlfactory.cpp
+++ b/indra/llui/lluictrlfactory.cpp
@@ -350,21 +350,22 @@ S32 LLUICtrlFactory::saveToXML(LLView* viewp, const LLString& filename)
 //-----------------------------------------------------------------------------
 // buildPanel()
 //-----------------------------------------------------------------------------
-void LLUICtrlFactory::buildPanel(LLPanel* panelp, const LLString &filename,
+BOOL LLUICtrlFactory::buildPanel(LLPanel* panelp, const LLString &filename,
 									const LLCallbackMap::map_t* factory_map)
 {
+	BOOL didPost = FALSE;
 	LLXMLNodePtr root;
 
 	if (!LLUICtrlFactory::getLayeredXMLNode(filename, root))
 	{
-		return;
+		return didPost;
 	}
 
 	// root must be called panel
 	if( !root->hasName("panel" ) )
 	{
 		llwarns << "Root node should be named panel in : " << filename << llendl;
-		return;
+		return didPost;
 	}
 
 	if (factory_map)
@@ -372,7 +373,7 @@ void LLUICtrlFactory::buildPanel(LLPanel* panelp, const LLString &filename,
 		mFactoryStack.push_front(factory_map);
 	}
 
-	panelp->initPanelXML(root, NULL, this);
+	didPost = panelp->initPanelXML(root, NULL, this);
 	
 	if (LLUI::sShowXUINames)
 	{
@@ -386,6 +387,8 @@ void LLUICtrlFactory::buildPanel(LLPanel* panelp, const LLString &filename,
 	{
 		mFactoryStack.pop_front();
 	}
+
+	return didPost;
 }
 
 //-----------------------------------------------------------------------------
diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h
index cb6864bafda..c7280aa4a2d 100644
--- a/indra/llui/lluictrlfactory.h
+++ b/indra/llui/lluictrlfactory.h
@@ -60,8 +60,8 @@ class LLUICtrlFactory
 	void buildFloater(LLFloater* floaterp, const LLString &filename, 
 						const LLCallbackMap::map_t* factory_map = NULL, BOOL open = TRUE);
 
-	void buildPanel(LLPanel* panelp, const LLString &filename,
-						const LLCallbackMap::map_t* factory_map = NULL);
+	BOOL buildPanel(LLPanel* panelp, const LLString &filename,
+					const LLCallbackMap::map_t* factory_map = NULL);
 
 	LLMenuGL *buildMenu(const LLString &filename, LLView* parentp);
 
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index 05c2247a35c..1fab00b5244 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -174,7 +174,6 @@ LLView::~LLView()
 	for (itor = mDispatchList.begin(); itor != mDispatchList.end(); ++itor)
 	{
 		(*itor).second->clearDispatchers();
-		delete (*itor).second;
 	}
 
 	std::for_each(mFloaterControls.begin(), mFloaterControls.end(),
@@ -350,22 +349,25 @@ void LLView::addChildAtEnd(LLView* child, S32 tab_group)
 }
 
 // remove the specified child from the view, and set it's parent to NULL.
-void LLView::removeChild( LLView* child )
+void LLView::removeChild(LLView* child, BOOL deleteIt)
 {
 	if (child->mParentView == this) 
 	{
 		mChildList.remove( child );
 		child->mParentView = NULL;
+		if (child->isCtrl())
+		{
+			removeCtrl((LLUICtrl*)child);
+		}
+		if (deleteIt)
+		{
+			delete child;
+		}
 	}
 	else
 	{
 		llerrs << "LLView::removeChild called with non-child" << llendl;
 	}
-
-	if (child->isCtrl())
-	{
-		removeCtrl((LLUICtrl*)child);
-	}
 }
 
 void LLView::addCtrlAtEnd(LLUICtrl* ctrl, S32 tab_group)
@@ -2490,7 +2492,6 @@ void LLView::deregisterEventListener(LLString name)
 	dispatch_list_t::iterator itor = mDispatchList.find(name);
 	if (itor != mDispatchList.end())
 	{
-		delete itor->second;
 		mDispatchList.erase(itor);
 	}
 }
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index 504558a132a..f9875e8ccaf 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -221,7 +221,7 @@ class LLView : public LLMouseHandler, public LLMortician, public LLSimpleListene
 	void		addChild(LLView* view, S32 tab_group = 0);
 	void		addChildAtEnd(LLView* view,  S32 tab_group = 0);
 	// remove the specified child from the view, and set it's parent to NULL.
-	void		removeChild( LLView* view );
+	void		removeChild(LLView* view, BOOL deleteIt = FALSE);
 
 	virtual void	addCtrl( LLUICtrl* ctrl, S32 tab_group);
 	virtual void	addCtrlAtEnd( LLUICtrl* ctrl, S32 tab_group);
@@ -464,7 +464,7 @@ class LLView : public LLMouseHandler, public LLMortician, public LLSimpleListene
 	LLView* childrenHandleRightMouseDown(S32 x, S32 y, MASK mask);
 	LLView* childrenHandleRightMouseUp(S32 x, S32 y, MASK mask);
 
-	typedef std::map<LLString, LLSimpleListener*> dispatch_list_t;
+	typedef std::map<LLString, LLPointer<LLSimpleListener> > dispatch_list_t;
 	dispatch_list_t mDispatchList;
 
 protected:
diff --git a/indra/llvfs/lllfsthread.h b/indra/llvfs/lllfsthread.h
index 74fd0ffd4d6..a9ef1fec49c 100644
--- a/indra/llvfs/lllfsthread.h
+++ b/indra/llvfs/lllfsthread.h
@@ -38,8 +38,9 @@ class LLLFSThread : public LLQueuedThread
 
 	class Responder : public LLThreadSafeRefCount
 	{
+	protected:
+		~Responder();
 	public:
-		virtual ~Responder();
 		virtual void completed(S32 bytes) = 0;
 	};
 
diff --git a/indra/llxml/llxmlnode.h b/indra/llxml/llxmlnode.h
index ae16a9d800e..e95904dad87 100644
--- a/indra/llxml/llxmlnode.h
+++ b/indra/llxml/llxmlnode.h
@@ -74,7 +74,7 @@ class LLXMLNode : public LLThreadSafeRefCount
 	};
 
 protected:
-	virtual ~LLXMLNode();
+	~LLXMLNode();
 
 public:
 	LLXMLNode();
diff --git a/indra/lscript/lscript_compile/indra.l b/indra/lscript/lscript_compile/indra.l
index 08c2683665e..37435c2e971 100644
--- a/indra/lscript/lscript_compile/indra.l
+++ b/indra/lscript/lscript_compile/indra.l
@@ -758,15 +758,8 @@ void comment()
 {
 	char c;
 
-#if LL_DARWIN
 	while ((c = yyinput()) != '\n' && c != 0 && c != EOF)
 		;
-#else
-	while ((c = yyinput()) != '\n' && c != 0)
-		;
-#endif		
-
-
 }
 
 void count()
diff --git a/indra/newview/installers/windows/installer_template.nsi b/indra/newview/installers/windows/installer_template.nsi
index 8ab7c4fdae9..1b5226c2107 100644
--- a/indra/newview/installers/windows/installer_template.nsi
+++ b/indra/newview/installers/windows/installer_template.nsi
@@ -1,63 +1,70 @@
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; @file viewer_manifest.py
-;;; @author James Cook, Don Kjer
-;;; @brief NSIS script for creating a Windows installer.
-;;;  This file has variables expanded by viewer_manifest.py 
-;;;  to produce the complete nsi script file.
-;;; For info, see http://www.nullsoft.com/free/nsis/
-;;; NSIS 2.02 or higher required
-;;;
-;;; Copyright (c) 2006-$CurrentYear$, Linden Research, Inc.
-;;; $License$
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; Compiler flags
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; secondlife setup.nsi
+;; Copyright 2004-2007, Linden Research, Inc.
+;; For info, see http://www.nullsoft.com/free/nsis/
+;;
+;; NSIS 2.22 or higher required
+;; Author: James Cook, Don Kjer, Callum Prentice
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Detect NSIS compiler version
 !define "NSIS${NSIS_VERSION}"
 !ifdef "NSISv2.02" | "NSISv2.03" | "NSISv2.04" | "NSISv2.05" | "NSISv2.06"
-    ;;; before 2.07 defaulted lzma to solid (whole file)
+    ;; before 2.07 defaulted lzma to solid (whole file)
     SetCompressor lzma
 !else
-    ;;; after 2.07 required /solid for whole file compression
+    ;; after 2.07 required /solid for whole file compression
     SetCompressor /solid lzma
 !endif
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Compiler flags
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 SetOverwrite on				; overwrite files
 SetCompress auto			; compress iff saves space
-SetDatablockOptimize off		; only saves us 0.1%, not worth it
-XPStyle on                              ; add an XP manifest to the installer
+SetDatablockOptimize off	; only saves us 0.1%, not worth it
+XPStyle on                  ; add an XP manifest to the installer
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Project flags
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 %%VERSION%%
 
-;;; Tweak for different servers/builds (this placeholder is replaced by viewer_manifest.py)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; - language files - one for each language (or flavor thereof)
+;; (these files are in the same place as the nsi template but the python script generates a new nsi file in the 
+;; application directory so we have to add a path to these include files)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+#!include "installers\windows\lang_de.nsi"
+!include "installers\windows\lang_en-us.nsi"
+#!include "installers\windows\lang_ja.nsi"
+!include "installers\windows\lang_ko.nsi"
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Tweak for different servers/builds (this placeholder is replaced by viewer_manifest.py)
 %%GRID_VARS%%
 
 Name ${INSTNAME}
 
-SubCaption 0 " Setup"			; override "license agreement" text
+SubCaption 0 $(LicenseSubTitleSetup)	; override "license agreement" text
 
-BrandingText " "				; bottom of window text
-Icon res\install_icon.ico		; our custom icon
+BrandingText " "						; bottom of window text
+Icon res\install_icon.ico				; our custom icon
 UninstallIcon res\uninstall_icon.ico    ; our custom icon
-WindowIcon on					; show our icon in left corner
-BGGradient off					; no big background window
-CRCCheck on						; make sure CRC is OK
+WindowIcon on							; show our icon in left corner
+BGGradient off							; no big background window
+CRCCheck on								; make sure CRC is OK
 InstProgressFlags smooth colored		; new colored smooth look
-ShowInstDetails nevershow		; no details, no "show" button
-SetOverwrite on					; stomp files by default
-AutoCloseWindow true			; after all files install, close window
+ShowInstDetails nevershow				; no details, no "show" button
+SetOverwrite on							; stomp files by default
+AutoCloseWindow true					; after all files install, close window
 
 !ifdef UPDATE
-LicenseText "This package will update Second Life to version ${VERSION_LONG}." "Next >"
+LicenseText $(LicenseDescUpdate) $(LicenseDescNext)
 !else
-LicenseText "This package will install Second Life on your computer." "Next >"
+LicenseText $(LicenseDescSetup) $(LicenseDescNext)
 !endif
 
 LicenseData "releasenotes.txt"
@@ -65,30 +72,30 @@ LicenseData "releasenotes.txt"
 InstallDir "$PROGRAMFILES\${INSTNAME}"
 InstallDirRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\${INSTNAME}" ""
 !ifdef UPDATE
-DirText "Installation Directory" "Select the Second Life directory to update:"
+DirText $(DirectoryChooseTitle) $(DirectoryChooseUpdate)
 !else
-DirText "Installation Directory" "Select the directory to install Second Life in:"
+DirText $(DirectoryChooseTitle) $(DirectoryChooseSetup)
 !endif
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Variables
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 Var INSTPROG
 Var INSTEXE
 Var INSTFLAGS
+Var LANGFLAGS
 Var INSTSHORTCUT
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Sections
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 Section ""						; (default section)
 
 SetShellVarContext all			; install for all users (if you change this, change it in the uninstall as well)
 
-
 ; Start with some default values.
 StrCpy $INSTFLAGS "${INSTFLAGS}"
+StrCpy $INSTFLAGS "$INSTFLAGS $LANGFLAGS"
 StrCpy $INSTPROG "${INSTNAME}"
 StrCpy $INSTEXE "${INSTEXE}"
 StrCpy $INSTSHORTCUT "${SHORTCUT}"
@@ -103,21 +110,22 @@ Call CheckIfAlreadyCurrent		; Make sure that we haven't already installed this v
 Call CloseSecondLife			; Make sure we're not running
 Call RemoveNSIS					; Check for old NSIS install to remove
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Don't remove cache files during a regular install, removing the inventory cache on upgrades results in lots of damage to the servers.
 ;Call RemoveCacheFiles			; Installing over removes potentially corrupted
 								; VFS and cache files.
 
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Files
-;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; This placeholder is replaced by the complete list of all the files in the installer, by viewer_manifest.py
 %%INSTALL_FILES%%
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; If this is a silent update, we don't need to re-create these shortcuts or registry entries.
 IfSilent POST_INSTALL
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Shortcuts in start menu
 CreateDirectory	"$SMPROGRAMS\$INSTSHORTCUT"
 SetOutPath "$INSTDIR"
@@ -146,6 +154,7 @@ CreateShortCut	"$SMPROGRAMS\$INSTSHORTCUT\SL Scripting Language Help.lnk" \
 CreateShortCut	"$SMPROGRAMS\$INSTSHORTCUT\Uninstall $INSTSHORTCUT.lnk" \
 				'"$INSTDIR\uninst.exe"' '/P="$INSTPROG"'
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Other shortcuts
 SetOutPath "$INSTDIR"
 CreateShortCut "$DESKTOP\$INSTSHORTCUT.lnk" "$INSTDIR\$INSTEXE" "$INSTFLAGS"
@@ -164,6 +173,7 @@ CreateShortCut "$INSTDIR\$INSTSHORTCUT Museum Spanish.lnk" "$INSTDIR\$INSTEXE" "
 
 !endif
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Write registry
 WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" "" "$INSTDIR"
 WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" "Version" "${VERSION_LONG}"
@@ -173,6 +183,7 @@ WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" "Exe"
 WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\$INSTPROG" "DisplayName" "$INSTPROG (remove only)"
 WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\$INSTPROG" "UninstallString" '"$INSTDIR\uninst.exe" /P="$INSTPROG"'
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Write URL registry info
 WriteRegStr HKEY_CLASSES_ROOT "${URLNAME}" "(default)" "URL:Second Life"
 WriteRegStr HKEY_CLASSES_ROOT "${URLNAME}" "URL Protocol" ""
@@ -192,10 +203,10 @@ WriteUninstaller "$INSTDIR\uninst.exe"
 ; end of default section
 SectionEnd
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; PostInstallExe
 ; This just runs any post installation scripts.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 Function PostInstallExe
 push $0
   ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" "PostInstallExe"
@@ -204,11 +215,10 @@ push $0
 pop $0
 FunctionEnd
 
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; CheckStartupParameters
 ; Sets INSTFLAGS, INSTPROG, and INSTEXE.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 Function CheckStartupParams
 push $0
 push $R0
@@ -237,7 +247,7 @@ push $R0
   Goto FINISHED
 
 ABORT:
-  MessageBox MB_OK "Could not find the program '$INSTPROG'. Silent update failed."
+  MessageBox MB_OK $(CheckStartupParamsMB)
   Quit
 
 FINISHED:
@@ -246,6 +256,9 @@ pop $R0
 pop $0
 FunctionEnd
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 Function un.CheckStartupParams
 push $0
 push $R0
@@ -274,7 +287,7 @@ push $R0
   Goto FINISHED
 
 ABORT:
-  MessageBox MB_OK "Could not find the program '$INSTPROG'. Silent update failed."
+  MessageBox MB_OK $(CheckStartupParamsMB)
   Quit
 
 FINISHED:
@@ -283,26 +296,26 @@ pop $R0
 pop $0
 FunctionEnd
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; After install completes, offer readme file
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 Function .onInstSuccess
 	MessageBox MB_YESNO \
-	"Start Second Life now?" /SD IDYES IDNO NoReadme
+	$(InstSuccesssQuestion) /SD IDYES IDNO NoReadme
 		; Assumes SetOutPath $INSTDIR
 		Exec '"$INSTDIR\$INSTEXE" $INSTFLAGS'
 	NoReadme:
 FunctionEnd
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Remove old NSIS version. Modifies no variables.
 ; Does NOT delete the LindenWorld directory, or any
 ; user files in that directory.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 Function RemoveNSIS
   Push $0
   ; Grab the installation directory of the old version
-  DetailPrint "Checking for old version..."
+  DetailPrint $(RemoveOldNSISVersion)
   ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" ""
 
   ; If key doesn't exist, skip uninstall
@@ -323,9 +336,9 @@ Function RemoveNSIS
   Pop $0
 FunctionEnd
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Make sure we're not on Windows 98 / ME
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 Function CheckWindowsVersion
 	DetailPrint "Checking Windows version..."
 	Call GetWindowsVersion
@@ -339,46 +352,49 @@ Function CheckWindowsVersion
 	StrCmp $R0 "NT" win_ver_bad
 	Return
 win_ver_bad:
-	MessageBox MB_YESNO 'Second Life only supports Windows XP, Windows 2000, and Mac OS X.$\n$\nAttempting to install on Windows $R0 can result in crashes and data loss.$\n$\nInstall anyway?' IDNO win_ver_abort
+	MessageBox MB_YESNO $(CheckWindowsVersionMB) IDNO win_ver_abort
 	Return
 win_ver_abort:
 	Quit
 FunctionEnd
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Make sure the user can install/uninstall
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 Function CheckIfAdministrator
-		DetailPrint "Checking for permission to install..."
+		DetailPrint $(CheckAdministratorInstDP)
          UserInfo::GetAccountType
          Pop $R0
          StrCmp $R0 "Admin" is_admin
-         MessageBox MB_OK 'You appear to be using a "limited" account.$\nYou must be an "administrator" to install Second Life.'
+         MessageBox MB_OK $(CheckAdministratorInstMB)
          Quit
 is_admin:
          Return
 FunctionEnd
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 Function un.CheckIfAdministrator
-		DetailPrint "Checking for permission to uninstall..."
+		DetailPrint $(CheckAdministratorUnInstDP)
          UserInfo::GetAccountType
          Pop $R0
          StrCmp $R0 "Admin" is_admin
-         MessageBox MB_OK 'You appear to be using a "limited" account.$\nYou must be an "administrator" to uninstall Second Life.'
+         MessageBox MB_OK $(CheckAdministratorUnInstMB)
          Quit
 is_admin:
          Return
 FunctionEnd
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Checks to see if the current version has already been installed (according to the registry).
 ; If it has, allow user to bail out of install process.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 Function CheckIfAlreadyCurrent
   Push $0
 	ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG" "Version"
     StrCmp $0 ${VERSION_LONG} 0 DONE
-	MessageBox MB_OKCANCEL "It appears that Second Life ${VERSION_LONG} is already installed.$\n$\nWould you like to install it again?" /SD IDOK IDOK DONE
+	MessageBox MB_OKCANCEL $(CheckIfCurrentMB) /SD IDOK IDOK DONE
     Quit
 
   DONE:
@@ -386,22 +402,21 @@ Function CheckIfAlreadyCurrent
     Return
 FunctionEnd
 	
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Close the program, if running. Modifies no variables.
 ; Allows user to bail out of install process.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 Function CloseSecondLife
   Push $0
   FindWindow $0 "Second Life" ""
   IntCmp $0 0 DONE
-  MessageBox MB_OKCANCEL "Second Life can't be installed while it is already running.$\n$\nFinish what you're doing then select OK to close Second Life and continue.$\nSelect CANCEL to cancel installation." IDOK CLOSE IDCANCEL CANCEL_INSTALL
+  MessageBox MB_OKCANCEL $(CloseSecondLifeInstMB) IDOK CLOSE IDCANCEL CANCEL_INSTALL
 
   CANCEL_INSTALL:
     Quit
 
   CLOSE:
-    DetailPrint "Waiting for Second Life to shut down..."
+    DetailPrint $(CloseSecondLifeInstDP)
     SendMessage $0 16 0 0
 
   LOOP:
@@ -416,59 +431,59 @@ Function CloseSecondLife
 FunctionEnd
 
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Delete files in Documents and Settings\<user>\SecondLife\cache
 ; Delete files in Documents and Settings\All Users\SecondLife\cache
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-Function RemoveCacheFiles
-
-; Delete files in Documents and Settings\<user>\SecondLife
-Push $0
-Push $1
-Push $2
-  DetailPrint "Deleting cache files in Documents and Settings folder"
-
-  StrCpy $0 0 ; Index number used to iterate via EnumRegKey
-
-  LOOP:
-    EnumRegKey $1 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" $0
-    StrCmp $1 "" DONE               ; no more users
-
-    ReadRegStr $2 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$1" "ProfileImagePath" 
-    StrCmp $2 "" CONTINUE 0         ; "ProfileImagePath" value is missing
-
-    ; Required since ProfileImagePath is of type REG_EXPAND_SZ
-    ExpandEnvStrings $2 $2
-
-	; When explicitly uninstalling, everything goes away
-    RMDir /r "$2\Application Data\SecondLife\cache"
-
-  CONTINUE:
-    IntOp $0 $0 + 1
-    Goto LOOP
-  DONE:
-Pop $2
-Pop $1
-Pop $0
-
-; Delete files in Documents and Settings\All Users\SecondLife
-Push $0
-  ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" "Common AppData"
-  StrCmp $0 "" +2
-  RMDir /r "$0\SecondLife\cache"
-Pop $0
-
-; Delete filse in C:\Windows\Application Data\SecondLife
-; If the user is running on a pre-NT system, Application Data lives here instead of
-; in Documents and Settings.
-RMDir /r "$WINDIR\Application Data\SecondLife\cache"
-
-FunctionEnd
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;Function RemoveCacheFiles
+;
+;; Delete files in Documents and Settings\<user>\SecondLife
+;Push $0
+;Push $1
+;Push $2
+;  DetailPrint $(RemoveCacheFilesDP)
+;
+;  StrCpy $0 0 ; Index number used to iterate via EnumRegKey
+;
+;  LOOP:
+;    EnumRegKey $1 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" $0
+;    StrCmp $1 "" DONE               ; no more users
+;
+;    ReadRegStr $2 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$1" "ProfileImagePath" 
+;    StrCmp $2 "" CONTINUE 0         ; "ProfileImagePath" value is missing
+;
+;    ; Required since ProfileImagePath is of type REG_EXPAND_SZ
+;    ExpandEnvStrings $2 $2
+;
+;	; When explicitly uninstalling, everything goes away
+;    RMDir /r "$2\Application Data\SecondLife\cache"
+;
+;  CONTINUE:
+;    IntOp $0 $0 + 1
+;    Goto LOOP
+;  DONE:
+;Pop $2
+;Pop $1
+;Pop $0
+;
+;; Delete files in Documents and Settings\All Users\SecondLife
+;Push $0
+;  ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" "Common AppData"
+;  StrCmp $0 "" +2
+;  RMDir /r "$0\SecondLife\cache"
+;Pop $0
+;
+;; Delete filse in C:\Windows\Application Data\SecondLife
+;; If the user is running on a pre-NT system, Application Data lives here instead of
+;; in Documents and Settings.
+;RMDir /r "$WINDIR\Application Data\SecondLife\cache"
+;
+;FunctionEnd
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Delete files in Documents and Settings\<user>\SecondLife
 ; Delete files in Documents and Settings\All Users\SecondLife
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 Function un.DocumentsAndSettingsFolder
 
 ; Delete files in Documents and Settings\<user>\SecondLife
@@ -522,21 +537,21 @@ RMDir /r "$WINDIR\Application Data\SecondLife"
 
 FunctionEnd
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Close the program, if running. Modifies no variables.
 ; Allows user to bail out of uninstall process.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 Function un.CloseSecondLife
   Push $0
   FindWindow $0 "Second Life" ""
   IntCmp $0 0 DONE
-  MessageBox MB_OKCANCEL "Second Life can't be uninstalled while it is already running.$\n$\nFinish what you're doing then select OK to close Second Life and continue.$\nSelect CANCEL to cancel installation." IDOK CLOSE IDCANCEL CANCEL_UNINSTALL
+  MessageBox MB_OKCANCEL $(CloseSecondLifeUnInstMB) IDOK CLOSE IDCANCEL CANCEL_UNINSTALL
 
   CANCEL_UNINSTALL:
     Quit
 
   CLOSE:
-    DetailPrint "Waiting for Second Life to shut down..."
+    DetailPrint $(CloseSecondLifeUnInstDP)
     SendMessage $0 16 0 0
 
   LOOP:
@@ -550,7 +565,7 @@ Function un.CloseSecondLife
     Return
 FunctionEnd
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Delete the installed files
 ;;; This deletes the uninstall executable, but it works 
 ;;; because it is copied to temp directory before running
@@ -558,7 +573,7 @@ FunctionEnd
 ;;; Note:  You must list all files here, because we only
 ;;; want to delete our files, not things users left in the
 ;;; application directories.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 Function un.ProgramFiles
 
 ;; Remove mozilla file first so recursive directory deletion doesn't get hung up
@@ -597,26 +612,26 @@ RMDir "$INSTDIR"
 IfFileExists "$INSTDIR" FOLDERFOUND NOFOLDER
 
 FOLDERFOUND:
-  MessageBox MB_YESNO "There are still files in your SecondLife program directory.$\n$\nThese are possibly files you created or moved to:$\n$INSTDIR$\n$\nDo you want to remove them?" IDNO NOFOLDER
+  MessageBox MB_YESNO $(DeleteProgramFilesMB) IDNO NOFOLDER
   RMDir /r "$INSTDIR"
 
 NOFOLDER:
 
 FunctionEnd
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Uninstall settings
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-UninstallText "This will uninstall Second Life ${VERSION_LONG} from your system."
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+UninstallText $(UninstallTextMsg)
 ShowUninstDetails show
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Uninstall section
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 Section Uninstall
 
 ; Start with some default values.
-StrCpy $INSTFLAGS "${INSTFLAGS}"
+StrCpy $INSTFLAGS ""
 StrCpy $INSTPROG "${INSTNAME}"
 StrCpy $INSTEXE "${INSTEXE}"
 StrCpy $INSTSHORTCUT "${SHORTCUT}"
@@ -629,9 +644,10 @@ SetShellVarContext all
 ; Make sure we're not running
 Call un.CloseSecondLife
 
-; Clean up registry keys
+; Clean up registry keys (these should all be !defines somewhere)
 DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\$INSTPROG"
 DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$INSTPROG"
+DeleteRegKey HKEY_LOCAL_MACHINE "Software\Linden Research, Inc.\Installer Language" 
 
 ; Clean up shortcuts
 Delete "$SMPROGRAMS\$INSTSHORTCUT\*.*"
@@ -652,7 +668,7 @@ Call un.ProgramFiles
 
 SectionEnd 				; end of uninstall section
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; (From the NSIS wiki, DK)
 ; GetParameterValue
 ;
@@ -667,7 +683,7 @@ SectionEnd 				; end of uninstall section
 ; or:
 ; foo.exe /S "/L=1033" /D="C:\Program Files\Foo"
 ; gpv "/L=" "1033"
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
  !macro GetParameterValue SWITCH DEFAULT
    Push $0
@@ -770,7 +786,7 @@ Function un.GetProgramName
   !insertmacro GetParameterValue "/P=" "SecondLife"
 FunctionEnd
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; (From the NSIS documentation, JC)
 ; GetWindowsVersion
 ;
@@ -787,8 +803,7 @@ FunctionEnd
 ;   Call GetWindowsVersion
 ;   Pop $R0
 ;   ; at this point $R0 is "NT 4.0" or whatnot
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 Function GetWindowsVersion
  
    Push $R0
@@ -860,3 +875,61 @@ Function GetWindowsVersion
    Exch $R0
  
 FunctionEnd
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  Note: to add new languages, add a language file include to the list 
+;;  at the top of this file, add an entry to the menu and then add an 
+;;  entry to the language ID selector below
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+Function .onInit
+
+	; read the language from registry (ok if not there) and set langauge menu
+	ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\${INSTNAME}" "InstallerLanguage"
+	StrCpy $LANGUAGE $0
+
+	Push ""
+	Push ${LANG_ENGLISH}
+	Push English
+#	Push ${LANG_GERMAN}
+#	Push German
+#	Push ${LANG_JAPANESE}
+#	Push Japanese
+	Push ${LANG_KOREAN}
+	Push Korean
+	Push A ; A means auto count languages for the auto count to work the first empty push (Push "") must remain
+	LangDLL::LangDialog "Installer Language" "Please select the language of the installer"
+	Pop $LANGUAGE
+	StrCmp $LANGUAGE "cancel" 0 +2
+		Abort
+
+	; save language in registry		
+	WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\${INSTNAME}" "InstallerLanguage" $LANGUAGE
+	
+	; generate language ID that will be used as a command line arg	
+	StrCmp $LANGUAGE "1042" 0 +3
+	StrCpy $LANGFLAGS " -set SystemLanguage ko"
+	Goto EndOfFunc
+#	StrCmp $LANGUAGE "1041" 0 +3
+#	StrCpy $LANGFLAGS " -set SystemLanguage ja"
+#	Goto EndOfFunc
+#	StrCmp $LANGUAGE "1031" 0 +3
+#	StrCpy $LANGFLAGS " -set SystemLanguage de"
+#	Goto EndOfFunc
+	StrCmp $LANGUAGE "1033" 0 +3
+	StrCpy $LANGFLAGS " -set SystemLanguage en-us"
+	Goto EndOfFunc
+	
+	EndOfFunc:
+
+FunctionEnd
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+Function un.onInit
+
+	; read language from registry and set for ininstaller
+	ReadRegStr $0 HKEY_LOCAL_MACHINE "SOFTWARE\Linden Research, Inc.\${INSTNAME}" "InstallerLanguage"
+	StrCpy $LANGUAGE $0
+
+FunctionEnd
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EOF  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\ No newline at end of file
diff --git a/indra/newview/linux_tools/wrapper.sh b/indra/newview/linux_tools/wrapper.sh
index 5f128e8e413..048aaf63827 100755
--- a/indra/newview/linux_tools/wrapper.sh
+++ b/indra/newview/linux_tools/wrapper.sh
@@ -33,6 +33,13 @@ export LL_GL_BASICEXT=x
 ##   LL_GL_BLACKLIST which solves your problems.
 #export LL_GL_BLACKLIST=abcdefghijklmno
 
+## - For advanced debugging cases, you can run the viewer under the
+##   control of another program, such as strace, gdb, or valgrind.  If
+##   you're building your own viewer, bear in mind that the executable
+##   in the bin directory will be stripped: you should replace it with
+##   an unstripped binary before you run.
+#export LL_WRAPPER='valgrind --log-file=secondlife.vg --leak-check=full --suppressions=/usr/lib/valgrind/glibc-2.5.supp --suppressions=secondlife-i686.supp'
+
 ## - Avoids an often-buggy X feature that doesn't really benefit us anyway.
 export SDL_VIDEO_X11_DGAMOUSE=0
 
@@ -41,7 +48,7 @@ export SDL_VIDEO_X11_DGAMOUSE=0
 
 RUN_PATH=`dirname "$0" || echo .`
 cd "${RUN_PATH}"
-LD_LIBRARY_PATH="`pwd`"/lib:"`pwd`"/app_settings/mozilla-runtime-linux-i686:"${LD_LIBRARY_PATH}" bin/do-not-directly-run-secondlife-bin `cat gridargs.dat` $@ | cat
+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
 echo '*********************************************************'
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index 89d60709d54..4b6e8c69966 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -831,12 +831,12 @@ class LLAgent : public LLObservable
 
 	class createStandardWearablesAllDoneCallback : public LLRefCount
 	{
-	public:
+	protected:
 		~createStandardWearablesAllDoneCallback();
 	};
 	class sendAgentWearablesUpdateCallback : public LLRefCount
 	{
-	public:
+	protected:
 		~sendAgentWearablesUpdateCallback();
 	};
 
@@ -866,7 +866,6 @@ class LLAgent : public LLObservable
 			S32 index,
 			LLWearable* wearable,
 			U32 todo = CALL_NONE);
-		~addWearableToAgentInventoryCallback() {};
 		virtual void fire(const LLUUID& inv_item);
 
 	private:
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index e95437f4ec3..6192d405afd 100644
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -179,7 +179,7 @@ class LLDrawable : public LLRefCount
 	static void cleanupDeadDrawables();
 
 protected:
-	virtual ~LLDrawable() { destroy(); }
+	~LLDrawable() { destroy(); }
 	void moveUpdatePipeline(BOOL moved);
 	void updatePartition();
 	BOOL updateMoveDamped();
diff --git a/indra/newview/llfloatergesture.cpp b/indra/newview/llfloatergesture.cpp
index 1296c96c5e6..58253184f1e 100644
--- a/indra/newview/llfloatergesture.cpp
+++ b/indra/newview/llfloatergesture.cpp
@@ -332,7 +332,6 @@ class GestureShowCallback : public LLInventoryCallback
 	{
 		mTitle = title;
 	}
-	~GestureShowCallback() {}
 	void fire(const LLUUID &inv_item)
 	{
 		LLPreviewGesture::show(mTitle.c_str(), inv_item, LLUUID::null);
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 588fb1dac01..8a1a0dcaaae 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -296,6 +296,7 @@ BOOL LLFloaterPreference::postBuild()
 LLFloaterPreference::~LLFloaterPreference()
 {
 	sInstance = NULL;
+	delete mPreferenceCore;
 }
 
 
diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp
index 14a4d7dc006..f7120674925 100644
--- a/indra/newview/llfolderview.cpp
+++ b/indra/newview/llfolderview.cpp
@@ -4262,7 +4262,8 @@ void LLFolderView::idle(void* user_data)
 	{
 		self->scrollToShowItem(self->mSelectedItems.back());
 		// continue scrolling until animated layout change is done
-		if (!self->needsArrange() || !self->isInVisibleChain())
+		if (self->getCompletedFilterGeneration() >= self->mFilter.getMinRequiredGeneration() &&
+			(!self->needsArrange() || !self->isInVisibleChain()))
 		{
 			self->mNeedsScroll = FALSE;
 		}
diff --git a/indra/newview/llhudeffecttrail.cpp b/indra/newview/llhudeffecttrail.cpp
index 1ce443fd002..dc32010b07c 100644
--- a/indra/newview/llhudeffecttrail.cpp
+++ b/indra/newview/llhudeffecttrail.cpp
@@ -168,7 +168,7 @@ void LLHUDEffectSpiral::triggerLocal()
 		{
 			if (show_beam)
 			{
-				LLViewerPartSourceBeam *psb = new LLViewerPartSourceBeam;
+				LLPointer<LLViewerPartSourceBeam> psb = new LLViewerPartSourceBeam;
 				psb->setColor(color);
 				psb->setSourceObject(mSourceObject);
 				psb->setTargetObject(mTargetObject);
@@ -183,7 +183,7 @@ void LLHUDEffectSpiral::triggerLocal()
 			{
 				if (show_beam)
 				{
-					LLViewerPartSourceBeam *psb = new LLViewerPartSourceBeam;
+					LLPointer<LLViewerPartSourceBeam> psb = new LLViewerPartSourceBeam;
 					psb->setSourceObject(mSourceObject);
 					psb->setTargetObject(NULL);
 					psb->setColor(color);
@@ -204,7 +204,7 @@ void LLHUDEffectSpiral::triggerLocal()
 				{
 					pos = gAgent.getPosAgentFromGlobal(mPositionGlobal);
 				}
-				LLViewerPartSourceSpiral *pss = new LLViewerPartSourceSpiral(pos);
+				LLPointer<LLViewerPartSourceSpiral> pss = new LLViewerPartSourceSpiral(pos);
 				if (!mSourceObject.isNull())
 				{
 					pss->setSourceObject(mSourceObject);
@@ -218,10 +218,10 @@ void LLHUDEffectSpiral::triggerLocal()
 	}
 	else
 	{
-		LLViewerPartSource *ps = mPartSourcep;
+		LLPointer<LLViewerPartSource>& ps = mPartSourcep;
 		if (mPartSourcep->getType() == LLViewerPartSource::LL_PART_SOURCE_BEAM)
 		{
-			LLViewerPartSourceBeam *psb = (LLViewerPartSourceBeam *)ps;
+			LLViewerPartSourceBeam *psb = (LLViewerPartSourceBeam *)ps.get();
 			psb->setSourceObject(mSourceObject);
 			psb->setTargetObject(mTargetObject);
 			psb->setColor(color);
@@ -232,7 +232,7 @@ void LLHUDEffectSpiral::triggerLocal()
 		}
 		else
 		{
-			LLViewerPartSourceSpiral *pss = (LLViewerPartSourceSpiral *)ps;
+			LLViewerPartSourceSpiral *pss = (LLViewerPartSourceSpiral *)ps.get();
 			pss->setSourceObject(mSourceObject);
 		}
 	}
diff --git a/indra/newview/llhudobject.h b/indra/newview/llhudobject.h
index 1148dd65217..9bd14796d57 100644
--- a/indra/newview/llhudobject.h
+++ b/indra/newview/llhudobject.h
@@ -74,7 +74,7 @@ class LLHUDObject : public LLRefCount
 	static void sortObjects();
 
 	LLHUDObject(const U8 type);
-	virtual ~LLHUDObject();
+	~LLHUDObject();
 
 	virtual void render() = 0;
 	virtual void renderForSelect() {};
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index badab645b9b..eb59a4355b2 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -3455,10 +3455,13 @@ class LLWearInventoryCategoryCallback : public LLInventoryCallback
 		 * Do nothing.  We only care about the destructor
 		 */
 	}
+
+protected:
 	~LLWearInventoryCategoryCallback()
 	{
 		wear_inventory_category_on_avatar(gInventory.getCategory(mCatID), mAppend);
 	}
+
 private:
 	LLUUID mCatID;
 	bool mAppend;
diff --git a/indra/newview/lloverlaybar.cpp b/indra/newview/lloverlaybar.cpp
index 32ae42363bf..27de4894460 100644
--- a/indra/newview/lloverlaybar.cpp
+++ b/indra/newview/lloverlaybar.cpp
@@ -308,27 +308,6 @@ void LLOverlayBar::refresh()
 		{
 			mMusicRemote->setVisible(TRUE);
 			mMusicRemote->setEnabled(TRUE);
-
-			S32 musicPlaying = gAudiop->isInternetStreamPlaying();
-
-			if ( musicPlaying == 0 )	// stopped
-			{
-				mMusicRemote->setTransportState ( LLMediaRemoteCtrl::Stop, FALSE );
-			}
-			else
-			if ( musicPlaying == 1 )	// playing
-			{
-				mMusicRemote->setTransportState ( LLMediaRemoteCtrl::Play, FALSE );
-				if (gAudiop)
-				{
-					gAudiop->setInternetStreamGain ( gSavedSettings.getF32 ( "AudioLevelMusic" ) );
-				}
-			}
-			else
-			if ( musicPlaying == 2 )	// paused
-			{
-				mMusicRemote->setTransportState ( LLMediaRemoteCtrl::Stop, FALSE );
-			}
 		}
 	}
 
diff --git a/indra/newview/llpanelgroup.cpp b/indra/newview/llpanelgroup.cpp
index 49623296193..23f7a4aba60 100644
--- a/indra/newview/llpanelgroup.cpp
+++ b/indra/newview/llpanelgroup.cpp
@@ -58,7 +58,7 @@ BOOL LLPanelGroupTab::postBuild()
 	if (txt)
 	{
 		mHelpText = txt->getText();
-		removeChild(txt);
+		removeChild(txt, TRUE);
 	}
 	return TRUE;
 }
@@ -265,13 +265,13 @@ BOOL LLPanelGroup::postBuild()
 	if (txt)
 	{
 		mDefaultNeedsApplyMesg = txt->getText();
-		removeChild(txt);
+		removeChild(txt, TRUE);
 	}
 	txt = (LLTextBox*)getChildByName("want_apply_text");
 	if (txt)
 	{
 		mWantApplyMesg = txt->getText();
-		removeChild(txt);
+		removeChild(txt, TRUE);
 	}
 
 	LLButton* button = (LLButton*) getChildByName("btn_ok");
diff --git a/indra/newview/llpanelgroupgeneral.cpp b/indra/newview/llpanelgroupgeneral.cpp
index 161b46a17c5..9967a701118 100644
--- a/indra/newview/llpanelgroupgeneral.cpp
+++ b/indra/newview/llpanelgroupgeneral.cpp
@@ -115,7 +115,7 @@ BOOL LLPanelGroupGeneral::postBuild()
 	if (founder)
 	{
 		mFounderName = new LLNameBox(founder->getName(),founder->getRect(),LLUUID::null,FALSE,founder->getFont(),founder->getMouseOpaque());
-		removeChild(founder);
+		removeChild(founder, TRUE);
 		addChild(mFounderName);
 	}
 
@@ -201,14 +201,14 @@ BOOL LLPanelGroupGeneral::postBuild()
 	if (txt)
 	{
 		mIncompleteMemberDataStr = txt->getText();
-		removeChild(txt);
+		removeChild(txt, TRUE);
 	}
 
 	txt = (LLTextBox*)getChildByName("confirm_group_create_str");
 	if (txt)
 	{
 		mConfirmGroupCreateStr = txt->getText();
-		removeChild(txt);
+		removeChild(txt, TRUE);
 	}
 
 	// If the group_id is null, then we are creating a new group
diff --git a/indra/newview/llpanelgrouplandmoney.cpp b/indra/newview/llpanelgrouplandmoney.cpp
index b11b6bd2538..09edc4c8af9 100644
--- a/indra/newview/llpanelgrouplandmoney.cpp
+++ b/indra/newview/llpanelgrouplandmoney.cpp
@@ -549,14 +549,14 @@ BOOL LLPanelGroupLandMoney::postBuild()
 	if ( no_permsp )
 	{
 		mImplementationp->mCantViewParcelsText = no_permsp->getText();
-		removeChild(no_permsp);
+		removeChild(no_permsp, TRUE);
 	}
 
 	no_permsp = (LLTextBox*) getChildByName("cant_view_group_accounting_text");
 	if ( no_permsp )
 	{
 		mImplementationp->mCantViewAccountsText = no_permsp->getText();
-		removeChild(no_permsp);
+		removeChild(no_permsp, TRUE);
 	}
 
 	
diff --git a/indra/newview/llpanelgroupnotices.cpp b/indra/newview/llpanelgroupnotices.cpp
index b0fc26f22a2..09ce13b1d66 100644
--- a/indra/newview/llpanelgroupnotices.cpp
+++ b/indra/newview/llpanelgroupnotices.cpp
@@ -259,7 +259,7 @@ BOOL LLPanelGroupNotices::postBuild()
 	if (txt)
 	{
 		mNoNoticesStr = txt->getText();
-		removeChild(txt);
+		removeChild(txt, TRUE);
 	}
 
 	mPanelCreateNotice = (LLPanel*) getChildByName("panel_create_new_notice",recurse);
@@ -274,7 +274,7 @@ BOOL LLPanelGroupNotices::postBuild()
 	target->setToolTip(dtv->getToolTip());
 
 	mPanelCreateNotice->addChild(target);
-	mPanelCreateNotice->removeChild(dtv);
+	mPanelCreateNotice->removeChild(dtv, TRUE);
 
 	arrangeNoticeView(VIEW_PAST_NOTICE);
 
diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp
index 30a86a40b26..faa278b667e 100644
--- a/indra/newview/llpanelgrouproles.cpp
+++ b/indra/newview/llpanelgrouproles.cpp
@@ -152,13 +152,13 @@ BOOL LLPanelGroupRoles::postBuild()
 	if (txt)
 	{
 		mDefaultNeedsApplyMesg = txt->getText();
-		removeChild(txt);
+		removeChild(txt, TRUE);
 	}
 	txt = (LLTextBox*)getChildByName("want_apply_text");
 	if (txt)
 	{
 		mWantApplyMesg = txt->getText();
-		removeChild(txt);
+		removeChild(txt, TRUE);
 	}
 
 	return LLPanelGroupTab::postBuild();
@@ -521,21 +521,21 @@ BOOL LLPanelGroupSubTab::postBuild()
 	if (icon && icon->getImage().notNull())
 	{
 		mActionIcons["folder"] = icon->getImage();
-		removeChild(icon);
+		removeChild(icon, TRUE);
 	}
 
 	icon = (LLIconCtrl*) getChildByName("power_all_have_icon",no_recurse);
 	if (icon && icon->getImage().notNull())
 	{
 		mActionIcons["full"] = icon->getImage();
-		removeChild(icon);
+		removeChild(icon, TRUE);
 	}
 
 	icon = (LLIconCtrl*) getChildByName("power_partial_icon",no_recurse);
 	if (icon && icon->getImage().notNull())
 	{
 		mActionIcons["partial"] = icon->getImage();
-		removeChild(icon);
+		removeChild(icon, TRUE);
 	}
 
 	return LLPanelGroupTab::postBuild();
@@ -1805,7 +1805,7 @@ BOOL LLPanelGroupRolesSubTab::postBuildSubTab(LLView* root)
 	if (txt)
 	{
 		mRemoveEveryoneTxt = txt->getText();
-		parent->removeChild(txt);
+		parent->removeChild(txt, TRUE);
 	}
 
 	mCreateRoleButton = 
diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index dcfede70aa8..ea18b2838fb 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -1162,6 +1162,9 @@ void LLPanelObject::onCommitParametric( LLUICtrl* ctrl, void* userdata )
 	if (selected_type == MI_SCULPT)
 	{
 		self->mObject->setParameterEntryInUse(LLNetworkData::PARAMS_SCULPT, TRUE, TRUE);
+		LLSculptParams *sculpt_params = (LLSculptParams *)self->mObject->getParameterEntry(LLNetworkData::PARAMS_SCULPT);
+		if (sculpt_params)
+			volume_params.setSculptID(sculpt_params->getSculptTexture(), 0);
 	}
 	else
 	{
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 98f842902d0..6698ee7505d 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -101,7 +101,7 @@ LLColor4 LLSelectMgr::sHighlightParentColor;
 LLColor4 LLSelectMgr::sHighlightChildColor;
 LLColor4 LLSelectMgr::sContextSilhouetteColor;
 
-static LLObjectSelection* get_null_object_selection();
+static LLObjectSelection *get_null_object_selection();
 template<> 
 	const LLHandle<LLObjectSelection>::NullFunc 
 		LLHandle<LLObjectSelection>::sNullFunc = get_null_object_selection;
@@ -125,14 +125,26 @@ struct LLDeRezInfo
 //
 
 
+static LLPointer<LLObjectSelection> sNullSelection;
+
 //
 // Functions
 //
 
-LLObjectSelection* get_null_object_selection()
+void LLSelectMgr::cleanupGlobals()
+{
+	delete gSelectMgr;
+	gSelectMgr = NULL;
+	sNullSelection = NULL;
+}
+
+LLObjectSelection *get_null_object_selection()
 {
-	static LLObjectSelection null_selection;
-	return &null_selection;;
+	if (sNullSelection.isNull())
+	{
+		sNullSelection = new LLObjectSelection;
+	}
+	return sNullSelection;
 }
 
 
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index 0b4392f318a..65f58da1cc8 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -94,9 +94,12 @@ typedef enum e_selection_type
 class LLObjectSelection : public std::list<LLSelectNode*>, public LLRefCount
 {
 	friend class LLSelectMgr;
+
+protected:
+	~LLObjectSelection();
+
 public:
 	LLObjectSelection();
-	virtual ~LLObjectSelection();
 
 	void updateEffects();
 
@@ -195,6 +198,8 @@ class LLSelectMgr : public LLEditMenuHandler
 	LLSelectMgr();
 	~LLSelectMgr();
 
+	static void cleanupGlobals();
+
 	// LLEditMenuHandler interface
 	virtual BOOL canUndo();
 	virtual void undo();
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 315a8e28288..43417d00063 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -1697,7 +1697,7 @@ void LLSpatialPartition::processImagery(LLCamera* camera)
 				cube_map->initGL();
 			}
 
-			if (gPipeline.mCubeBuffer == NULL)
+			if (gPipeline.mCubeBuffer.isNull())
 			{
 				gPipeline.mCubeBuffer = new LLCubeMap();
 				gPipeline.mCubeBuffer->initGL();
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index c65f4063bfa..a2f24005df1 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -146,7 +146,6 @@ class LLSpatialGroup : public LLOctreeListener<LLDrawable>
 	} eSetStateMode;
 
 	LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part);
-	virtual ~LLSpatialGroup();
 
 	BOOL isDead()							{ return isState(DEAD); }
 	BOOL isState(U32 state) const			{ return mState & state ? TRUE : FALSE; }
@@ -190,6 +189,8 @@ class LLSpatialGroup : public LLOctreeListener<LLDrawable>
 	virtual void handleChildRemoval(const OctreeNode* parent, const OctreeNode* child);
 
 protected:
+	virtual ~LLSpatialGroup();
+
 	U32 mState;
 	S32 mLODHash;
 	static S32 sLODSeed;
@@ -323,11 +324,13 @@ class LLSpatialPartition: public LLGeometryManager
 // class for creating bridges between spatial partitions
 class LLSpatialBridge : public LLDrawable, public LLSpatialPartition
 {
+protected:
+	~LLSpatialBridge();
+
 public:
 	typedef std::vector<LLPointer<LLSpatialBridge> > bridge_vector_t;
 	
 	LLSpatialBridge(LLDrawable* root, U32 data_mask);
-	virtual ~LLSpatialBridge();
 	
 	virtual BOOL isSpatialBridge() const		{ return TRUE; }
 
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 5e981b8922e..f2d0d594f85 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -2787,25 +2787,26 @@ void update_app(BOOL mandatory, const std::string& auth_msg)
 	LLStringBase<char>::format_map_t args;
 	args["[MESSAGE]"] = msg;
 	
-	BOOL *mandatoryp = new BOOL(mandatory);
+	// represent a bool as a null/non-null pointer
+	void *mandatoryp = mandatory ? &mandatory : NULL;
 
 #if LL_WINDOWS
 	if (mandatory)
 	{
 		gViewerWindow->alertXml("DownloadWindowsMandatory", args,
 								update_dialog_callback,
-								(void *)mandatoryp);
+								mandatoryp);
 	}
 	else
 	{
 #if LL_RELEASE_FOR_DOWNLOAD
 		gViewerWindow->alertXml("DownloadWindowsReleaseForDownload", args,
 								update_dialog_callback,
-								(void *)mandatoryp);
+								mandatoryp);
 #else
 		gViewerWindow->alertXml("DownloadWindows", args,
 								update_dialog_callback,
-								(void *)mandatoryp);
+								mandatoryp);
 #endif
 	}
 #else
@@ -2813,18 +2814,18 @@ void update_app(BOOL mandatory, const std::string& auth_msg)
 	{
 		gViewerWindow->alertXml("DownloadMacMandatory", args,
 								update_dialog_callback,
-								(void *)mandatoryp);
+								mandatoryp);
 	}
 	else
 	{
 #if LL_RELEASE_FOR_DOWNLOAD
 		gViewerWindow->alertXml("DownloadMacReleaseForDownload", args,
 								update_dialog_callback,
-								(void *)mandatoryp);
+								mandatoryp);
 #else
 		gViewerWindow->alertXml("DownloadMac", args,
 								update_dialog_callback,
-								(void *)mandatoryp);
+								mandatoryp);
 #endif
 	}
 #endif
@@ -2835,7 +2836,7 @@ void update_app(BOOL mandatory, const std::string& auth_msg)
 void update_dialog_callback(S32 option, void *userdata)
 {
 	std::string update_exe_path;
-	BOOL mandatory = *(BOOL *)userdata;
+	BOOL mandatory = userdata != NULL;
 
 #if !LL_RELEASE_FOR_DOWNLOAD
 	if (option == 2)
diff --git a/indra/newview/lltoolbrush.cpp b/indra/newview/lltoolbrush.cpp
index e56635e1810..69de1142a4d 100644
--- a/indra/newview/lltoolbrush.cpp
+++ b/indra/newview/lltoolbrush.cpp
@@ -397,7 +397,7 @@ void LLToolBrushLand::handleSelect()
 //	if (!mBrushSelected)
 	{
 		mLastShowParcelOwners = gSavedSettings.getBOOL("ShowParcelOwners");
-		gSavedSettings.setBOOL("ShowParcelOwners", TRUE);
+		gSavedSettings.setBOOL("ShowParcelOwners", mLastShowParcelOwners);
 		mBrushSelected = TRUE;
 	}
 }
@@ -410,6 +410,7 @@ void LLToolBrushLand::handleDeselect()
 		gEditMenuHandler = NULL;
 	}
 	gFloaterTools->setStatusText("");
+	mLastShowParcelOwners = gSavedSettings.getBOOL("ShowParcelOwners");
 	gSavedSettings.setBOOL("ShowParcelOwners", mLastShowParcelOwners);
 	gParcelMgr->setSelectionVisible(TRUE);
 	mBrushSelected = FALSE;
diff --git a/indra/newview/lltoolselectland.cpp b/indra/newview/lltoolselectland.cpp
index f64bf6bf2d5..84834d58027 100644
--- a/indra/newview/lltoolselectland.cpp
+++ b/indra/newview/lltoolselectland.cpp
@@ -198,7 +198,7 @@ void LLToolSelectLand::handleSelect()
 {
 	gFloaterTools->setStatusText("Click and drag to select land");
 	mLastShowParcelOwners = gSavedSettings.getBOOL("ShowParcelOwners");
-	gSavedSettings.setBOOL("ShowParcelOwners", TRUE);
+	gSavedSettings.setBOOL("ShowParcelOwners", mLastShowParcelOwners);
 }
 
 
@@ -206,6 +206,7 @@ void LLToolSelectLand::handleDeselect()
 {
 	gFloaterTools->setStatusText("");
 	mSelection = NULL;
+	mLastShowParcelOwners = gSavedSettings.getBOOL("ShowParcelOwners");
 	//gParcelMgr->deselectLand();
 	gSavedSettings.setBOOL("ShowParcelOwners", mLastShowParcelOwners);
 }
diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h
index 2668e1121c6..84cdadaf9b2 100644
--- a/indra/newview/llviewerinventory.h
+++ b/indra/newview/llviewerinventory.h
@@ -171,7 +171,6 @@ class LLViewerInventoryCategory  : public LLInventoryCategory
 class LLInventoryCallback : public LLRefCount
 {
 public:
-	virtual ~LLInventoryCallback() {}
 	virtual void fire(const LLUUID& inv_item) = 0;
 };
 
@@ -186,8 +185,11 @@ class RezAttachmentCallback : public LLInventoryCallback
 {
 public:
 	RezAttachmentCallback(LLViewerJointAttachment *attachmentp);
-	~RezAttachmentCallback();
 	void fire(const LLUUID& inv_item);
+
+protected:
+	~RezAttachmentCallback();
+
 private:
 	LLViewerJointAttachment* mAttach;
 };
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index c8b62146d6b..898af8932fd 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -1408,6 +1408,8 @@ void init_server_menu(LLMenuGL* menu)
 	menu->createJumpKeys();
 }
 
+static std::vector<LLPointer<view_listener_t> > sMenus;
+
 //-----------------------------------------------------------------------------
 // cleanup_menus()
 //-----------------------------------------------------------------------------
@@ -1438,7 +1440,9 @@ void cleanup_menus()
 	gPopupMenuView = NULL;
 
 	delete gMenuHolder;
-	gMenuHolder = NULL; 
+	gMenuHolder = NULL;
+
+	sMenus.clear();
 }
 
 //-----------------------------------------------------------------------------
@@ -7529,199 +7533,205 @@ class LLToolsSelectTool : public view_listener_t
 	}
 };
 
+static void addMenu(view_listener_t *menu, const char *name)
+{
+	sMenus.push_back(menu);
+	menu->registerListener(gMenuHolder, name);
+}
+
 void initialize_menus()
 {
 	// File menu
 	init_menu_file();
 
 	// Edit menu
-	(new LLEditUndo())->registerListener(gMenuHolder, "Edit.Undo");
-	(new LLEditRedo())->registerListener(gMenuHolder, "Edit.Redo");
-	(new LLEditCut())->registerListener(gMenuHolder, "Edit.Cut");
-	(new LLEditCopy())->registerListener(gMenuHolder, "Edit.Copy");
-	(new LLEditPaste())->registerListener(gMenuHolder, "Edit.Paste");
-	(new LLEditDelete())->registerListener(gMenuHolder, "Edit.Delete");
-	(new LLEditSearch())->registerListener(gMenuHolder, "Edit.Search");
-	(new LLEditSelectAll())->registerListener(gMenuHolder, "Edit.SelectAll");
-	(new LLEditDeselect())->registerListener(gMenuHolder, "Edit.Deselect");
-	(new LLEditDuplicate())->registerListener(gMenuHolder, "Edit.Duplicate");
-	(new LLEditTakeOff())->registerListener(gMenuHolder, "Edit.TakeOff");
-
-	(new LLEditEnableUndo())->registerListener(gMenuHolder, "Edit.EnableUndo");
-	(new LLEditEnableRedo())->registerListener(gMenuHolder, "Edit.EnableRedo");
-	(new LLEditEnableCut())->registerListener(gMenuHolder, "Edit.EnableCut");
-	(new LLEditEnableCopy())->registerListener(gMenuHolder, "Edit.EnableCopy");
-	(new LLEditEnablePaste())->registerListener(gMenuHolder, "Edit.EnablePaste");
-	(new LLEditEnableDelete())->registerListener(gMenuHolder, "Edit.EnableDelete");
-	(new LLEditEnableSelectAll())->registerListener(gMenuHolder, "Edit.EnableSelectAll");
-	(new LLEditEnableDeselect())->registerListener(gMenuHolder, "Edit.EnableDeselect");
-	(new LLEditEnableDuplicate())->registerListener(gMenuHolder, "Edit.EnableDuplicate");
-	(new LLEditEnableTakeOff())->registerListener(gMenuHolder, "Edit.EnableTakeOff");
-	(new LLEditEnableCustomizeAvatar())->registerListener(gMenuHolder, "Edit.EnableCustomizeAvatar");
+	addMenu(new LLEditUndo(), "Edit.Undo");
+	addMenu(new LLEditRedo(), "Edit.Redo");
+	addMenu(new LLEditCut(), "Edit.Cut");
+	addMenu(new LLEditCopy(), "Edit.Copy");
+	addMenu(new LLEditPaste(), "Edit.Paste");
+	addMenu(new LLEditDelete(), "Edit.Delete");
+	addMenu(new LLEditSearch(), "Edit.Search");
+	addMenu(new LLEditSelectAll(), "Edit.SelectAll");
+	addMenu(new LLEditDeselect(), "Edit.Deselect");
+	addMenu(new LLEditDuplicate(), "Edit.Duplicate");
+	addMenu(new LLEditTakeOff(), "Edit.TakeOff");
+
+	addMenu(new LLEditEnableUndo(), "Edit.EnableUndo");
+	addMenu(new LLEditEnableRedo(), "Edit.EnableRedo");
+	addMenu(new LLEditEnableCut(), "Edit.EnableCut");
+	addMenu(new LLEditEnableCopy(), "Edit.EnableCopy");
+	addMenu(new LLEditEnablePaste(), "Edit.EnablePaste");
+	addMenu(new LLEditEnableDelete(), "Edit.EnableDelete");
+	addMenu(new LLEditEnableSelectAll(), "Edit.EnableSelectAll");
+	addMenu(new LLEditEnableDeselect(), "Edit.EnableDeselect");
+	addMenu(new LLEditEnableDuplicate(), "Edit.EnableDuplicate");
+	addMenu(new LLEditEnableTakeOff(), "Edit.EnableTakeOff");
+	addMenu(new LLEditEnableCustomizeAvatar(), "Edit.EnableCustomizeAvatar");
 
 	// View menu
-	(new LLViewMouselook())->registerListener(gMenuHolder, "View.Mouselook");
-	(new LLViewBuildMode())->registerListener(gMenuHolder, "View.BuildMode");
-	(new LLViewResetView())->registerListener(gMenuHolder, "View.ResetView");
-	(new LLViewLookAtLastChatter())->registerListener(gMenuHolder, "View.LookAtLastChatter");
-	(new LLViewShowHoverTips())->registerListener(gMenuHolder, "View.ShowHoverTips");
-	(new LLViewHighlightTransparent())->registerListener(gMenuHolder, "View.HighlightTransparent");
-	(new LLViewToggleBeacon())->registerListener(gMenuHolder, "View.ToggleBeacon");
-	(new LLViewToggleRenderType())->registerListener(gMenuHolder, "View.ToggleRenderType");
-	(new LLViewShowHUDAttachments())->registerListener(gMenuHolder, "View.ShowHUDAttachments");
-	(new LLViewZoomOut())->registerListener(gMenuHolder, "View.ZoomOut");
-	(new LLViewZoomIn())->registerListener(gMenuHolder, "View.ZoomIn");
-	(new LLViewZoomDefault())->registerListener(gMenuHolder, "View.ZoomDefault");
-	(new LLViewFullscreen())->registerListener(gMenuHolder, "View.Fullscreen");
-	(new LLViewDefaultUISize())->registerListener(gMenuHolder, "View.DefaultUISize");
-
-	(new LLViewEnableMouselook())->registerListener(gMenuHolder, "View.EnableMouselook");
-	(new LLViewEnableLastChatter())->registerListener(gMenuHolder, "View.EnableLastChatter");
-
-	(new LLViewCheckBuildMode())->registerListener(gMenuHolder, "View.CheckBuildMode");
-	(new LLViewCheckShowHoverTips())->registerListener(gMenuHolder, "View.CheckShowHoverTips");
-	(new LLViewCheckHighlightTransparent())->registerListener(gMenuHolder, "View.CheckHighlightTransparent");
-	(new LLViewCheckBeaconEnabled())->registerListener(gMenuHolder, "View.CheckBeaconEnabled");
-	(new LLViewCheckRenderType())->registerListener(gMenuHolder, "View.CheckRenderType");
-	(new LLViewCheckHUDAttachments())->registerListener(gMenuHolder, "View.CheckHUDAttachments");
+	addMenu(new LLViewMouselook(), "View.Mouselook");
+	addMenu(new LLViewBuildMode(), "View.BuildMode");
+	addMenu(new LLViewResetView(), "View.ResetView");
+	addMenu(new LLViewLookAtLastChatter(), "View.LookAtLastChatter");
+	addMenu(new LLViewShowHoverTips(), "View.ShowHoverTips");
+	addMenu(new LLViewHighlightTransparent(), "View.HighlightTransparent");
+	addMenu(new LLViewToggleBeacon(), "View.ToggleBeacon");
+	addMenu(new LLViewToggleRenderType(), "View.ToggleRenderType");
+	addMenu(new LLViewShowHUDAttachments(), "View.ShowHUDAttachments");
+	addMenu(new LLViewZoomOut(), "View.ZoomOut");
+	addMenu(new LLViewZoomIn(), "View.ZoomIn");
+	addMenu(new LLViewZoomDefault(), "View.ZoomDefault");
+	addMenu(new LLViewFullscreen(), "View.Fullscreen");
+	addMenu(new LLViewDefaultUISize(), "View.DefaultUISize");
+
+	addMenu(new LLViewEnableMouselook(), "View.EnableMouselook");
+	addMenu(new LLViewEnableLastChatter(), "View.EnableLastChatter");
+
+	addMenu(new LLViewCheckBuildMode(), "View.CheckBuildMode");
+	addMenu(new LLViewCheckShowHoverTips(), "View.CheckShowHoverTips");
+	addMenu(new LLViewCheckHighlightTransparent(), "View.CheckHighlightTransparent");
+	addMenu(new LLViewCheckBeaconEnabled(), "View.CheckBeaconEnabled");
+	addMenu(new LLViewCheckRenderType(), "View.CheckRenderType");
+	addMenu(new LLViewCheckHUDAttachments(), "View.CheckHUDAttachments");
 
 	// World menu
-	(new LLWorldChat())->registerListener(gMenuHolder, "World.Chat");
-	(new LLWorldStartGesture())->registerListener(gMenuHolder, "World.StartGesture");
-	(new LLWorldAlwaysRun())->registerListener(gMenuHolder, "World.AlwaysRun");
-	(new LLWorldFly())->registerListener(gMenuHolder, "World.Fly");
-	(new LLWorldCreateLandmark())->registerListener(gMenuHolder, "World.CreateLandmark");
-	(new LLWorldSetHomeLocation())->registerListener(gMenuHolder, "World.SetHomeLocation");
-	(new LLWorldTeleportHome())->registerListener(gMenuHolder, "World.TeleportHome");
-	(new LLWorldSetAway())->registerListener(gMenuHolder, "World.SetAway");
-	(new LLWorldSetBusy())->registerListener(gMenuHolder, "World.SetBusy");
+	addMenu(new LLWorldChat(), "World.Chat");
+	addMenu(new LLWorldStartGesture(), "World.StartGesture");
+	addMenu(new LLWorldAlwaysRun(), "World.AlwaysRun");
+	addMenu(new LLWorldFly(), "World.Fly");
+	addMenu(new LLWorldCreateLandmark(), "World.CreateLandmark");
+	addMenu(new LLWorldSetHomeLocation(), "World.SetHomeLocation");
+	addMenu(new LLWorldTeleportHome(), "World.TeleportHome");
+	addMenu(new LLWorldSetAway(), "World.SetAway");
+	addMenu(new LLWorldSetBusy(), "World.SetBusy");
 
-	(new LLWorldEnableCreateLandmark())->registerListener(gMenuHolder, "World.EnableCreateLandmark");
-	(new LLWorldEnableSetHomeLocation())->registerListener(gMenuHolder, "World.EnableSetHomeLocation");
-	(new LLWorldEnableTeleportHome())->registerListener(gMenuHolder, "World.EnableTeleportHome");
-	(new LLWorldEnableBuyLand())->registerListener(gMenuHolder, "World.EnableBuyLand");
+	addMenu(new LLWorldEnableCreateLandmark(), "World.EnableCreateLandmark");
+	addMenu(new LLWorldEnableSetHomeLocation(), "World.EnableSetHomeLocation");
+	addMenu(new LLWorldEnableTeleportHome(), "World.EnableTeleportHome");
+	addMenu(new LLWorldEnableBuyLand(), "World.EnableBuyLand");
 
-	(new LLWorldCheckAlwaysRun())->registerListener(gMenuHolder, "World.CheckAlwaysRun");
+	addMenu(new LLWorldCheckAlwaysRun(), "World.CheckAlwaysRun");
 
-	(new LLWorldForceSun())->registerListener(gMenuHolder, "World.ForceSun");
+	addMenu(new LLWorldForceSun(), "World.ForceSun");
 
 	// Tools menu
-	(new LLToolsSelectTool())->registerListener(gMenuHolder, "Tools.SelectTool");
-	(new LLToolsSelectOnlyMyObjects())->registerListener(gMenuHolder, "Tools.SelectOnlyMyObjects");
-	(new LLToolsSelectOnlyMovableObjects())->registerListener(gMenuHolder, "Tools.SelectOnlyMovableObjects");
-	(new LLToolsSelectBySurrounding())->registerListener(gMenuHolder, "Tools.SelectBySurrounding");
-	(new LLToolsShowHiddenSelection())->registerListener(gMenuHolder, "Tools.ShowHiddenSelection");
-	(new LLToolsShowSelectionLightRadius())->registerListener(gMenuHolder, "Tools.ShowSelectionLightRadius");
-	(new LLToolsSnapObjectXY())->registerListener(gMenuHolder, "Tools.SnapObjectXY");
-	(new LLToolsUseSelectionForGrid())->registerListener(gMenuHolder, "Tools.UseSelectionForGrid");
-	(new LLToolsLink())->registerListener(gMenuHolder, "Tools.Link");
-	(new LLToolsUnlink())->registerListener(gMenuHolder, "Tools.Unlink");
-	(new LLToolsStopAllAnimations())->registerListener(gMenuHolder, "Tools.StopAllAnimations");
-	(new LLToolsLookAtSelection())->registerListener(gMenuHolder, "Tools.LookAtSelection");
-	(new LLToolsBuyOrTake())->registerListener(gMenuHolder, "Tools.BuyOrTake");
-	(new LLToolsTakeCopy())->registerListener(gMenuHolder, "Tools.TakeCopy");
-	(new LLToolsSaveToInventory())->registerListener(gMenuHolder, "Tools.SaveToInventory");
-	(new LLToolsSaveToObjectInventory())->registerListener(gMenuHolder, "Tools.SaveToObjectInventory");
-	(new LLToolsSelectedScriptAction())->registerListener(gMenuHolder, "Tools.SelectedScriptAction");
-
-	(new LLToolsEnableToolNotPie())->registerListener(gMenuHolder, "Tools.EnableToolNotPie");
-	(new LLToolsEnableLink())->registerListener(gMenuHolder, "Tools.EnableLink");
-	(new LLToolsEnableUnlink())->registerListener(gMenuHolder, "Tools.EnableUnlink");
-	(new LLToolsEnableBuyOrTake())->registerListener(gMenuHolder, "Tools.EnableBuyOrTake");
-	(new LLToolsEnableTakeCopy())->registerListener(gMenuHolder, "Tools.EnableTakeCopy");
-	(new LLToolsEnableSaveToInventory())->registerListener(gMenuHolder, "Tools.SaveToInventory");
-	(new LLToolsEnableSaveToObjectInventory())->registerListener(gMenuHolder, "Tools.SaveToObjectInventory");
-
-	/*(new LLToolsVisibleBuyObject())->registerListener(gMenuHolder, "Tools.VisibleBuyObject");
-	(new LLToolsVisibleTakeObject())->registerListener(gMenuHolder, "Tools.VisibleTakeObject");*/
+	addMenu(new LLToolsSelectTool(), "Tools.SelectTool");
+	addMenu(new LLToolsSelectOnlyMyObjects(), "Tools.SelectOnlyMyObjects");
+	addMenu(new LLToolsSelectOnlyMovableObjects(), "Tools.SelectOnlyMovableObjects");
+	addMenu(new LLToolsSelectBySurrounding(), "Tools.SelectBySurrounding");
+	addMenu(new LLToolsShowHiddenSelection(), "Tools.ShowHiddenSelection");
+	addMenu(new LLToolsShowSelectionLightRadius(), "Tools.ShowSelectionLightRadius");
+	addMenu(new LLToolsSnapObjectXY(), "Tools.SnapObjectXY");
+	addMenu(new LLToolsUseSelectionForGrid(), "Tools.UseSelectionForGrid");
+	addMenu(new LLToolsLink(), "Tools.Link");
+	addMenu(new LLToolsUnlink(), "Tools.Unlink");
+	addMenu(new LLToolsStopAllAnimations(), "Tools.StopAllAnimations");
+	addMenu(new LLToolsLookAtSelection(), "Tools.LookAtSelection");
+	addMenu(new LLToolsBuyOrTake(), "Tools.BuyOrTake");
+	addMenu(new LLToolsTakeCopy(), "Tools.TakeCopy");
+	addMenu(new LLToolsSaveToInventory(), "Tools.SaveToInventory");
+	addMenu(new LLToolsSaveToObjectInventory(), "Tools.SaveToObjectInventory");
+	addMenu(new LLToolsSelectedScriptAction(), "Tools.SelectedScriptAction");
+
+	addMenu(new LLToolsEnableToolNotPie(), "Tools.EnableToolNotPie");
+	addMenu(new LLToolsEnableLink(), "Tools.EnableLink");
+	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 LLToolsVisibleBuyObject(), "Tools.VisibleBuyObject");
+	addMenu(new LLToolsVisibleTakeObject(), "Tools.VisibleTakeObject");*/
 
 	// Help menu
-	(new LLHelpLiveHelp())->registerListener(gMenuHolder, "Help.LiveHelp");
-	(new LLHelpMOTD())->registerListener(gMenuHolder, "Help.MOTD");
+	addMenu(new LLHelpLiveHelp(), "Help.LiveHelp");
+	addMenu(new LLHelpMOTD(), "Help.MOTD");
 
 	// Self pie menu
-	(new LLSelfStandUp())->registerListener(gMenuHolder, "Self.StandUp");
-	(new LLSelfRemoveAllAttachments())->registerListener(gMenuHolder, "Self.RemoveAllAttachments");
+	addMenu(new LLSelfStandUp(), "Self.StandUp");
+	addMenu(new LLSelfRemoveAllAttachments(), "Self.RemoveAllAttachments");
 
-	(new LLSelfEnableStandUp())->registerListener(gMenuHolder, "Self.EnableStandUp");
-	(new LLSelfEnableRemoveAllAttachments())->registerListener(gMenuHolder, "Self.EnableRemoveAllAttachments");
+	addMenu(new LLSelfEnableStandUp(), "Self.EnableStandUp");
+	addMenu(new LLSelfEnableRemoveAllAttachments(), "Self.EnableRemoveAllAttachments");
 
 	 // Avatar pie menu
-	(new LLObjectMute())->registerListener(gMenuHolder, "Avatar.Mute");
-	(new LLAvatarAddFriend())->registerListener(gMenuHolder, "Avatar.AddFriend");
-	(new LLAvatarFreeze())->registerListener(gMenuHolder, "Avatar.Freeze");
-	(new LLAvatarDebug())->registerListener(gMenuHolder, "Avatar.Debug");
-	(new LLAvatarVisibleDebug())->registerListener(gMenuHolder, "Avatar.VisibleDebug");
-	(new LLAvatarEnableDebug())->registerListener(gMenuHolder, "Avatar.EnableDebug");
-	(new LLAvatarGiveCard())->registerListener(gMenuHolder, "Avatar.GiveCard");
-	(new LLAvatarEject())->registerListener(gMenuHolder, "Avatar.Eject");
-	(new LLAvatarSendIM())->registerListener(gMenuHolder, "Avatar.SendIM");
+	addMenu(new LLObjectMute(), "Avatar.Mute");
+	addMenu(new LLAvatarAddFriend(), "Avatar.AddFriend");
+	addMenu(new LLAvatarFreeze(), "Avatar.Freeze");
+	addMenu(new LLAvatarDebug(), "Avatar.Debug");
+	addMenu(new LLAvatarVisibleDebug(), "Avatar.VisibleDebug");
+	addMenu(new LLAvatarEnableDebug(), "Avatar.EnableDebug");
+	addMenu(new LLAvatarGiveCard(), "Avatar.GiveCard");
+	addMenu(new LLAvatarEject(), "Avatar.Eject");
+	addMenu(new LLAvatarSendIM(), "Avatar.SendIM");
 	
-	(new LLObjectEnableMute())->registerListener(gMenuHolder, "Avatar.EnableMute");
-	(new LLAvatarEnableAddFriend())->registerListener(gMenuHolder, "Avatar.EnableAddFriend");
-	(new LLAvatarEnableFreezeEject())->registerListener(gMenuHolder, "Avatar.EnableFreezeEject");
+	addMenu(new LLObjectEnableMute(), "Avatar.EnableMute");
+	addMenu(new LLAvatarEnableAddFriend(), "Avatar.EnableAddFriend");
+	addMenu(new LLAvatarEnableFreezeEject(), "Avatar.EnableFreezeEject");
 
 	// Object pie menu
-	(new LLObjectOpen())->registerListener(gMenuHolder, "Object.Open");
-	(new LLObjectBuild())->registerListener(gMenuHolder, "Object.Build");
-	(new LLObjectTouch())->registerListener(gMenuHolder, "Object.Touch");
-	(new LLObjectSitOrStand())->registerListener(gMenuHolder, "Object.SitOrStand");
-	(new LLObjectDelete())->registerListener(gMenuHolder, "Object.Delete");
-	(new LLObjectAttachToAvatar())->registerListener(gMenuHolder, "Object.AttachToAvatar");
-	(new LLObjectReturn())->registerListener(gMenuHolder, "Object.Return");
-	(new LLObjectReportAbuse())->registerListener(gMenuHolder, "Object.ReportAbuse");
-	(new LLObjectMute())->registerListener(gMenuHolder, "Object.Mute");
-	(new LLObjectBuy())->registerListener(gMenuHolder, "Object.Buy");
-	(new LLObjectEdit())->registerListener(gMenuHolder, "Object.Edit");
-	(new LLObjectInspect())->registerListener(gMenuHolder, "Object.Inspect");
-
-	(new LLObjectEnableOpen())->registerListener(gMenuHolder, "Object.EnableOpen");
-	(new LLObjectEnableTouch())->registerListener(gMenuHolder, "Object.EnableTouch");
-	(new LLObjectEnableSitOrStand())->registerListener(gMenuHolder, "Object.EnableSitOrStand");
-	(new LLObjectEnableDelete())->registerListener(gMenuHolder, "Object.EnableDelete");
-	(new LLObjectEnableWear())->registerListener(gMenuHolder, "Object.EnableWear");
-	(new LLObjectEnableReturn())->registerListener(gMenuHolder, "Object.EnableReturn");
-	(new LLObjectEnableReportAbuse())->registerListener(gMenuHolder, "Object.EnableReportAbuse");
-	(new LLObjectEnableMute())->registerListener(gMenuHolder, "Object.EnableMute");
-	(new LLObjectEnableBuy())->registerListener(gMenuHolder, "Object.EnableBuy");
-
-	/*(new LLObjectVisibleTouch())->registerListener(gMenuHolder, "Object.VisibleTouch");
-	(new LLObjectVisibleCustomTouch())->registerListener(gMenuHolder, "Object.VisibleCustomTouch");
-	(new LLObjectVisibleStandUp())->registerListener(gMenuHolder, "Object.VisibleStandUp");
-	(new LLObjectVisibleSitHere())->registerListener(gMenuHolder, "Object.VisibleSitHere");
-	(new LLObjectVisibleCustomSit())->registerListener(gMenuHolder, "Object.VisibleCustomSit");*/
+	addMenu(new LLObjectOpen(), "Object.Open");
+	addMenu(new LLObjectBuild(), "Object.Build");
+	addMenu(new LLObjectTouch(), "Object.Touch");
+	addMenu(new LLObjectSitOrStand(), "Object.SitOrStand");
+	addMenu(new LLObjectDelete(), "Object.Delete");
+	addMenu(new LLObjectAttachToAvatar(), "Object.AttachToAvatar");
+	addMenu(new LLObjectReturn(), "Object.Return");
+	addMenu(new LLObjectReportAbuse(), "Object.ReportAbuse");
+	addMenu(new LLObjectMute(), "Object.Mute");
+	addMenu(new LLObjectBuy(), "Object.Buy");
+	addMenu(new LLObjectEdit(), "Object.Edit");
+	addMenu(new LLObjectInspect(), "Object.Inspect");
+
+	addMenu(new LLObjectEnableOpen(), "Object.EnableOpen");
+	addMenu(new LLObjectEnableTouch(), "Object.EnableTouch");
+	addMenu(new LLObjectEnableSitOrStand(), "Object.EnableSitOrStand");
+	addMenu(new LLObjectEnableDelete(), "Object.EnableDelete");
+	addMenu(new LLObjectEnableWear(), "Object.EnableWear");
+	addMenu(new LLObjectEnableReturn(), "Object.EnableReturn");
+	addMenu(new LLObjectEnableReportAbuse(), "Object.EnableReportAbuse");
+	addMenu(new LLObjectEnableMute(), "Object.EnableMute");
+	addMenu(new LLObjectEnableBuy(), "Object.EnableBuy");
+
+	/*addMenu(new LLObjectVisibleTouch(), "Object.VisibleTouch");
+	addMenu(new LLObjectVisibleCustomTouch(), "Object.VisibleCustomTouch");
+	addMenu(new LLObjectVisibleStandUp(), "Object.VisibleStandUp");
+	addMenu(new LLObjectVisibleSitHere(), "Object.VisibleSitHere");
+	addMenu(new LLObjectVisibleCustomSit(), "Object.VisibleCustomSit");*/
 
 	// Attachment pie menu
-	(new LLAttachmentDrop())->registerListener(gMenuHolder, "Attachment.Drop");
-	(new LLAttachmentDetach())->registerListener(gMenuHolder, "Attachment.Detach");
+	addMenu(new LLAttachmentDrop(), "Attachment.Drop");
+	addMenu(new LLAttachmentDetach(), "Attachment.Detach");
 
-	(new LLAttachmentEnableDrop())->registerListener(gMenuHolder, "Attachment.EnableDrop");
-	(new LLAttachmentEnableDetach())->registerListener(gMenuHolder, "Attachment.EnableDetach");
+	addMenu(new LLAttachmentEnableDrop(), "Attachment.EnableDrop");
+	addMenu(new LLAttachmentEnableDetach(), "Attachment.EnableDetach");
 
 	// Land pie menu
-	(new LLLandBuild())->registerListener(gMenuHolder, "Land.Build");
-	(new LLLandSit())->registerListener(gMenuHolder, "Land.Sit");
-	(new LLLandBuyPass())->registerListener(gMenuHolder, "Land.BuyPass");
-	(new LLLandEdit())->registerListener(gMenuHolder, "Land.Edit");
+	addMenu(new LLLandBuild(), "Land.Build");
+	addMenu(new LLLandSit(), "Land.Sit");
+	addMenu(new LLLandBuyPass(), "Land.BuyPass");
+	addMenu(new LLLandEdit(), "Land.Edit");
 
-	(new LLLandEnableBuyPass())->registerListener(gMenuHolder, "Land.EnableBuyPass");
+	addMenu(new LLLandEnableBuyPass(), "Land.EnableBuyPass");
 
 	// Generic actions
-	(new LLShowFloater())->registerListener(gMenuHolder, "ShowFloater");
-	(new LLPromptShowURL())->registerListener(gMenuHolder, "PromptShowURL");
-	(new LLPromptShowFile())->registerListener(gMenuHolder, "PromptShowFile");
-	(new LLShowAgentProfile())->registerListener(gMenuHolder, "ShowAgentProfile");
-	(new LLShowAgentGroups())->registerListener(gMenuHolder, "ShowAgentGroups");
-	(new LLToggleControl())->registerListener(gMenuHolder, "ToggleControl");
-
-	(new LLGoToObject())->registerListener(gMenuHolder, "GoToObject");
-	(new LLPayObject())->registerListener(gMenuHolder, "PayObject");
-
-	(new LLEnablePayObject())->registerListener(gMenuHolder, "EnablePayObject");
-	(new LLEnableEdit())->registerListener(gMenuHolder, "EnableEdit");
-
-	(new LLFloaterVisible())->registerListener(gMenuHolder, "FloaterVisible");
-	(new LLSomethingSelected())->registerListener(gMenuHolder, "SomethingSelected");
-	(new LLSomethingSelectedNoHUD())->registerListener(gMenuHolder, "SomethingSelectedNoHUD");
-	(new LLEditableSelected())->registerListener(gMenuHolder, "EditableSelected");
+	addMenu(new LLShowFloater(), "ShowFloater");
+	addMenu(new LLPromptShowURL(), "PromptShowURL");
+	addMenu(new LLPromptShowFile(), "PromptShowFile");
+	addMenu(new LLShowAgentProfile(), "ShowAgentProfile");
+	addMenu(new LLShowAgentGroups(), "ShowAgentGroups");
+	addMenu(new LLToggleControl(), "ToggleControl");
+
+	addMenu(new LLGoToObject(), "GoToObject");
+	addMenu(new LLPayObject(), "PayObject");
+
+	addMenu(new LLEnablePayObject(), "EnablePayObject");
+	addMenu(new LLEnableEdit(), "EnableEdit");
+
+	addMenu(new LLFloaterVisible(), "FloaterVisible");
+	addMenu(new LLSomethingSelected(), "SomethingSelected");
+	addMenu(new LLSomethingSelectedNoHUD(), "SomethingSelectedNoHUD");
+	addMenu(new LLEditableSelected(), "EditableSelected");
 }
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 18f5e541545..9bcf1ccaee7 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -767,8 +767,8 @@ void open_offer(const std::vector<LLUUID>& items, const std::string& from_name)
 		if (check_offer_throttle(from_name, false))
 		{
 			// I'm not sure this is a good idea.  JC
-			// bool show_keep_discard = item->getPermissions().getCreator() != gAgent.getID();
-			bool show_keep_discard = true;
+			bool show_keep_discard = item->getPermissions().getCreator() != gAgent.getID();
+			//bool show_keep_discard = true;
 			switch(item->getType())
 			{
 			case LLAssetType::AT_NOTECARD:
@@ -2197,7 +2197,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
 		if (chat.mSourceType == CHAT_SOURCE_OBJECT 
 			&& chat.mChatType != CHAT_TYPE_DEBUG_MSG)
 		{
-			LLViewerPartSourceChat *psc = new LLViewerPartSourceChat(chatter->getPositionAgent());
+			LLPointer<LLViewerPartSourceChat> psc = new LLViewerPartSourceChat(chatter->getPositionAgent());
 			psc->setSourceObject(chatter);
 			psc->setColor(color);
 			//We set the particles to be owned by the object's owner, 
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index e15f5da5379..710ba186f94 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -4000,7 +4000,7 @@ void LLViewerObject::unpackParticleSource(const S32 block_num, const LLUUID& own
 	}
 	else
 	{
-		LLViewerPartSourceScript *pss = LLViewerPartSourceScript::unpackPSS(this, NULL, block_num);
+		LLPointer<LLViewerPartSourceScript> pss = LLViewerPartSourceScript::unpackPSS(this, NULL, block_num);
 		//If the owner is muted, don't create the system
 		if(gMuteListp->isMuted(owner_id)) return;
 
@@ -4049,7 +4049,7 @@ void LLViewerObject::unpackParticleSource(LLDataPacker &dp, const LLUUID& owner_
 	}
 	else
 	{
-		LLViewerPartSourceScript *pss = LLViewerPartSourceScript::unpackPSS(this, NULL, dp);
+		LLPointer<LLViewerPartSourceScript> pss = LLViewerPartSourceScript::unpackPSS(this, NULL, dp);
 		//If the owner is muted, don't create the system
 		if(gMuteListp->isMuted(owner_id)) return;
 		// We need to be able to deal with a particle source that hasn't changed, but still got an update!
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 3e885233fd5..f6aaadd40bf 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -96,7 +96,7 @@ struct LLMaterialExportInfo
 class LLViewerObject : public LLPrimitive, public LLRefCount
 {
 protected:
-	virtual ~LLViewerObject(); // use unref()
+	~LLViewerObject(); // use unref()
 
 	// TomY: Provide for a list of extra parameter structures, mapped by structure name
 	struct ExtraParameter
diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp
index 5af3d532a69..556e0bc79b7 100644
--- a/indra/newview/llviewerparcelmgr.cpp
+++ b/indra/newview/llviewerparcelmgr.cpp
@@ -2557,8 +2557,21 @@ bool LLParcelSelection::hasOthersSelected() const
 	return mSelectedOtherCount != 0;
 }
 
+static LLPointer<LLParcelSelection> sNullSelection;
+
 LLParcelSelection* get_null_parcel_selection()
 {
-	static LLParcelSelection null_selection;
-	return &null_selection;
+	if (sNullSelection.isNull())
+	{
+		sNullSelection = new LLParcelSelection;
+	}
+	
+	return sNullSelection;
+}
+
+void LLViewerParcelMgr::cleanupGlobals()
+{
+	delete gParcelMgr;
+	gParcelMgr = NULL;
+	sNullSelection = NULL;
 }
diff --git a/indra/newview/llviewerparcelmgr.h b/indra/newview/llviewerparcelmgr.h
index 879ce2dd8a7..20c6b6895dd 100644
--- a/indra/newview/llviewerparcelmgr.h
+++ b/indra/newview/llviewerparcelmgr.h
@@ -53,12 +53,13 @@ class LLParcelSelection : public LLRefCount
 {
 	friend class LLViewerParcelMgr;
 
+protected:
+	~LLParcelSelection();
+
 public:
 	LLParcelSelection(LLParcel* parcel);
 	LLParcelSelection();
 
-	~LLParcelSelection();
-
 	// this can return NULL at any time, as parcel selection
 	// might have been invalidated.
 	LLParcel* getParcel() { return mParcel; }
@@ -99,6 +100,8 @@ class LLViewerParcelMgr
 	LLViewerParcelMgr();
 	~LLViewerParcelMgr();
 
+	static void cleanupGlobals();
+
 	BOOL	selectionEmpty() const;
 	F32		getSelectionWidth() const	{ return F32(mEastNorth.mdV[VX] - mWestSouth.mdV[VX]); }
 	F32		getSelectionHeight() const	{ return F32(mEastNorth.mdV[VY] - mWestSouth.mdV[VY]); }
diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp
index 6d4e8bfeffd..9b7e44a523a 100644
--- a/indra/newview/llviewerpartsim.cpp
+++ b/indra/newview/llviewerpartsim.cpp
@@ -83,7 +83,7 @@ LLViewerPart &LLViewerPart::operator=(const LLViewerPart &part)
 	return *this;
 }
 
-void LLViewerPart::init(LLViewerPartSource *sourcep, LLViewerImage *imagep, LLVPCallback cb)
+void LLViewerPart::init(LLPointer<LLViewerPartSource> sourcep, LLViewerImage *imagep, LLVPCallback cb)
 {
 	LLMemType mt(LLMemType::MTYPE_PARTICLES);
 	mPartID = LLViewerPart::sNextPartID;
@@ -653,7 +653,7 @@ void LLViewerPartSim::updateSimulation()
 }
 
 
-void LLViewerPartSim::addPartSource(LLViewerPartSource *sourcep)
+void LLViewerPartSim::addPartSource(LLPointer<LLViewerPartSource> sourcep)
 {
 	LLMemType mt(LLMemType::MTYPE_PARTICLES);
 	if (!sourcep)
diff --git a/indra/newview/llviewerpartsim.h b/indra/newview/llviewerpartsim.h
index b0b9500ac61..afde3049f7f 100644
--- a/indra/newview/llviewerpartsim.h
+++ b/indra/newview/llviewerpartsim.h
@@ -33,12 +33,13 @@ typedef void (*LLVPCallback)(LLViewerPart &part, const F32 dt);
 
 class LLViewerPart : public LLPartData, public LLRefCount
 {
+protected:
+	~LLViewerPart();
 public:
 	LLViewerPart();
-	~LLViewerPart();
 
 	LLViewerPart &operator=(const LLViewerPart &part);
-	void init(LLViewerPartSource *sourcep, LLViewerImage *imagep, LLVPCallback cb);
+	void init(LLPointer<LLViewerPartSource> sourcep, LLViewerImage *imagep, LLVPCallback cb);
 
 
 	U32					mPartID;					// Particle ID used primarily for moving between groups
@@ -113,7 +114,7 @@ class LLViewerPartSim
 
 	void updateSimulation();
 
-	void addPartSource(LLViewerPartSource *sourcep);
+	void addPartSource(LLPointer<LLViewerPartSource> sourcep);
 
 	void cleanupRegion(LLViewerRegion *regionp);
 
diff --git a/indra/newview/llviewerpartsource.cpp b/indra/newview/llviewerpartsource.cpp
index 6a92ba50873..01c835dbf09 100644
--- a/indra/newview/llviewerpartsource.cpp
+++ b/indra/newview/llviewerpartsource.cpp
@@ -290,7 +290,7 @@ void LLViewerPartSourceScript::update(const F32 dt)
 }
 
 // static
-LLViewerPartSourceScript *LLViewerPartSourceScript::unpackPSS(LLViewerObject *source_objp, LLViewerPartSourceScript *pssp, const S32 block_num)
+LLPointer<LLViewerPartSourceScript> LLViewerPartSourceScript::unpackPSS(LLViewerObject *source_objp, LLPointer<LLViewerPartSourceScript> pssp, const S32 block_num)
 {
 	LLMemType mt(LLMemType::MTYPE_PARTICLES);
 	if (!pssp)
@@ -299,10 +299,9 @@ LLViewerPartSourceScript *LLViewerPartSourceScript::unpackPSS(LLViewerObject *so
 		{
 			return NULL;
 		}
-		LLViewerPartSourceScript *new_pssp = new LLViewerPartSourceScript(source_objp);
+		LLPointer<LLViewerPartSourceScript> new_pssp = new LLViewerPartSourceScript(source_objp);
 		if (!new_pssp->mPartSysData.unpackBlock(block_num))
 		{
-			delete new_pssp;
 			return NULL;
 		}
 		if (new_pssp->mPartSysData.mTargetUUID.notNull())
@@ -333,15 +332,14 @@ LLViewerPartSourceScript *LLViewerPartSourceScript::unpackPSS(LLViewerObject *so
 }
 
 
-LLViewerPartSourceScript *LLViewerPartSourceScript::unpackPSS(LLViewerObject *source_objp, LLViewerPartSourceScript *pssp, LLDataPacker &dp)
+LLPointer<LLViewerPartSourceScript> LLViewerPartSourceScript::unpackPSS(LLViewerObject *source_objp, LLPointer<LLViewerPartSourceScript> pssp, LLDataPacker &dp)
 {
 	LLMemType mt(LLMemType::MTYPE_PARTICLES);
 	if (!pssp)
 	{
-		LLViewerPartSourceScript *new_pssp = new LLViewerPartSourceScript(source_objp);
+		LLPointer<LLViewerPartSourceScript> new_pssp = new LLViewerPartSourceScript(source_objp);
 		if (!new_pssp->mPartSysData.unpack(dp))
 		{
-			delete new_pssp;
 			return NULL;
 		}
 		if (new_pssp->mPartSysData.mTargetUUID.notNull())
@@ -402,8 +400,8 @@ void LLViewerPartSourceSpiral::updatePart(LLViewerPart &part, const F32 dt)
 	F32 frac = part.mLastUpdateTime/part.mMaxAge;
 
 	LLVector3 center_pos;
-	LLViewerPartSource *ps = (LLViewerPartSource*)part.mPartSourcep;
-	LLViewerPartSourceSpiral *pss = (LLViewerPartSourceSpiral *)ps;
+	LLPointer<LLViewerPartSource>& ps = part.mPartSourcep;
+	LLViewerPartSourceSpiral *pss = (LLViewerPartSourceSpiral *)ps.get();
 	if (!pss->mSourceObjectp.isNull() && !pss->mSourceObjectp->mDrawable.isNull())
 	{
 		part.mPosAgent = pss->mSourceObjectp->getRenderPosition();
diff --git a/indra/newview/llviewerpartsource.h b/indra/newview/llviewerpartsource.h
index 4bd577b7a54..30ea00809a2 100644
--- a/indra/newview/llviewerpartsource.h
+++ b/indra/newview/llviewerpartsource.h
@@ -87,8 +87,8 @@ class LLViewerPartSourceScript : public LLViewerPartSource
 	BOOL updateFromMesg();
 
 	// Returns a new particle source to attach to an object...
-	static LLViewerPartSourceScript *unpackPSS(LLViewerObject *source_objp, LLViewerPartSourceScript *pssp, const S32 block_num);
-	static LLViewerPartSourceScript *unpackPSS(LLViewerObject *source_objp, LLViewerPartSourceScript *pssp, LLDataPacker &dp);
+	static LLPointer<LLViewerPartSourceScript> unpackPSS(LLViewerObject *source_objp, LLPointer<LLViewerPartSourceScript> pssp, const S32 block_num);
+	static LLPointer<LLViewerPartSourceScript> unpackPSS(LLViewerObject *source_objp, LLPointer<LLViewerPartSourceScript> pssp, LLDataPacker &dp);
 
 	LLViewerImage *getImage() const				{ return mImagep; }
 	void setImage(LLViewerImage *imagep);
@@ -137,7 +137,6 @@ class LLViewerPartSourceBeam : public LLViewerPartSource
 {
 public:
 	LLViewerPartSourceBeam();
-	~LLViewerPartSourceBeam();
 
 	/*virtual*/ void setDead();
 
@@ -155,6 +154,7 @@ class LLViewerPartSourceBeam : public LLViewerPartSource
 	LLVector3d		mLKGTargetPosGlobal;
 	LLColor4 mColor;
 protected:
+	~LLViewerPartSourceBeam();
 };
 
 
diff --git a/indra/newview/llvoclouds.h b/indra/newview/llvoclouds.h
index 180e4703b95..5f5301db20e 100644
--- a/indra/newview/llvoclouds.h
+++ b/indra/newview/llvoclouds.h
@@ -23,7 +23,6 @@ class LLVOClouds : public LLAlphaObject
 {
 public:
 	LLVOClouds(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp );
-	virtual ~LLVOClouds();
 
 	// Initialize data that's only inited once per class.
 	static void initClass();
@@ -53,6 +52,8 @@ class LLVOClouds : public LLAlphaObject
 
 	void setCloudGroup(LLCloudGroup *cgp)		{ mCloudGroupp = cgp; }
 protected:
+	virtual ~LLVOClouds();
+
 	LLCloudGroup *mCloudGroupp;
 };
 
diff --git a/indra/newview/llvograss.h b/indra/newview/llvograss.h
index 38aef64cd8f..b1839c05880 100644
--- a/indra/newview/llvograss.h
+++ b/indra/newview/llvograss.h
@@ -21,7 +21,6 @@ class LLVOGrass : public LLAlphaObject
 {
 public:
 	LLVOGrass(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
-	virtual ~LLVOGrass();
 
 	// Initialize data that's only inited once per class.
 	static void initClass();
@@ -84,6 +83,9 @@ class LLVOGrass : public LLAlphaObject
 	F32				          mBladeWindAngle;
 	F32				          mBWAOverlap;
 
+protected:
+	~LLVOGrass();
+
 private:
 	void updateSpecies();
 	F32 mLastHeight;		// For cheap update hack
diff --git a/indra/newview/llvoground.h b/indra/newview/llvoground.h
index 587b0064de7..9bf5be70579 100644
--- a/indra/newview/llvoground.h
+++ b/indra/newview/llvoground.h
@@ -18,9 +18,10 @@
 class LLVOGround : public LLStaticViewerObject
 {
 protected:
+	~LLVOGround();
+
 public:
 	LLVOGround(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
-	virtual ~LLVOGround();
 
 	/*virtual*/ BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
 	
diff --git a/indra/newview/llvopartgroup.h b/indra/newview/llvopartgroup.h
index 40827009714..df1631cbc78 100644
--- a/indra/newview/llvopartgroup.h
+++ b/indra/newview/llvopartgroup.h
@@ -30,8 +30,6 @@ class LLVOPartGroup : public LLAlphaObject
 
 	LLVOPartGroup(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
 
-	~LLVOPartGroup();
-
 	/*virtual*/ BOOL    isActive() const; // Whether this object needs to do an idleUpdate.
 	BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
 	BOOL isParticle();
@@ -58,6 +56,8 @@ class LLVOPartGroup : public LLAlphaObject
 	LLViewerPartGroup* getViewerPartGroup()	{ return mViewerPartGroupp; }
 
 protected:
+	~LLVOPartGroup();
+
 	LLViewerPartGroup *mViewerPartGroupp;
 	LLVector3 mExtents[2];
 	LLColor4 mDebugColor;
diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp
index 9da6027ab56..aa4c6f00862 100644
--- a/indra/newview/llvosky.cpp
+++ b/indra/newview/llvosky.cpp
@@ -518,8 +518,6 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
 	mSun.setIntensity(SUN_INTENSITY);
 	mMoon.setIntensity(0.1f * SUN_INTENSITY);
 
-	mCubeMap = NULL;
-
 	mSunTexturep = gImageList.getImage(gSunTextureID, TRUE, TRUE);
 	mSunTexturep->setClamp(TRUE, TRUE);
 	mMoonTexturep = gImageList.getImage(gMoonTextureID, TRUE, TRUE);
@@ -534,7 +532,6 @@ LLVOSky::~LLVOSky()
 	// Don't delete images - it'll get deleted by gImageList on shutdown
 	// This needs to be done for each texture
 
-	delete mCubeMap;
 	mCubeMap = NULL;
 }
 
@@ -576,7 +573,7 @@ void LLVOSky::initCubeMap()
 	{
 		images.push_back(mSkyTex[side].getImageRaw());
 	}
-	if (mCubeMap != NULL)
+	if (mCubeMap)
 	{
 		mCubeMap->init(images);
 	}
diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h
index 5697e721ff1..836cd7add71 100644
--- a/indra/newview/llvosky.h
+++ b/indra/newview/llvosky.h
@@ -504,7 +504,6 @@ class LLVOSky : public LLStaticViewerObject
 	};
 	
 	LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
-	virtual ~LLVOSky();
 
 	// Initialize/delete data that's only inited once per class.
 	static void initClass();
@@ -667,6 +666,8 @@ class LLVOSky : public LLStaticViewerObject
 	LLFace				*mFace[FACE_COUNT];
 
 protected:
+	~LLVOSky();
+
 	LLPointer<LLViewerImage> mSunTexturep;
 	LLPointer<LLViewerImage> mMoonTexturep;
 	LLPointer<LLViewerImage> mBloomTexturep;
@@ -716,7 +717,7 @@ class LLVOSky : public LLStaticViewerObject
 	LLColor3			mMoonDiffuse;
 	LLColor4U			mFadeColor;					// Color to fade in from	
 
-	LLCubeMap			*mCubeMap;					// Cube map for the environment
+	LLPointer<LLCubeMap>	mCubeMap;					// Cube map for the environment
 	S32					mDrawRefl;
 
 	LLFrameTimer		mUpdateTimer;
diff --git a/indra/newview/llvosurfacepatch.h b/indra/newview/llvosurfacepatch.h
index fd2eff710bb..af6653e556d 100644
--- a/indra/newview/llvosurfacepatch.h
+++ b/indra/newview/llvosurfacepatch.h
@@ -30,7 +30,6 @@ class LLVOSurfacePatch : public LLStaticViewerObject
 	eVertexDataMask;
 
 	LLVOSurfacePatch(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
-	virtual ~LLVOSurfacePatch();
 
 	/*virtual*/ void markDead();
 
@@ -64,6 +63,8 @@ class LLVOSurfacePatch : public LLStaticViewerObject
 
 	BOOL			mDirtiedPatch;
 protected:
+	~LLVOSurfacePatch();
+
 	LLFacePool		*mPool;
 	LLFacePool		*getPool();
 	S32				mBaseComp;
diff --git a/indra/newview/llvotextbubble.h b/indra/newview/llvotextbubble.h
index a348a53c7c0..bba51babd3c 100644
--- a/indra/newview/llvotextbubble.h
+++ b/indra/newview/llvotextbubble.h
@@ -16,7 +16,6 @@ class LLVOTextBubble : public LLAlphaObject
 {
 public:
 	LLVOTextBubble(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
-	virtual ~LLVOTextBubble();
 
 	/*virtual*/ BOOL    isActive() const; // Whether this object needs to do an idleUpdate.
 	/*virtual*/ BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
@@ -39,7 +38,9 @@ class LLVOTextBubble : public LLAlphaObject
 	LLColor4 mColor;
 	S32 mLOD;
 	BOOL mVolumeChanged;
+
 protected:
+	~LLVOTextBubble();
 	BOOL setVolume(const LLVolumeParams &volume_params);
 	LLFrameTimer mUpdateTimer;
 };
diff --git a/indra/newview/llvotree.h b/indra/newview/llvotree.h
index 487dd706df1..e10abbfb278 100644
--- a/indra/newview/llvotree.h
+++ b/indra/newview/llvotree.h
@@ -19,6 +19,9 @@ class LLDrawPool;
 
 class LLVOTree : public LLViewerObject
 {
+protected:
+	~LLVOTree();
+
 public:
 	enum 
 	{
@@ -29,7 +32,6 @@ class LLVOTree : public LLViewerObject
 	eVertexDataMask;
 
 	LLVOTree(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
-	virtual ~LLVOTree();
 
 	// Initialize data that's only inited once per class.
 	static void initClass();
diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h
index bde9058f4c4..6ee6d255c49 100644
--- a/indra/newview/llvovolume.h
+++ b/indra/newview/llvovolume.h
@@ -49,6 +49,9 @@ class LLVolumeInterface
 // Class which embodies all Volume objects (with pcode LL_PCODE_VOLUME)
 class LLVOVolume : public LLViewerObject
 {
+protected:
+	virtual				~LLVOVolume();
+
 public:
 	static		void	initClass();
 	static 		void 	preUpdateGeom();
@@ -65,7 +68,6 @@ class LLVOVolume : public LLViewerObject
 
 public:
 						LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
-	virtual				~LLVOVolume();
 
 	/*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline);
 
diff --git a/indra/newview/llvowater.h b/indra/newview/llvowater.h
index 74a5e81d8c9..fd140fda564 100644
--- a/indra/newview/llvowater.h
+++ b/indra/newview/llvowater.h
@@ -36,7 +36,6 @@ class LLVOWater : public LLStaticViewerObject
 	eVertexDataMask;
 
 	LLVOWater(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
-	virtual ~LLVOWater() {}
 
 	/*virtual*/ void markDead();
 
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index bb0efb48e11..c3841a47907 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -154,7 +154,6 @@ BOOL	LLPipeline::sRenderGlow = FALSE;
 
 LLPipeline::LLPipeline() :
 	mScreenTex(0),
-	mCubeBuffer(NULL),
 	mGlowMap(0),
 	mGlowBuffer(0),
 	mVertexShadersEnabled(FALSE),
@@ -352,7 +351,6 @@ void LLPipeline::releaseGLBuffers()
 
 	if (mCubeBuffer)
 	{
-		delete mCubeBuffer;
 		mCubeBuffer = NULL;
 	}
 
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index f20731c7498..390e1395036 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -343,7 +343,7 @@ class LLPipeline
 	GLuint					mFramebuffer[2];
 
 	//dynamic cube map scratch space
-	LLCubeMap*				mCubeBuffer;
+	LLPointer<LLCubeMap>	mCubeBuffer;
 
 	//frambuffer object for rendering dynamic cube maps
 	GLuint					mCubeFrameBuffer;
diff --git a/indra/newview/secondlife-i686.supp b/indra/newview/secondlife-i686.supp
new file mode 100644
index 00000000000..b1b30a441f4
--- /dev/null
+++ b/indra/newview/secondlife-i686.supp
@@ -0,0 +1,175 @@
+# @file secondlife-i686.supp
+# @brief Valgrind suppressions for Linux i686 viewer.
+#
+# Copyright (c) 2000-$CurrentYear$, Linden Research, Inc.
+# $License$
+#
+# This is a Valgrind suppression file for use on the viewer.
+#
+# Hints for most successful use of valgrind:
+#
+# - If your distro comes with library packages that contain debug info
+#   (Fedora calls these debuginfo packages), install them.
+# - Inside the SConstruct script, disable linking against tcmalloc.
+#   Valgrind and tcmalloc don't get along.
+# - Delete the copy of libstdc++.so.6 that is bundled with the viewer
+#   (if you have one), so that the viewer will use the system's
+#   libstdc++.
+# - After you build the viewer, replace the stripped
+#   do-not-directly-run-secondlife-bin binary with an unstripped copy.
+
+# Mozilla noise.
+
+{
+   Cond:mozilla-runtime/*.so
+   Memcheck:Cond
+   obj:*/mozilla-runtime-*/*.so
+}
+
+{
+   Value4:mozilla-runtime/*.so
+   Memcheck:Value4
+   obj:*/mozilla-runtime-*/*.so
+}
+
+{
+   Cond:mozilla-runtime/*/*.so
+   Memcheck:Cond
+   obj:*/mozilla-runtime-*/*/*.so
+}
+
+{
+   Value4:mozilla-runtime/*/*.so
+   Memcheck:Value4
+   obj:*/mozilla-runtime-*/*/*.so
+}
+
+{
+   Cond:mozilla-runtime/libmozjs.so
+   Memcheck:Cond
+   obj:*/libmozjs.so
+}
+
+{
+   Cond:mozilla-runtime/libxul
+   Memcheck:Cond
+   obj:*/libxul.so
+}
+
+{
+   Value4:mozilla-runtime/libxul
+   Memcheck:Value4
+   obj:*/libxul.so
+}
+
+# libcurl badness.
+
+{
+   Cond:libcurl/inflate/Curl_unencode_gzip_write
+   Memcheck:Cond
+   fun:inflate
+   fun:inflate_stream
+   fun:Curl_unencode_gzip_write
+}
+{
+   Cond:libcurl/ares_mkquery/Curl_getaddrinfo
+   Memcheck:Cond
+   fun:ares_mkquery
+   fun:ares_query
+   fun:ares_search
+   fun:next_lookup
+   fun:Curl_getaddrinfo
+}
+
+# libdl business.
+
+{
+   Cond:libdl/_dl_relocate_object
+   Memcheck:Cond
+   fun:_dl_relocate_object
+}
+
+# X11 fun.
+
+{
+   Param:X11/_X11TransSocketWritev/writev/vector
+   Memcheck:Param
+   writev(vector[...])
+   fun:writev
+   fun:_X11TransSocketWritev
+}
+
+{
+   Param:X11/_X11TransWrite/write/buf
+   Memcheck:Param
+   write(buf)
+   obj:/lib/libc-2.6.so
+   fun:_X11TransWrite
+}
+
+# OpenSSL stuff.
+
+{
+   Value4:libcrypto
+   Memcheck:Value4
+   obj:*/libcrypto.so.0.9*
+}
+
+{
+   Cond:libcrypto
+   Memcheck:Cond
+   obj:*/libcrypto.so.0.9*
+}
+
+{
+   Value4:libssl
+   Memcheck:Value4
+   obj:*/libssl.so.0.9*
+}
+
+{
+   Cond:libcrypto
+   Memcheck:Cond
+   obj:*/libssl.so.0.9*
+}
+
+# NVIDIA driver brokenness.
+
+{
+   Addr4:NVIDIA/libGL
+   Memcheck:Addr4
+   obj:/usr/lib/libGL.so.1.0.*
+}
+
+{
+   Value4:NVIDIA/libGL
+   Memcheck:Value4
+   obj:/usr/lib/libGL.so.1.0.*
+}
+
+{
+   Cond:NVIDIA/libGL
+   Memcheck:Cond
+   obj:/usr/lib/libGL.so.1.0.*
+}
+
+{
+   Value4:NVIDIA/libGLcore
+   Memcheck:Value4
+   obj:/usr/lib/libGLcore.so.1.0.*
+}
+
+{
+   Cond:NVIDIA/libGLcore
+   Memcheck:Cond
+   obj:/usr/lib/libGLcore.so.1.0.*
+}
+
+{
+   Param:NVIDIA/ioctl
+   Memcheck:Param
+   ioctl(generic)
+   fun:ioctl
+   fun:_nv000130gl
+}
+
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index c03ec750815..c714ad627df 100755
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -391,6 +391,7 @@ def construct(self):
                         self.end_prefix("res-sdl")
 
                 self.path("featuretable_linux.txt")
+                self.path("secondlife-i686.supp")
 
                 self.path("app_settings/mozilla-runtime-linux-i686")
 
-- 
GitLab