Brad Kittenbrink avatar Brad Kittenbrink committed d255fa3

Fix for CHOP-220. Reviewed by mani.

Comments (0)

Files changed (5)

indra/newview/llpanellandmarks.cpp

 {
 	if (!parcel_id.isNull())
 	{
-        //ext-4655, defensive. remove now incase this gets called twice without a remove
-        LLRemoteParcelInfoProcessor::getInstance()->removeObserver(parcel_id, this);
-        
 		LLRemoteParcelInfoProcessor::getInstance()->addObserver(parcel_id, this);
 		LLRemoteParcelInfoProcessor::getInstance()->sendParcelInfoRequest(parcel_id);
 	}

indra/newview/llpanelpick.cpp

 {
 	if (mParcelId != mRequestedId)
 	{
-        //ext-4655, remove now incase this gets called twice without a remove
-        LLRemoteParcelInfoProcessor::getInstance()->removeObserver(mRequestedId, this);
-        
 		LLRemoteParcelInfoProcessor::getInstance()->addObserver(mParcelId, this);
 		LLRemoteParcelInfoProcessor::getInstance()->sendParcelInfoRequest(mParcelId);
 

indra/newview/llpanelplaceinfo.cpp

 {
 	if (mParcelID != mRequestedID)
 	{
-        //ext-4655, defensive. remove now incase this gets called twice without a remove
-        //as panel never closes its ok atm (but wrong :) 
-        LLRemoteParcelInfoProcessor::getInstance()->removeObserver(mRequestedID, this);
-
 		LLRemoteParcelInfoProcessor::getInstance()->addObserver(mParcelID, this);
 		LLRemoteParcelInfoProcessor::getInstance()->sendParcelInfoRequest(mParcelID);
 

indra/newview/llremoteparcelrequest.cpp

 
 void LLRemoteParcelInfoProcessor::addObserver(const LLUUID& parcel_id, LLRemoteParcelInfoObserver* observer)
 {
+	observer_multimap_t::iterator it;
+	observer_multimap_t::iterator end = mObservers.upper_bound(parcel_id);
+
 	// Check if the observer is already in observers list for this UUID
-	observer_multimap_t::iterator it;
-
-	it = mObservers.find(parcel_id);
-	while (it != mObservers.end())
+	for(it = mObservers.find(parcel_id); it != end; ++it)
 	{
-		if (it->second == observer)
+		if (it->second.get() == observer)
 		{
 			return;
 		}
-		else
-		{
-			++it;
-		}
 	}
 
-	mObservers.insert(std::pair<LLUUID, LLRemoteParcelInfoObserver*>(parcel_id, observer));
+	mObservers.insert(std::make_pair(parcel_id, observer->getObserverHandle()));
 }
 
 void LLRemoteParcelInfoProcessor::removeObserver(const LLUUID& parcel_id, LLRemoteParcelInfoObserver* observer)
 	}
 
 	observer_multimap_t::iterator it;
+	observer_multimap_t::iterator end = mObservers.upper_bound(parcel_id);
 
-	it = mObservers.find(parcel_id);
-	while (it != mObservers.end())
+	for(it = mObservers.find(parcel_id); it != end; ++it)
 	{
-		if (it->second == observer)
+		if (it->second.get() == observer)
 		{
 			mObservers.erase(it);
 			break;
 		}
-		else
-		{
-			++it;
-		}
 	}
 }
 
 	msg->getS32		("Data", "SalePrice", parcel_data.sale_price);
 	msg->getS32		("Data", "AuctionID", parcel_data.auction_id);
 
-	LLRemoteParcelInfoProcessor::observer_multimap_t observers = LLRemoteParcelInfoProcessor::getInstance()->mObservers;
+	LLRemoteParcelInfoProcessor::observer_multimap_t & observers = LLRemoteParcelInfoProcessor::getInstance()->mObservers;
 
-	observer_multimap_t::iterator oi = observers.find(parcel_data.parcel_id);
+	typedef std::vector<observer_multimap_t::iterator> deadlist_t;
+	deadlist_t dead_iters;
+
+	observer_multimap_t::iterator oi;
 	observer_multimap_t::iterator end = observers.upper_bound(parcel_data.parcel_id);
-	for (; oi != end; ++oi)
+
+	for (oi = observers.find(parcel_data.parcel_id); oi != end; ++oi)
 	{
-		oi->second->processParcelInfo(parcel_data);
+		LLRemoteParcelInfoObserver * observer = oi->second.get();
+		if(observer)
+		{
+			observer->processParcelInfo(parcel_data);
+		}
+		else
+		{
+			// the handle points to an expired observer, so don't keep it
+			// around anymore
+			dead_iters.push_back(oi);
+		}
+	}
+
+	deadlist_t::iterator i;
+	deadlist_t::iterator end_dead = dead_iters.end();
+	for(i = dead_iters.begin(); i != end_dead; ++i)
+	{
+		observers.erase(*i);
 	}
 }
 

indra/newview/llremoteparcelrequest.h

 	static void processParcelInfoReply(LLMessageSystem* msg, void**);
 
 private:
-	typedef std::multimap<LLUUID, LLRemoteParcelInfoObserver*> observer_multimap_t;
+	typedef std::multimap<LLUUID, LLHandle<LLRemoteParcelInfoObserver> > observer_multimap_t;
 	observer_multimap_t mObservers;
 };
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.