From f30b54b64fcb6667571bf2340b396fb700ff6965 Mon Sep 17 00:00:00 2001 From: Mnikolenko ProductEngine Date: Wed, 18 Mar 2015 18:11:09 +0200 Subject: MAINT-4993 FIXED Favorite landmarks randomly reorder between sessions or when adding or removing a landmark from favorites --- indra/newview/llfavoritesbar.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp index 6c5b5be720..4ee81f4afa 100755 --- a/indra/newview/llfavoritesbar.cpp +++ b/indra/newview/llfavoritesbar.cpp @@ -1653,6 +1653,17 @@ void LLFavoritesOrderStorage::cleanup() mSortIndexes.swap(aTempMap); } +// See also LLInventorySort where landmarks in the Favorites folder are sorted. +class LLViewerInventoryItemSort +{ +public: + bool operator()(const LLPointer& a, const LLPointer& b) + { + return LLFavoritesOrderStorage::instance().getSortIndex(a->getUUID()) + < LLFavoritesOrderStorage::instance().getSortIndex(b->getUUID()); + } +}; + void LLFavoritesOrderStorage::saveOrder() { LLInventoryModel::cat_array_t cats; @@ -1660,6 +1671,7 @@ void LLFavoritesOrderStorage::saveOrder() LLIsType is_type(LLAssetType::AT_LANDMARK); LLUUID favorites_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE); gInventory.collectDescendentsIf(favorites_id, cats, items, LLInventoryModel::EXCLUDE_TRASH, is_type); + std::sort(items.begin(), items.end(), LLViewerInventoryItemSort()); saveItemsOrder(items); } @@ -1685,16 +1697,7 @@ void LLFavoritesOrderStorage::saveItemsOrder( const LLInventoryModel::item_array gInventory.notifyObservers(); } -// See also LLInventorySort where landmarks in the Favorites folder are sorted. -class LLViewerInventoryItemSort -{ -public: - bool operator()(const LLPointer& a, const LLPointer& b) - { - return LLFavoritesOrderStorage::instance().getSortIndex(a->getUUID()) - < LLFavoritesOrderStorage::instance().getSortIndex(b->getUUID()); - } -}; + // * @param source_item_id - LLUUID of the source item to be moved into new position // * @param target_item_id - LLUUID of the target item before which source item should be placed. -- cgit v1.2.3