From 28435a08988022f5dd1d0e931b6ad048b8950e11 Mon Sep 17 00:00:00 2001
From: Josh Bell <josh@lindenlab.com>
Date: Mon, 11 Jun 2007 18:24:15 +0000
Subject: [PATCH] NOTE: Partial merges of the maintenance branch up. The bulk
 of maintenance 62831:63347 is awaiting final QA and merging, post 1.17.0

svn merge -r 63182:63183 svn+ssh://svn.lindenlab.com/svn/linden/branches/maintenance --> release
svn merge -r 63341:63342 svn+ssh://svn.lindenlab.com/svn/linden/branches/maintenance --> release
svn merge -r 63420:63421 svn+ssh://svn.lindenlab.com/svn/linden/branches/maintenance --> release

Rush in the following fixes:

* SL-27250 "Stop All Animations" doesn't work when stuck in a pose after teleporting
* SL-44718 VWR-1040: crash when opening several gestures quickly
* SL-44326 recurring error message in agni nightly #1
---
 indra/llcharacter/llcharacter.cpp        |  9 +++++++++
 indra/llcharacter/llcharacter.h          |  3 +++
 indra/llcharacter/llmotioncontroller.cpp | 17 +++++++++++++++++
 indra/llcharacter/llmotioncontroller.h   |  3 +++
 indra/newview/llpreview.cpp              | 14 +++++++-------
 indra/newview/llpreview.h                |  6 +++---
 indra/newview/llpreviewanim.cpp          | 10 +++++-----
 indra/newview/llpreviewgesture.cpp       |  6 +++---
 indra/newview/llpreviewnotecard.cpp      | 12 ++++++------
 indra/newview/llpreviewnotecard.h        |  2 +-
 indra/newview/llpreviewscript.cpp        | 10 +++++-----
 indra/newview/llpreviewsound.cpp         |  6 +++---
 indra/newview/llpreviewtexture.cpp       |  4 ++--
 indra/newview/llviewermenu.cpp           |  6 +-----
 14 files changed, 68 insertions(+), 40 deletions(-)

diff --git a/indra/llcharacter/llcharacter.cpp b/indra/llcharacter/llcharacter.cpp
index 583f01cf913..c6ed3e6b5d3 100644
--- a/indra/llcharacter/llcharacter.cpp
+++ b/indra/llcharacter/llcharacter.cpp
@@ -169,6 +169,15 @@ void LLCharacter::updateMotion(BOOL force_update)
 }
 
 
+//-----------------------------------------------------------------------------
+// deactivateAllMotions()
+//-----------------------------------------------------------------------------
+void LLCharacter::deactivateAllMotions()
+{
+	mMotionController.deactivateAllMotions();
+}
+
+
 //-----------------------------------------------------------------------------
 // flushAllMotions()
 //-----------------------------------------------------------------------------
diff --git a/indra/llcharacter/llcharacter.h b/indra/llcharacter/llcharacter.h
index 44fb6d08338..8f720d3b841 100644
--- a/indra/llcharacter/llcharacter.h
+++ b/indra/llcharacter/llcharacter.h
@@ -150,6 +150,9 @@ class LLCharacter
 	// no cached references to character joint data.  This is 
 	// useful if a character wants to rebuild it's skeleton.
 	virtual void flushAllMotions();
+	
+	// Flush only wipes active animations. 
+	virtual void deactivateAllMotions();
 
 	// dumps information for debugging
 	virtual void dumpCharacter( LLJoint *joint = NULL );
diff --git a/indra/llcharacter/llmotioncontroller.cpp b/indra/llcharacter/llmotioncontroller.cpp
index 71bbdfb9327..fad69fc6e9d 100644
--- a/indra/llcharacter/llmotioncontroller.cpp
+++ b/indra/llcharacter/llmotioncontroller.cpp
@@ -835,6 +835,23 @@ LLMotion *LLMotionController::findMotion(const LLUUID& id)
 	return mAllMotions[id];
 }
 
+//-----------------------------------------------------------------------------
+// deactivateAllMotions()
+//-----------------------------------------------------------------------------
+void LLMotionController::deactivateAllMotions()
+{
+	//They must all die, precious.
+	for (std::map<LLUUID, LLMotion*>::iterator iter = mAllMotions.begin();
+		 iter != mAllMotions.end(); iter++)
+	{
+		LLMotion* motionp = iter->second;
+		if (motionp) motionp->deactivate();
+	}
+
+	// delete all motion instances
+	deleteAllMotions();
+}
+
 
 //-----------------------------------------------------------------------------
 // flushAllMotions()
diff --git a/indra/llcharacter/llmotioncontroller.h b/indra/llcharacter/llmotioncontroller.h
index a19e704643a..15791b63188 100644
--- a/indra/llcharacter/llmotioncontroller.h
+++ b/indra/llcharacter/llmotioncontroller.h
@@ -138,6 +138,9 @@ class LLMotionController
 	// releases all motion instances
 	void flushAllMotions();
 
+	//Flush is a liar.
+	void deactivateAllMotions();	
+
 	// pause and continue all motions
 	void pause();
 	void unpause();
diff --git a/indra/newview/llpreview.cpp b/indra/newview/llpreview.cpp
index 562e4c37c10..c4f958420b9 100644
--- a/indra/newview/llpreview.cpp
+++ b/indra/newview/llpreview.cpp
@@ -50,7 +50,7 @@ LLPreview::LLPreview(const std::string& name) :
 	mAutoFocus = FALSE;
 }
 
-LLPreview::LLPreview(const std::string& name, const LLRect& rect, const std::string& title, const LLUUID& item_uuid, const LLUUID& object_uuid, BOOL allow_resize, S32 min_width, S32 min_height, LLViewerInventoryItem* inv_item )
+LLPreview::LLPreview(const std::string& name, const LLRect& rect, const std::string& title, const LLUUID& item_uuid, const LLUUID& object_uuid, BOOL allow_resize, S32 min_width, S32 min_height, LLPointer<LLViewerInventoryItem> inv_item )
 :	LLFloater(name, rect, title, allow_resize, min_width, min_height ),
 	mItemUUID(item_uuid),
 	mSourceID(LLUUID::null),
@@ -135,11 +135,11 @@ void LLPreview::setSourceID(const LLUUID& source_id)
 	sPreviewsBySource.insert(preview_multimap_t::value_type(mSourceID, mViewHandle));
 }
 
-LLViewerInventoryItem* LLPreview::getItem() const
+const LLViewerInventoryItem *LLPreview::getItem() const
 {
-	if(mItem != NULL)
+	if(mItem)
 		return mItem;
-	LLViewerInventoryItem* item = NULL;
+	const LLViewerInventoryItem *item = NULL;
 	if(mObjectUUID.isNull())
 	{
 		// it's an inventory item, so get the item.
@@ -160,7 +160,7 @@ LLViewerInventoryItem* LLPreview::getItem() const
 // Sub-classes should override this function if they allow editing
 void LLPreview::onCommit()
 {
-	LLViewerInventoryItem* item = getItem();
+	const LLViewerInventoryItem *item = getItem();
 	if(item)
 	{
 		if (!item->isComplete())
@@ -333,7 +333,7 @@ BOOL LLPreview::handleHover(S32 x, S32 y, MASK mask)
 	{
 		S32 screen_x;
 		S32 screen_y;
-		LLViewerInventoryItem *item = getItem();
+		const LLViewerInventoryItem *item = getItem();
 
 		localPointToScreen(x, y, &screen_x, &screen_y );
 		if(item
@@ -419,7 +419,7 @@ void LLPreview::onDiscardBtn(void* data)
 {
 	LLPreview* self = (LLPreview*)data;
 
-	LLViewerInventoryItem* item = self->getItem();
+	const LLViewerInventoryItem* item = self->getItem();
 	if (!item) return;
 
 	self->mForceClose = TRUE;
diff --git a/indra/newview/llpreview.h b/indra/newview/llpreview.h
index 1b7c0fd9c83..589e1fde21b 100644
--- a/indra/newview/llpreview.h
+++ b/indra/newview/llpreview.h
@@ -51,13 +51,13 @@ class LLPreview : public LLFloater
 public:
 	// Used for XML-based construction.
 	LLPreview(const std::string& name);
-	LLPreview(const std::string& name, const LLRect& rect, const std::string& title, const LLUUID& item_uuid, const LLUUID& object_uuid, BOOL allow_resize = FALSE, S32 min_width = 0, S32 min_height = 0, LLViewerInventoryItem* inv_item = NULL );
+	LLPreview(const std::string& name, const LLRect& rect, const std::string& title, const LLUUID& item_uuid, const LLUUID& object_uuid, BOOL allow_resize = FALSE, S32 min_width = 0, S32 min_height = 0, LLPointer<LLViewerInventoryItem> inv_item = NULL );
 	virtual ~LLPreview();
 
 	void setItemID(const LLUUID& item_id);
 	void setObjectID(const LLUUID& object_id);
 	void setSourceID(const LLUUID& source_id);
-	LLViewerInventoryItem* getItem() const; // searches if not constructed with it
+	const LLViewerInventoryItem *getItem() const; // searches if not constructed with it
 
 	static LLPreview* find(const LLUUID& item_uuid);
 	static LLPreview*	show(const LLUUID& item_uuid, BOOL take_focus = TRUE );
@@ -134,7 +134,7 @@ class LLPreview : public LLFloater
 	static preview_map_t sInstances;
 	LLUUID mNotecardInventoryID;
 	LLUUID mObjectID;
-	LLViewerInventoryItem* mItem;
+	LLPointer<LLViewerInventoryItem> mItem;
 };
 
 
diff --git a/indra/newview/llpreviewanim.cpp b/indra/newview/llpreviewanim.cpp
index 99cff4b7188..6e3403932d1 100644
--- a/indra/newview/llpreviewanim.cpp
+++ b/indra/newview/llpreviewanim.cpp
@@ -31,7 +31,7 @@ LLPreviewAnim::LLPreviewAnim(const std::string& name, const LLRect& rect, const
 	childSetAction("Anim play btn",playAnim,this);
 	childSetAction("Anim audition btn",auditionAnim,this);
 
-	LLInventoryItem* item = getItem();
+	const LLInventoryItem* item = getItem();
 	
 	childSetCommitCallback("desc", LLPreview::onText, this);
 	childSetText("desc", item->getDescription());
@@ -87,7 +87,7 @@ void LLPreviewAnim::endAnimCallback( void *userdata )
 void LLPreviewAnim::playAnim( void *userdata )
 {
 	LLPreviewAnim* self = (LLPreviewAnim*) userdata;
-	LLInventoryItem *item = self->getItem();
+	const LLInventoryItem *item = self->getItem();
 
 	if(item)
 	{
@@ -124,7 +124,7 @@ void LLPreviewAnim::playAnim( void *userdata )
 void LLPreviewAnim::auditionAnim( void *userdata )
 {
 	LLPreviewAnim* self = (LLPreviewAnim*) userdata;
-	LLInventoryItem *item = self->getItem();
+	const LLInventoryItem *item = self->getItem();
 
 	if(item)
 	{
@@ -160,7 +160,7 @@ void LLPreviewAnim::auditionAnim( void *userdata )
 void LLPreviewAnim::saveAnim( void *userdata )
 {
 	LLPreviewAnim* self = (LLPreviewAnim*) userdata;
-	LLInventoryItem *item = self->getItem();
+	const LLInventoryItem *item = self->getItem();
 
 	if(item)
 	{
@@ -186,7 +186,7 @@ void LLPreviewAnim::saveAnim( void *userdata )
 
 void LLPreviewAnim::onClose(bool app_quitting)
 {
-	LLInventoryItem *item = getItem();
+	const LLInventoryItem *item = getItem();
 
 	if(item)
 	{
diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp
index 9710fc8bf29..c556e3f4506 100644
--- a/indra/newview/llpreviewgesture.cpp
+++ b/indra/newview/llpreviewgesture.cpp
@@ -504,7 +504,7 @@ BOOL LLPreviewGesture::postBuild()
 	addSounds();
 
 
-	LLInventoryItem* item = getItem();
+	const LLInventoryItem* item = getItem();
 
 	if (item) 
 	{
@@ -830,7 +830,7 @@ void LLPreviewGesture::initDefaultGesture()
 
 void LLPreviewGesture::loadAsset()
 {
-	LLInventoryItem* item = getItem();
+	const LLInventoryItem* item = getItem();
 	if (!item) return;
 
 	LLUUID asset_id = item->getAssetUUID();
@@ -1100,7 +1100,7 @@ void LLPreviewGesture::saveIfNeeded()
 		file.write((U8*)buffer, size);
 
 		// Upload that asset to the database
-		LLInventoryItem* item = getItem();
+		const LLInventoryItem* item = getItem();
 		if (item)
 		{
 			std::string agent_url = gAgent.getRegion()->getCapability("UpdateGestureAgentInventory");
diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp
index e5dfb9ae768..8650bcf4591 100644
--- a/indra/newview/llpreviewnotecard.cpp
+++ b/indra/newview/llpreviewnotecard.cpp
@@ -62,7 +62,7 @@ LLPreviewNotecard::LLPreviewNotecard(const std::string& name,
 									 const LLUUID& object_id,
 									 const LLUUID& asset_id,
 									 BOOL show_keep_discard,
-									 LLViewerInventoryItem* inv_item) :
+									 LLPointer<LLViewerInventoryItem> inv_item) :
 	LLPreview(name, rect, title, item_id, object_id, TRUE,
 			  PREVIEW_MIN_WIDTH,
 			  PREVIEW_MIN_HEIGHT,
@@ -86,7 +86,7 @@ LLPreviewNotecard::LLPreviewNotecard(const std::string& name,
 		
 		if( mAssetID.isNull() )
 		{
-			LLInventoryItem* item = getItem();
+			const LLInventoryItem* item = getItem();
 			if( item )
 			{
 				mAssetID = item->getAssetUUID();
@@ -103,7 +103,7 @@ LLPreviewNotecard::LLPreviewNotecard(const std::string& name,
 			
 	childSetVisible("lock", FALSE);	
 	
-	LLInventoryItem* item = getItem();
+	const LLInventoryItem* item = getItem();
 	
 	childSetCommitCallback("desc", LLPreview::onText, this);
 	if (item)
@@ -242,7 +242,7 @@ void LLPreviewNotecard::refreshFromInventory()
 void LLPreviewNotecard::loadAsset()
 {
 	// request the asset.
-	LLInventoryItem* item = getItem();
+	const LLInventoryItem* item = getItem();
 	LLViewerTextEditor* editor = LLViewerUICtrlFactory::getViewerTextEditorByName(this, "Notecard Editor");
 
 	if (!editor)
@@ -366,7 +366,7 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs,
 
 			previewEditor->makePristine();
 
-			LLInventoryItem* item = preview->getItem();
+			const LLInventoryItem* item = preview->getItem();
 			BOOL modifiable = item && gAgent.allowOperation(PERM_MODIFY,
 								item->getPermissions(), GP_OBJECT_MANIPULATE);
 			preview->setEnabled(modifiable);
@@ -471,7 +471,7 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem)
 		file.setMaxSize(size);
 		file.write((U8*)buffer.c_str(), size);
 
-		LLInventoryItem* item = getItem();
+		const LLInventoryItem* item = getItem();
 		// save it out to database
 		if (item)
 		{			
diff --git a/indra/newview/llpreviewnotecard.h b/indra/newview/llpreviewnotecard.h
index 908d4da98cd..88ce8b36ce4 100644
--- a/indra/newview/llpreviewnotecard.h
+++ b/indra/newview/llpreviewnotecard.h
@@ -30,7 +30,7 @@ class LLPreviewNotecard : public LLPreview
 					  const LLUUID& object_id = LLUUID::null,
 					  const LLUUID& asset_id = LLUUID::null,
 					  BOOL show_keep_discard = FALSE,
-					  LLViewerInventoryItem* inv_item = NULL);
+					  LLPointer<LLViewerInventoryItem> inv_item = NULL);
 
 	// llpreview	
 	virtual bool saveItem(LLPointer<LLInventoryItem>* itemptr);
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 51ead9c5323..07e3853b273 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -1077,7 +1077,7 @@ LLPreviewLSL::LLPreviewLSL(const std::string& name, const LLRect& rect,
 	moveResizeHandleToFront();
 
 	
-	LLInventoryItem* item = getItem();	
+	const LLInventoryItem* item = getItem();	
 
 	childSetCommitCallback("desc", LLPreview::onText, this);
 	childSetText("desc", item->getDescription());
@@ -1131,7 +1131,7 @@ void LLPreviewLSL::loadAsset()
 	// *HACK: we poke into inventory to see if it's there, and if so,
 	// then it might be part of the inventory library. If it's in the
 	// library, then you can see the script, but not modify it.
-	LLInventoryItem* item = gInventory.getItem(mItemUUID);
+	const LLInventoryItem* item = gInventory.getItem(mItemUUID);
 	BOOL is_library = item
 		&& !gInventory.isObjectDescendentOf(mItemUUID,
 											gAgent.getInventoryRootID());
@@ -1258,7 +1258,7 @@ void LLPreviewLSL::saveIfNeeded()
 	fclose(fp);
 	fp = NULL;
 
-	LLInventoryItem *inv_item = getItem();
+	const LLInventoryItem *inv_item = getItem();
 	// save it out to asset server
 	std::string url = gAgent.getRegion()->getCapability("UpdateScriptAgentInventory");
 	if(inv_item)
@@ -1373,8 +1373,8 @@ void LLPreviewLSL::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32
 	{
 		if (info)
 		{
-			LLViewerInventoryItem* item;
-			item = (LLViewerInventoryItem*)gInventory.getItem(info->mItemUUID);
+			const LLViewerInventoryItem* item;
+			item = (const LLViewerInventoryItem*)gInventory.getItem(info->mItemUUID);
 			if(item)
 			{
 				LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
diff --git a/indra/newview/llpreviewsound.cpp b/indra/newview/llpreviewsound.cpp
index 871a0c55b7a..7df0e48762c 100644
--- a/indra/newview/llpreviewsound.cpp
+++ b/indra/newview/llpreviewsound.cpp
@@ -39,7 +39,7 @@ LLPreviewSound::LLPreviewSound(const std::string& name, const LLRect& rect, cons
 	button = LLUICtrlFactory::getButtonByName(this, "Sound audition btn");
 	button->setSoundFlags(LLView::SILENT);
 
-	LLInventoryItem* item = getItem();
+	const LLInventoryItem* item = getItem();
 	
 	childSetCommitCallback("desc", LLPreview::onText, this);
 	childSetText("desc", item->getDescription());
@@ -65,7 +65,7 @@ LLPreviewSound::LLPreviewSound(const std::string& name, const LLRect& rect, cons
 void LLPreviewSound::playSound( void *userdata )
 {
 	LLPreviewSound* self = (LLPreviewSound*) userdata;
-	LLInventoryItem *item = self->getItem();
+	const LLInventoryItem *item = self->getItem();
 
 	if(item && gAudiop)
 	{
@@ -77,7 +77,7 @@ void LLPreviewSound::playSound( void *userdata )
 void LLPreviewSound::auditionSound( void *userdata )
 {
 	LLPreviewSound* self = (LLPreviewSound*) userdata;
-	LLInventoryItem *item = self->getItem();
+	const LLInventoryItem *item = self->getItem();
 
 	if(item && gAudiop)
 	{
diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp
index 214b3e38f82..974ee274768 100644
--- a/indra/newview/llpreviewtexture.cpp
+++ b/indra/newview/llpreviewtexture.cpp
@@ -47,7 +47,7 @@ LLPreviewTexture::LLPreviewTexture(const std::string& name,
 	mLastHeight(0),
 	mLastWidth(0)
 {
-	LLInventoryItem *item = getItem();
+	const LLInventoryItem *item = getItem();
 	if(item)
 	{
 		mImageID = item->getAssetUUID();
@@ -157,7 +157,7 @@ void LLPreviewTexture::init()
 
 	if (!mCopyToInv) 
 	{
-		LLInventoryItem* item = getItem();
+		const LLInventoryItem* item = getItem();
 		
 		if (item)
 		{
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 898af8932fd..1565a5875b8 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -4538,11 +4538,7 @@ class LLToolsStopAllAnimations : public view_listener_t
 		
 		if (!avatarp) return true;
 		
-		LLVOAvatar::AnimSourceIterator anim_it = avatarp->mAnimationSources.begin();
-		for (;anim_it != avatarp->mAnimationSources.end(); ++anim_it)
-		{
-			avatarp->stopMotion( anim_it->second, TRUE );
-		}
+		avatarp->deactivateAllMotions();
 	
 		avatarp->processAnimationStateChanges();
 		return true;
-- 
GitLab