diff options
author | Merov Linden <merov@lindenlab.com> | 2010-11-24 13:57:22 -0800 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2010-11-24 13:57:22 -0800 |
commit | 2e46db239fc8587ecb5aafceda2f060fd470cd93 (patch) | |
tree | a1de838836e837ed9e63eb69990437a69bc0ae9b /indra/newview/llremoteparcelrequest.cpp | |
parent | f2194ee5f6ae305b4eaa379168aefecf0aed477a (diff) | |
parent | d9e2d4de48fb8bdbf5b6bb40aa6302e5bfccbe25 (diff) |
Pull from viewer-beta
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); } } |