summaryrefslogtreecommitdiff
path: root/indra/newview/llinventoryfunctions.cpp
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2012-02-16 14:57:30 -0800
committerMerov Linden <merov@lindenlab.com>2012-02-16 14:57:30 -0800
commit155a171180be2df4500e7c6d03df3f99bf4231e7 (patch)
treebc57e35ad1dc2d4a31cc77ac02cb10a23a165756 /indra/newview/llinventoryfunctions.cpp
parent632c8c138c94fae24729ef75ac29967cd4758eb3 (diff)
EXP-1896 : Prevent recursively copying of folders onto themselves
Diffstat (limited to 'indra/newview/llinventoryfunctions.cpp')
-rw-r--r--indra/newview/llinventoryfunctions.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index 4fb06f82c1..236c997ef6 100644
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -240,11 +240,15 @@ void rename_category(LLInventoryModel* model, const LLUUID& cat_id, const std::s
void copy_inventory_category(LLInventoryModel* model,
LLViewerInventoryCategory* cat,
- const LLUUID& parent_id)
+ const LLUUID& parent_id,
+ const LLUUID& root_copy_id)
{
// Create the initial folder
LLUUID new_cat_uuid = gInventory.createNewCategory(parent_id, LLFolderType::FT_NONE, cat->getName());
model->notifyObservers();
+
+ // We need to exclude the initial root of the copy to avoid recursively copying the copy, etc...
+ LLUUID root_id = (root_copy_id.isNull() ? new_cat_uuid : root_copy_id);
// Get the content of the folder
LLInventoryModel::cat_array_t* cat_array;
@@ -270,7 +274,10 @@ void copy_inventory_category(LLInventoryModel* model,
for (LLInventoryModel::cat_array_t::iterator iter = cat_array_copy.begin(); iter != cat_array_copy.end(); iter++)
{
LLViewerInventoryCategory* category = *iter;
- copy_inventory_category(model, category, new_cat_uuid);
+ if (category->getUUID() != root_id)
+ {
+ copy_inventory_category(model, category, new_cat_uuid, root_id);
+ }
}
}