diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llinventorymodel.cpp | 76 |
1 files changed, 61 insertions, 15 deletions
diff --git a/linden/indra/newview/llinventorymodel.cpp b/linden/indra/newview/llinventorymodel.cpp index 0e6056f..b1e3017 100644 --- a/linden/indra/newview/llinventorymodel.cpp +++ b/linden/indra/newview/llinventorymodel.cpp | |||
@@ -293,6 +293,28 @@ void LLInventoryModel::getDirectDescendentsOf(const LLUUID& cat_id, | |||
293 | items = get_ptr_in_map(mParentChildItemTree, cat_id); | 293 | items = get_ptr_in_map(mParentChildItemTree, cat_id); |
294 | } | 294 | } |
295 | 295 | ||
296 | // SJB: Added version to lock the arrays to catch potential logic bugs | ||
297 | void LLInventoryModel::lockDirectDescendentArrays(const LLUUID& cat_id, | ||
298 | cat_array_t*& categories, | ||
299 | item_array_t*& items) | ||
300 | { | ||
301 | getDirectDescendentsOf(cat_id, categories, items); | ||
302 | if (categories) | ||
303 | { | ||
304 | mCategoryLock[cat_id] = true; | ||
305 | } | ||
306 | if (items) | ||
307 | { | ||
308 | mItemLock[cat_id] = true; | ||
309 | } | ||
310 | } | ||
311 | |||
312 | void LLInventoryModel::unlockDirectDescendentArrays(const LLUUID& cat_id) | ||
313 | { | ||
314 | mCategoryLock[cat_id] = false; | ||
315 | mItemLock[cat_id] = false; | ||
316 | } | ||
317 | |||
296 | // findCategoryUUIDForType() returns the uuid of the category that | 318 | // findCategoryUUIDForType() returns the uuid of the category that |
297 | // specifies 'type' as what it defaults to containing. The category is | 319 | // specifies 'type' as what it defaults to containing. The category is |
298 | // not necessarily only for that type. *NOTE: This will create a new | 320 | // not necessarily only for that type. *NOTE: This will create a new |
@@ -620,6 +642,26 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item) | |||
620 | return mask; | 642 | return mask; |
621 | } | 643 | } |
622 | 644 | ||
645 | LLInventoryModel::cat_array_t* LLInventoryModel::getUnlockedCatArray(const LLUUID& id) | ||
646 | { | ||
647 | cat_array_t* cat_array = get_ptr_in_map(mParentChildCategoryTree, id); | ||
648 | if (cat_array) | ||
649 | { | ||
650 | llassert_always(mCategoryLock[id] == false); | ||
651 | } | ||
652 | return cat_array; | ||
653 | } | ||
654 | |||
655 | LLInventoryModel::item_array_t* LLInventoryModel::getUnlockedItemArray(const LLUUID& id) | ||
656 | { | ||
657 | item_array_t* item_array = get_ptr_in_map(mParentChildItemTree, id); | ||
658 | if (item_array) | ||
659 | { | ||
660 | llassert_always(mItemLock[id] == false); | ||
661 | } | ||
662 | return item_array; | ||
663 | } | ||
664 | |||
623 | // Calling this method with an inventory category will either change | 665 | // Calling this method with an inventory category will either change |
624 | // an existing item with the matching id, or it will add the category. | 666 | // an existing item with the matching id, or it will add the category. |
625 | void LLInventoryModel::updateCategory(const LLViewerInventoryCategory* cat) | 667 | void LLInventoryModel::updateCategory(const LLViewerInventoryCategory* cat) |
@@ -646,12 +688,12 @@ void LLInventoryModel::updateCategory(const LLViewerInventoryCategory* cat) | |||
646 | { | 688 | { |
647 | // need to update the parent-child tree | 689 | // need to update the parent-child tree |
648 | cat_array_t* cat_array; | 690 | cat_array_t* cat_array; |
649 | cat_array = get_ptr_in_map(mParentChildCategoryTree, old_parent_id); | 691 | cat_array = getUnlockedCatArray(old_parent_id); |
650 | if(cat_array) | 692 | if(cat_array) |
651 | { | 693 | { |
652 | cat_array->removeObj(old_cat); | 694 | cat_array->removeObj(old_cat); |
653 | } | 695 | } |
654 | cat_array = get_ptr_in_map(mParentChildCategoryTree, new_parent_id); | 696 | cat_array = getUnlockedCatArray(new_parent_id); |
655 | if(cat_array) | 697 | if(cat_array) |
656 | { | 698 | { |
657 | cat_array->put(old_cat); | 699 | cat_array->put(old_cat); |
@@ -674,13 +716,15 @@ void LLInventoryModel::updateCategory(const LLViewerInventoryCategory* cat) | |||
674 | 716 | ||
675 | // make sure this category is correctly referenced by it's parent. | 717 | // make sure this category is correctly referenced by it's parent. |
676 | cat_array_t* cat_array; | 718 | cat_array_t* cat_array; |
677 | cat_array = get_ptr_in_map(mParentChildCategoryTree, cat->getParentUUID()); | 719 | cat_array = getUnlockedCatArray(cat->getParentUUID()); |
678 | if(cat_array) | 720 | if(cat_array) |
679 | { | 721 | { |
680 | cat_array->put(new_cat); | 722 | cat_array->put(new_cat); |
681 | } | 723 | } |
682 | 724 | ||
683 | // make space in the tree for this category's children. | 725 | // make space in the tree for this category's children. |
726 | llassert_always(mCategoryLock[new_cat->getUUID()] == false); | ||
727 | llassert_always(mItemLock[new_cat->getUUID()] == false); | ||
684 | cat_array_t* catsp = new cat_array_t; | 728 | cat_array_t* catsp = new cat_array_t; |
685 | item_array_t* itemsp = new item_array_t; | 729 | item_array_t* itemsp = new item_array_t; |
686 | mParentChildCategoryTree[new_cat->getUUID()] = catsp; | 730 | mParentChildCategoryTree[new_cat->getUUID()] = catsp; |
@@ -708,9 +752,9 @@ void LLInventoryModel::moveObject(const LLUUID& object_id, const LLUUID& cat_id) | |||
708 | if(cat && (cat->getParentUUID() != cat_id)) | 752 | if(cat && (cat->getParentUUID() != cat_id)) |
709 | { | 753 | { |
710 | cat_array_t* cat_array; | 754 | cat_array_t* cat_array; |
711 | cat_array = get_ptr_in_map(mParentChildCategoryTree, cat->getParentUUID()); | 755 | cat_array = getUnlockedCatArray(cat->getParentUUID()); |
712 | if(cat_array) cat_array->removeObj(cat); | 756 | if(cat_array) cat_array->removeObj(cat); |
713 | cat_array = get_ptr_in_map(mParentChildCategoryTree, cat_id); | 757 | cat_array = getUnlockedCatArray(cat_id); |
714 | cat->setParent(cat_id); | 758 | cat->setParent(cat_id); |
715 | if(cat_array) cat_array->put(cat); | 759 | if(cat_array) cat_array->put(cat); |
716 | addChangedMask(LLInventoryObserver::STRUCTURE, object_id); | 760 | addChangedMask(LLInventoryObserver::STRUCTURE, object_id); |
@@ -720,9 +764,9 @@ void LLInventoryModel::moveObject(const LLUUID& object_id, const LLUUID& cat_id) | |||
720 | if(item && (item->getParentUUID() != cat_id)) | 764 | if(item && (item->getParentUUID() != cat_id)) |
721 | { | 765 | { |
722 | item_array_t* item_array; | 766 | item_array_t* item_array; |
723 | item_array = get_ptr_in_map(mParentChildItemTree, item->getParentUUID()); | 767 | item_array = getUnlockedItemArray(item->getParentUUID()); |
724 | if(item_array) item_array->removeObj(item); | 768 | if(item_array) item_array->removeObj(item); |
725 | item_array = get_ptr_in_map(mParentChildItemTree, cat_id); | 769 | item_array = getUnlockedItemArray(cat_id); |
726 | item->setParent(cat_id); | 770 | item->setParent(cat_id); |
727 | if(item_array) item_array->put(item); | 771 | if(item_array) item_array->put(item); |
728 | addChangedMask(LLInventoryObserver::STRUCTURE, object_id); | 772 | addChangedMask(LLInventoryObserver::STRUCTURE, object_id); |
@@ -743,25 +787,25 @@ void LLInventoryModel::deleteObject(const LLUUID& id) | |||
743 | mCategoryMap.erase(id); | 787 | mCategoryMap.erase(id); |
744 | mItemMap.erase(id); | 788 | mItemMap.erase(id); |
745 | //mInventory.erase(id); | 789 | //mInventory.erase(id); |
746 | item_array_t* item_list = get_ptr_in_map(mParentChildItemTree, parent_id); | 790 | item_array_t* item_list = getUnlockedItemArray(parent_id); |
747 | if(item_list) | 791 | if(item_list) |
748 | { | 792 | { |
749 | LLViewerInventoryItem* item = (LLViewerInventoryItem*)((LLInventoryObject*)obj); | 793 | LLViewerInventoryItem* item = (LLViewerInventoryItem*)((LLInventoryObject*)obj); |
750 | item_list->removeObj(item); | 794 | item_list->removeObj(item); |
751 | } | 795 | } |
752 | cat_array_t* cat_list = get_ptr_in_map(mParentChildCategoryTree, parent_id); | 796 | cat_array_t* cat_list = getUnlockedCatArray(parent_id); |
753 | if(cat_list) | 797 | if(cat_list) |
754 | { | 798 | { |
755 | LLViewerInventoryCategory* cat = (LLViewerInventoryCategory*)((LLInventoryObject*)obj); | 799 | LLViewerInventoryCategory* cat = (LLViewerInventoryCategory*)((LLInventoryObject*)obj); |
756 | cat_list->removeObj(cat); | 800 | cat_list->removeObj(cat); |
757 | } | 801 | } |
758 | item_list = get_ptr_in_map(mParentChildItemTree, id); | 802 | item_list = getUnlockedItemArray(id); |
759 | if(item_list) | 803 | if(item_list) |
760 | { | 804 | { |
761 | delete item_list; | 805 | delete item_list; |
762 | mParentChildItemTree.erase(id); | 806 | mParentChildItemTree.erase(id); |
763 | } | 807 | } |
764 | cat_list = get_ptr_in_map(mParentChildCategoryTree, id); | 808 | cat_list = getUnlockedCatArray(id); |
765 | if(cat_list) | 809 | if(cat_list) |
766 | { | 810 | { |
767 | delete cat_list; | 811 | delete cat_list; |
@@ -2060,11 +2104,13 @@ void LLInventoryModel::buildParentChildMap() | |||
2060 | cats.put(cat); | 2104 | cats.put(cat); |
2061 | if (mParentChildCategoryTree.count(cat->getUUID()) == 0) | 2105 | if (mParentChildCategoryTree.count(cat->getUUID()) == 0) |
2062 | { | 2106 | { |
2107 | llassert_always(mCategoryLock[cat->getUUID()] == false); | ||
2063 | catsp = new cat_array_t; | 2108 | catsp = new cat_array_t; |
2064 | mParentChildCategoryTree[cat->getUUID()] = catsp; | 2109 | mParentChildCategoryTree[cat->getUUID()] = catsp; |
2065 | } | 2110 | } |
2066 | if (mParentChildItemTree.count(cat->getUUID()) == 0) | 2111 | if (mParentChildItemTree.count(cat->getUUID()) == 0) |
2067 | { | 2112 | { |
2113 | llassert_always(mItemLock[cat->getUUID()] == false); | ||
2068 | itemsp = new item_array_t; | 2114 | itemsp = new item_array_t; |
2069 | mParentChildItemTree[cat->getUUID()] = itemsp; | 2115 | mParentChildItemTree[cat->getUUID()] = itemsp; |
2070 | } | 2116 | } |
@@ -2089,7 +2135,7 @@ void LLInventoryModel::buildParentChildMap() | |||
2089 | for(i = 0; i < count; ++i) | 2135 | for(i = 0; i < count; ++i) |
2090 | { | 2136 | { |
2091 | LLViewerInventoryCategory* cat = cats.get(i); | 2137 | LLViewerInventoryCategory* cat = cats.get(i); |
2092 | catsp = get_ptr_in_map(mParentChildCategoryTree, cat->getParentUUID()); | 2138 | catsp = getUnlockedCatArray(cat->getParentUUID()); |
2093 | if(catsp) | 2139 | if(catsp) |
2094 | { | 2140 | { |
2095 | catsp->put(cat); | 2141 | catsp->put(cat); |
@@ -2122,7 +2168,7 @@ void LLInventoryModel::buildParentChildMap() | |||
2122 | cat->setParent(gAgent.getInventoryRootID()); | 2168 | cat->setParent(gAgent.getInventoryRootID()); |
2123 | } | 2169 | } |
2124 | cat->updateServer(TRUE); | 2170 | cat->updateServer(TRUE); |
2125 | catsp = get_ptr_in_map(mParentChildCategoryTree, cat->getParentUUID()); | 2171 | catsp = getUnlockedCatArray(cat->getParentUUID()); |
2126 | if(catsp) | 2172 | if(catsp) |
2127 | { | 2173 | { |
2128 | catsp->put(cat); | 2174 | catsp->put(cat); |
@@ -2158,7 +2204,7 @@ void LLInventoryModel::buildParentChildMap() | |||
2158 | { | 2204 | { |
2159 | LLPointer<LLViewerInventoryItem> item; | 2205 | LLPointer<LLViewerInventoryItem> item; |
2160 | item = items.get(i); | 2206 | item = items.get(i); |
2161 | itemsp = get_ptr_in_map(mParentChildItemTree, item->getParentUUID()); | 2207 | itemsp = getUnlockedItemArray(item->getParentUUID()); |
2162 | if(itemsp) | 2208 | if(itemsp) |
2163 | { | 2209 | { |
2164 | itemsp->put(item); | 2210 | itemsp->put(item); |
@@ -2175,7 +2221,7 @@ void LLInventoryModel::buildParentChildMap() | |||
2175 | // we update server here, the client might crash. | 2221 | // we update server here, the client might crash. |
2176 | //item->updateServer(); | 2222 | //item->updateServer(); |
2177 | lost_item_ids.push_back(item->getUUID()); | 2223 | lost_item_ids.push_back(item->getUUID()); |
2178 | itemsp = get_ptr_in_map(mParentChildItemTree, item->getParentUUID()); | 2224 | itemsp = getUnlockedItemArray(item->getParentUUID()); |
2179 | if(itemsp) | 2225 | if(itemsp) |
2180 | { | 2226 | { |
2181 | itemsp->put(item); | 2227 | itemsp->put(item); |