nat_linden avatar nat_linden committed 6f4836f

DRTVWR-136: Remove redundant remove_(item|category)() functions.
Incoming changes from two different project repos left viewer-development with
LLInventoryModel::removeItem() and removeCategory() plus free functions
remove_item() and remove_category() in llinventoryfunctions.cpp.
remove_category() was actually the better implementation; migrated its body
into LLInventoryModel::removeCategory(). Clearly the previous state of affairs
-- with LLInventoryModel::removeItem() plus a remove_category() free function
in a very different source file -- fooled two different developers into
overlooking the other of the pair. Unfortunately we each added different
"missing" functions, leaving us with a complete set of four.
Fix existing references to remove_item() and remove_category() free functions.

Comments (0)

Files changed (6)

indra/newview/llfolderview.cpp

 		 iter != objects.end();
 		 ++iter)
 	{
-		const LLUUID& item_id = (*iter);
-		LLInventoryObject *obj = gInventory.getObject(item_id);
-		if (obj)
-		{
-			if (LLAssetType::AT_CATEGORY == obj->getType())
-			{
-				remove_category(&gInventory, item_id);
-			}
-			else
-			{
-				remove_item(&gInventory, item_id);
-			}
-		}
+		gInventory.removeObject(*iter);
 	}
 }
 

indra/newview/llinventorybridge.cpp

 	{
 		// move it to the trash
 		LLPreview::hide(mUUID);
-		remove_category(getInventoryModel(), mUUID);
+		getInventoryModel()->removeCategory(mUUID);
 		return TRUE;
 	}
 	return FALSE;

indra/newview/llinventoryfunctions.cpp

 	path.append(temp);
 }
 
-// Move the item to the trash. Works for folders and objects.
-// Caution: This method assumes that the item is removable!
-void remove_item(LLInventoryModel* model, const LLUUID& id)
-{
-	LLViewerInventoryItem* item = model->getItem(id);
-	if (!item)
-		return;
-	
-	if (item->getType() == LLAssetType::AT_CATEGORY)
-	{
-		// Call the general helper function to delete a folder
-		remove_category(model, id);
-	}
-	else
-	{
-		// Get the trash UUID
-		LLUUID trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH, false);
-		if (trash_id.notNull())
-		{
-			// Finally, move the item to the trash
-			model->changeItemParent(item, trash_id, true);
-		}
-	}
-}
-
-void remove_category(LLInventoryModel* model, const LLUUID& cat_id)
-{
-	if (!model || !get_is_category_removable(model, cat_id))
-	{
-		return;
-	}
-
-	// Look for any gestures and deactivate them
-	LLInventoryModel::cat_array_t	descendent_categories;
-	LLInventoryModel::item_array_t	descendent_items;
-	gInventory.collectDescendents(cat_id, descendent_categories, descendent_items, FALSE);
-
-	for (LLInventoryModel::item_array_t::const_iterator iter = descendent_items.begin();
-		 iter != descendent_items.end();
-		 ++iter)
-	{
-		const LLViewerInventoryItem* item = (*iter);
-		const LLUUID& item_id = item->getUUID();
-		if (item->getType() == LLAssetType::AT_GESTURE
-			&& LLGestureMgr::instance().isGestureActive(item_id))
-		{
-			LLGestureMgr::instance().deactivateGesture(item_id);
-		}
-	}
-
-	LLViewerInventoryCategory* cat = gInventory.getCategory(cat_id);
-	if (cat)
-	{
-		const LLUUID trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH);
-		model->changeCategoryParent(cat, trash_id, TRUE);
-	}
-}
-
 void rename_category(LLInventoryModel* model, const LLUUID& cat_id, const std::string& new_name)
 {
 	LLViewerInventoryCategory* cat;
 
 				if (cat_array->empty() && item_array->empty())
 				{
-					remove_category(&gInventory, parent);
+					gInventory.removeCategory(parent);
 				}
 
 				if (parent == top_level_folder)

indra/newview/llinventoryfunctions.h

 
 void show_item_original(const LLUUID& item_uuid);
 
-void remove_item(LLInventoryModel* model, const LLUUID& id);
-
-void remove_category(LLInventoryModel* model, const LLUUID& cat_id);
-
 void rename_category(LLInventoryModel* model, const LLUUID& cat_id, const std::string& new_name);
 
 void copy_inventory_category(LLInventoryModel* model, LLViewerInventoryCategory* cat, const LLUUID& parent_id, const LLUUID& root_copy_id = LLUUID::null);

indra/newview/llinventorymodel.cpp

 #include "llviewerregion.h"
 #include "llcallbacklist.h"
 #include "llvoavatarself.h"
+#include "llgesturemgr.h"
 #include <typeinfo>
 
 //#define DIFF_INVENTORY_FILES
 	else
 	{
 		const LLUUID new_parent = findCategoryUUIDForType(LLFolderType::FT_TRASH);
-		LL_INFOS("Inventory") << "Moving to Trash (" << new_parent << "):" << LL_ENDL;
-		changeItemParent(item, new_parent, TRUE);
+		if (new_parent.notNull())
+		{
+			LL_INFOS("Inventory") << "Moving to Trash (" << new_parent << "):" << LL_ENDL;
+			changeItemParent(item, new_parent, TRUE);
+		}
 	}
 }
 
 void LLInventoryModel::removeCategory(const LLUUID& category_id)
 {
+	if (! get_is_category_removable(this, category_id))
+	{
+		return;
+	}
+
+	// Look for any gestures and deactivate them
+	LLInventoryModel::cat_array_t	descendent_categories;
+	LLInventoryModel::item_array_t	descendent_items;
+	collectDescendents(category_id, descendent_categories, descendent_items, FALSE);
+
+	for (LLInventoryModel::item_array_t::const_iterator iter = descendent_items.begin();
+		 iter != descendent_items.end();
+		 ++iter)
+	{
+		const LLViewerInventoryItem* item = (*iter);
+		const LLUUID& item_id = item->getUUID();
+		if (item->getType() == LLAssetType::AT_GESTURE
+			&& LLGestureMgr::instance().isGestureActive(item_id))
+		{
+			LLGestureMgr::instance().deactivateGesture(item_id);
+		}
+	}
+
 	LLViewerInventoryCategory* cat = getCategory(category_id);
-	if (! cat)
+	if (cat)
 	{
-		LL_WARNS("Inventory") << "couldn't find inventory folder " << category_id << LL_ENDL;
-	}
-	else
-	{
-		const LLUUID new_parent = findCategoryUUIDForType(LLFolderType::FT_TRASH);
-		LL_INFOS("Inventory") << "Moving to Trash (" << new_parent << "):" << LL_ENDL;
-		changeCategoryParent(cat, new_parent, TRUE);
+		const LLUUID trash_id = findCategoryUUIDForType(LLFolderType::FT_TRASH);
+		if (trash_id.notNull())
+		{
+			changeCategoryParent(cat, trash_id, TRUE);
+		}
 	}
 }
 

indra/newview/lloutfitslist.cpp

 
 	if (mSelectedOutfitUUID.notNull())
 	{
-		remove_category(&gInventory, mSelectedOutfitUUID);
+		gInventory.removeCategory(mSelectedOutfitUUID);
 	}
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.