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/llremoteparcelrequest.cpp | |
parent | 023af775d552709dd8f6f8ee77aeb939510aaed2 (diff) |
Fix for CHOP-220. Reviewed by mani.
Diffstat (limited to 'indra/newview/llremoteparcelrequest.cpp')
-rw-r--r-- | indra/newview/llremoteparcelrequest.cpp | 53 |
1 files changed, 33 insertions, 20 deletions
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); } } |