From 320dfa1d72c2eab9c59daf6bb13cc5001162c7b0 Mon Sep 17 00:00:00 2001
From: Monroe Linden <monroe@lindenlab.com>
Date: Thu, 19 Nov 2009 15:01:27 -0800
Subject: Added LLVOVolume::markDead(), which unhooks any prim media instances
 from the dead object.

---
 indra/newview/llvovolume.cpp | 22 ++++++++++++++++++++++
 indra/newview/llvovolume.h   |  1 +
 2 files changed, 23 insertions(+)

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index e5531a1497..8bfbfcb9c3 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -183,6 +183,22 @@ LLVOVolume::~LLVOVolume()
 	}
 }
 
+void LLVOVolume::markDead()
+{
+	if (!mDead)
+	{
+		// TODO: tell LLMediaDataClient to remove this object from its queue
+		
+		// Detach all media impls from this object
+		for(U32 i = 0 ; i < mMediaImplList.size() ; i++)
+		{
+			removeMediaImpl(i);
+		}
+	}
+	
+	LLViewerObject::markDead();
+}
+
 
 // static
 void LLVOVolume::initClass()
@@ -1708,6 +1724,12 @@ void LLVOVolume::updateObjectMediaData(const LLSD &media_data_array)
 
 void LLVOVolume::syncMediaData(S32 texture_index, const LLSD &media_data, bool merge, bool ignore_agent)
 {
+	if(mDead)
+	{
+		// If the object has been marked dead, don't process media updates.
+		return;
+	}
+	
 	LLTextureEntry *te = getTE(texture_index);
 	//llinfos << "BEFORE: texture_index = " << texture_index
 	//	<< " hasMedia = " << te->hasMedia() << " : " 
diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h
index fb543efc04..70d203daf2 100644
--- a/indra/newview/llvovolume.h
+++ b/indra/newview/llvovolume.h
@@ -100,6 +100,7 @@ public:
 
 public:
 						LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
+	/*virtual*/ void markDead();		// Override (and call through to parent) to clean up media references
 
 	/*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline);
 
-- 
cgit v1.2.3