diff options
author | Mike Antipov <mantipov@productengine.com> | 2010-01-29 12:25:38 +0200 |
---|---|---|
committer | Mike Antipov <mantipov@productengine.com> | 2010-01-29 12:25:38 +0200 |
commit | 72b2cf291d67ae7a271b5745e50290d174a088b6 (patch) | |
tree | 4753ec53dff35a3687aab99a84b9c1f8a8358c5d /indra/newview/llviewerinventory.cpp | |
parent | a08f098847cda964bfba5476fd213e05bdf67dd0 (diff) |
Work on major bug EXT-3985 ([BSI] Landmarks created in Viewer 2.0 show up with 1@ in Viewer 1.23.x)
-- implemented cleanning of stored sort indexes to remove ones for landmarks not in Favorites while disconnecting viewer
--HG--
branch : product-engine
Diffstat (limited to 'indra/newview/llviewerinventory.cpp')
-rw-r--r-- | indra/newview/llviewerinventory.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index a3cbd80c84..1b141532ef 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1178,8 +1178,10 @@ const std::string& LLViewerInventoryItem::getName() const /** * Class to store sorting order of favorites landmarks in a local file. EXT-3985. * It replaced previously implemented solution to store sort index in landmark's name as a "<N>@" prefix. + * Data are stored in user home directory. */ class LLFavoritesOrderStorage : public LLSingleton<LLFavoritesOrderStorage> + , public LLDestroyClass<LLFavoritesOrderStorage> { public: /** @@ -1193,12 +1195,27 @@ public: S32 getSortIndex(const LLUUID& inv_item_id); void removeSortIndex(const LLUUID& inv_item_id); + /** + * Implementation of LLDestroyClass. Calls cleanup() instance method. + * + * It is important this callback is called before gInventory is cleaned. + * For now it is called from LLAppViewer::cleanup() -> LLAppViewer::disconnectViewer(), + * Inventory is cleaned later from LLAppViewer::cleanup() after LLAppViewer::disconnectViewer() is called. + * @see cleanup() + */ + static void destroyClass(); + const static S32 NO_INDEX; private: friend class LLSingleton<LLFavoritesOrderStorage>; LLFavoritesOrderStorage() { load(); } ~LLFavoritesOrderStorage() { save(); } + /** + * Removes sort indexes for items which are not in Favorites bar for now. + */ + void cleanup(); + const static std::string SORTING_DATA_FILE_NAME; void load(); @@ -1206,6 +1223,32 @@ private: typedef std::map<LLUUID, S32> sort_index_map_t; sort_index_map_t mSortIndexes; + + struct IsNotInFavorites + { + IsNotInFavorites(const LLInventoryModel::item_array_t& items) + : mFavoriteItems(items) + { + + } + + /** + * Returns true if specified item is not found among inventory items + */ + bool operator()(const sort_index_map_t::value_type& id_index_pair) const + { + LLPointer<LLViewerInventoryItem> item = gInventory.getItem(id_index_pair.first); + if (item.isNull()) return true; + + LLInventoryModel::item_array_t::const_iterator found_it = + std::find(mFavoriteItems.begin(), mFavoriteItems.end(), item); + + return found_it == mFavoriteItems.end(); + } + private: + LLInventoryModel::item_array_t mFavoriteItems; + }; + }; const std::string LLFavoritesOrderStorage::SORTING_DATA_FILE_NAME = "landmarks_sorting.xml"; @@ -1231,6 +1274,12 @@ void LLFavoritesOrderStorage::removeSortIndex(const LLUUID& inv_item_id) mSortIndexes.erase(inv_item_id); } +// static +void LLFavoritesOrderStorage::destroyClass() +{ + LLFavoritesOrderStorage::instance().cleanup(); +} + void LLFavoritesOrderStorage::load() { // load per-resident sorting information @@ -1273,6 +1322,24 @@ void LLFavoritesOrderStorage::save() } } +void LLFavoritesOrderStorage::cleanup() +{ + const LLUUID fav_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE); + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + gInventory.collectDescendents(fav_id, cats, items, LLInventoryModel::EXCLUDE_TRASH); + + IsNotInFavorites is_not_in_fav(items); +
+ sort_index_map_t aTempMap;
+ //copy unremoved values from mSortIndexes to aTempMap
+ std::remove_copy_if(mSortIndexes.begin(), mSortIndexes.end(),
+ inserter(aTempMap, aTempMap.begin()),
+ is_not_in_fav);
+
+ //Swap the contents of mSortIndexes and aTempMap
+ mSortIndexes.swap(aTempMap); +} // *TODO: mantipov: REMOVE, EXT-3985 |