Skip to content
Snippets Groups Projects
Commit 72b2cf29 authored by Mike Antipov's avatar Mike Antipov
Browse files

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
parent a08f0988
No related branches found
No related tags found
No related merge requests found
...@@ -1178,8 +1178,10 @@ const std::string& LLViewerInventoryItem::getName() const ...@@ -1178,8 +1178,10 @@ const std::string& LLViewerInventoryItem::getName() const
/** /**
* Class to store sorting order of favorites landmarks in a local file. EXT-3985. * 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. * 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> class LLFavoritesOrderStorage : public LLSingleton<LLFavoritesOrderStorage>
, public LLDestroyClass<LLFavoritesOrderStorage>
{ {
public: public:
/** /**
...@@ -1193,12 +1195,27 @@ class LLFavoritesOrderStorage : public LLSingleton<LLFavoritesOrderStorage> ...@@ -1193,12 +1195,27 @@ class LLFavoritesOrderStorage : public LLSingleton<LLFavoritesOrderStorage>
S32 getSortIndex(const LLUUID& inv_item_id); S32 getSortIndex(const LLUUID& inv_item_id);
void removeSortIndex(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; const static S32 NO_INDEX;
private: private:
friend class LLSingleton<LLFavoritesOrderStorage>; friend class LLSingleton<LLFavoritesOrderStorage>;
LLFavoritesOrderStorage() { load(); } LLFavoritesOrderStorage() { load(); }
~LLFavoritesOrderStorage() { save(); } ~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; const static std::string SORTING_DATA_FILE_NAME;
void load(); void load();
...@@ -1206,6 +1223,32 @@ class LLFavoritesOrderStorage : public LLSingleton<LLFavoritesOrderStorage> ...@@ -1206,6 +1223,32 @@ class LLFavoritesOrderStorage : public LLSingleton<LLFavoritesOrderStorage>
typedef std::map<LLUUID, S32> sort_index_map_t; typedef std::map<LLUUID, S32> sort_index_map_t;
sort_index_map_t mSortIndexes; 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"; const std::string LLFavoritesOrderStorage::SORTING_DATA_FILE_NAME = "landmarks_sorting.xml";
...@@ -1231,6 +1274,12 @@ void LLFavoritesOrderStorage::removeSortIndex(const LLUUID& inv_item_id) ...@@ -1231,6 +1274,12 @@ void LLFavoritesOrderStorage::removeSortIndex(const LLUUID& inv_item_id)
mSortIndexes.erase(inv_item_id); mSortIndexes.erase(inv_item_id);
} }
// static
void LLFavoritesOrderStorage::destroyClass()
{
LLFavoritesOrderStorage::instance().cleanup();
}
void LLFavoritesOrderStorage::load() void LLFavoritesOrderStorage::load()
{ {
// load per-resident sorting information // load per-resident sorting information
...@@ -1273,6 +1322,24 @@ void LLFavoritesOrderStorage::save() ...@@ -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 // *TODO: mantipov: REMOVE, EXT-3985
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment