diff options
author | brad kittenbrink <brad@lindenlab.com> | 2010-11-22 19:07:17 -0800 |
---|---|---|
committer | brad kittenbrink <brad@lindenlab.com> | 2010-11-22 19:07:17 -0800 |
commit | 7db4d2b88f24ae5fe6051968d6d4c3ba9aadf817 (patch) | |
tree | 9d7a6dfc7a2d869229d698126c0536a7de35ca60 /indra/newview | |
parent | 023af775d552709dd8f6f8ee77aeb939510aaed2 (diff) |
Fix for CHOP-220. Reviewed by mani.
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llpanellandmarks.cpp | 3 | ||||
-rw-r--r-- | indra/newview/llpanelpick.cpp | 3 | ||||
-rw-r--r-- | indra/newview/llpanelplaceinfo.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llremoteparcelrequest.cpp | 53 | ||||
-rw-r--r-- | indra/newview/llremoteparcelrequest.h | 2 |
5 files changed, 34 insertions, 31 deletions
diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp index d25b8e0e02..e8c8273a9d 100644 --- a/indra/newview/llpanellandmarks.cpp +++ b/indra/newview/llpanellandmarks.cpp @@ -520,9 +520,6 @@ void LLLandmarksPanel::setParcelID(const LLUUID& parcel_id) { 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); } diff --git a/indra/newview/llpanelpick.cpp b/indra/newview/llpanelpick.cpp index 271728220c..44cca21a76 100644 --- a/indra/newview/llpanelpick.cpp +++ b/indra/newview/llpanelpick.cpp @@ -204,9 +204,6 @@ void LLPanelPickInfo::sendParcelInfoRequest() { 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); diff --git a/indra/newview/llpanelplaceinfo.cpp b/indra/newview/llpanelplaceinfo.cpp index 9cbb512e70..4ae0c0eb12 100644 --- a/indra/newview/llpanelplaceinfo.cpp +++ b/indra/newview/llpanelplaceinfo.cpp @@ -128,10 +128,6 @@ void LLPanelPlaceInfo::sendParcelInfoRequest() { 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); diff --git a/indra/newview/llremoteparcelrequest.cpp b/indra/newview/llremoteparcelrequest.cpp index d63a48647d..10d4452ed2 100644 --- a/indra/newview/llremoteparcelrequest.cpp +++ b/indra/newview/llremoteparcelrequest.cpp @@ -77,23 +77,19 @@ void LLRemoteParcelRequestResponder::error(U32 status, const std::string& reason void LLRemoteParcelInfoProcessor::addObserver(const LLUUID& parcel_id, LLRemoteParcelInfoObserver* observer) { - // Check if the observer is already in observers list for this UUID observer_multimap_t::iterator it; + observer_multimap_t::iterator end = mObservers.upper_bound(parcel_id); - it = mObservers.find(parcel_id); - while (it != mObservers.end()) + // Check if the observer is already in observers list for this UUID + 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) @@ -104,19 +100,15 @@ void LLRemoteParcelInfoProcessor::removeObserver(const LLUUID& parcel_id, LLRemo } 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; - } } } @@ -141,13 +133,34 @@ void LLRemoteParcelInfoProcessor::processParcelInfoReply(LLMessageSystem* msg, v 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; + + typedef std::vector<observer_multimap_t::iterator> deadlist_t; + deadlist_t dead_iters; - observer_multimap_t::iterator oi = observers.find(parcel_data.parcel_id); + 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) + { + 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) { - oi->second->processParcelInfo(parcel_data); + observers.erase(*i); } } diff --git a/indra/newview/llremoteparcelrequest.h b/indra/newview/llremoteparcelrequest.h index a6c62995a9..74cf1616df 100644 --- a/indra/newview/llremoteparcelrequest.h +++ b/indra/newview/llremoteparcelrequest.h @@ -98,7 +98,7 @@ public: 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; }; |