diff options
Diffstat (limited to 'indra/newview/llinventorymodel.cpp')
| -rw-r--r-- | indra/newview/llinventorymodel.cpp | 131 | 
1 files changed, 75 insertions, 56 deletions
| diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 9e37c5be38..fb9be1e04f 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -36,10 +36,11 @@  #include "llagent.h"  #include "llagentwearables.h"  #include "llinventorypanel.h" -#include "llfloaterinventory.h"  #include "llinventorybridge.h"  #include "llinventoryfunctions.h"  #include "llinventoryobserver.h" +#include "llinventorypanel.h" +#include "llnotificationsutil.h"  #include "llwindow.h"  #include "llviewercontrol.h"  #include "llpreview.h"  @@ -210,6 +211,25 @@ BOOL LLInventoryModel::isObjectDescendentOf(const LLUUID& obj_id,  	return FALSE;  } +const LLViewerInventoryCategory *LLInventoryModel::getFirstNondefaultParent(const LLUUID& obj_id) const +{ +	const LLInventoryObject* obj = getObject(obj_id); +	const LLUUID& parent_id = obj->getParentUUID(); +	while (!parent_id.isNull()) +	{ +		const LLViewerInventoryCategory *cat = getCategory(parent_id); +		if (!cat) break; +		const LLFolderType::EType folder_type = cat->getPreferredType(); +		if (folder_type != LLFolderType::FT_NONE && +			folder_type != LLFolderType::FT_ROOT_INVENTORY && +			!LLFolderType::lookupIsEnsembleType(folder_type)) +		{ +			return cat; +		} +	} +	return NULL; +} +  // Get the object by id. Returns NULL if not found.  LLInventoryObject* LLInventoryModel::getObject(const LLUUID& id) const  { @@ -870,46 +890,48 @@ void LLInventoryModel::moveObject(const LLUUID& object_id, const LLUUID& cat_id)  // Delete a particular inventory object by ID.  void LLInventoryModel::deleteObject(const LLUUID& id)  { -	// Disabling this; let users manually purge linked objects. -	// purgeLinkedObjects(id);  	lldebugs << "LLInventoryModel::deleteObject()" << llendl;  	LLPointer<LLInventoryObject> obj = getObject(id); -	if(obj) +	if (!obj)   	{ -		lldebugs << "Deleting inventory object " << id << llendl; -		mLastItem = NULL; -		LLUUID parent_id = obj->getParentUUID(); -		mCategoryMap.erase(id); -		mItemMap.erase(id); -		//mInventory.erase(id); -		item_array_t* item_list = getUnlockedItemArray(parent_id); -		if(item_list) -		{ -			LLViewerInventoryItem* item = (LLViewerInventoryItem*)((LLInventoryObject*)obj); -			item_list->removeObj(item); -		} -		cat_array_t* cat_list = getUnlockedCatArray(parent_id); -		if(cat_list) -		{ -			LLViewerInventoryCategory* cat = (LLViewerInventoryCategory*)((LLInventoryObject*)obj); -			cat_list->removeObj(cat); -		} -		item_list = getUnlockedItemArray(id); -		if(item_list) -		{ -			delete item_list; -			mParentChildItemTree.erase(id); -		} -		cat_list = getUnlockedCatArray(id); -		if(cat_list) -		{ -			delete cat_list; -			mParentChildCategoryTree.erase(id); -		} -		addChangedMask(LLInventoryObserver::REMOVE, id); -		obj = NULL; // delete obj -		gInventory.notifyObservers(); +		llwarns << "Deleting non-existent object [ id: " << id << " ] " << llendl; +		return;  	} +	 +	lldebugs << "Deleting inventory object " << id << llendl; +	mLastItem = NULL; +	LLUUID parent_id = obj->getParentUUID(); +	mCategoryMap.erase(id); +	mItemMap.erase(id); +	//mInventory.erase(id); +	item_array_t* item_list = getUnlockedItemArray(parent_id); +	if(item_list) +	{ +		LLViewerInventoryItem* item = (LLViewerInventoryItem*)((LLInventoryObject*)obj); +		item_list->removeObj(item); +	} +	cat_array_t* cat_list = getUnlockedCatArray(parent_id); +	if(cat_list) +	{ +		LLViewerInventoryCategory* cat = (LLViewerInventoryCategory*)((LLInventoryObject*)obj); +		cat_list->removeObj(cat); +	} +	item_list = getUnlockedItemArray(id); +	if(item_list) +	{ +		delete item_list; +		mParentChildItemTree.erase(id); +	} +	cat_list = getUnlockedCatArray(id); +	if(cat_list) +	{ +		delete cat_list; +		mParentChildCategoryTree.erase(id); +	} +	addChangedMask(LLInventoryObserver::REMOVE, id); +	obj = NULL; // delete obj +	updateLinkedObjectsFromPurge(id); +	gInventory.notifyObservers();  }  // Delete a particular inventory item by ID, and remove it from the server. @@ -925,26 +947,23 @@ void LLInventoryModel::purgeObject(const LLUUID &id)  	}  } -void LLInventoryModel::purgeLinkedObjects(const LLUUID &id) +void LLInventoryModel::updateLinkedObjectsFromPurge(const LLUUID &baseobj_id)  { -	LLInventoryObject* objectp = getObject(id); -	if (!objectp) return; - -	if (objectp->getIsLinkType()) -	{ -		return; -	} +	LLInventoryModel::item_array_t item_array = collectLinkedItems(baseobj_id); -	LLInventoryModel::item_array_t item_array = collectLinkedItems(id); -	 -	for (LLInventoryModel::item_array_t::iterator iter = item_array.begin(); +	// REBUILD is expensive, so clear the current change list first else +	// everything else on the changelist will also get rebuilt. +	gInventory.notifyObservers(); +	for (LLInventoryModel::item_array_t::const_iterator iter = item_array.begin();  		 iter != item_array.end();  		 iter++)  	{ -		LLViewerInventoryItem *linked_item = (*iter); -		if (linked_item->getUUID() == id) continue; -		purgeObject(linked_item->getUUID()); +		const LLViewerInventoryItem *linked_item = (*iter); +		const LLUUID &item_id = linked_item->getUUID(); +		if (item_id == baseobj_id) continue; +		addChangedMask(LLInventoryObserver::REBUILD, item_id);  	} +	gInventory.notifyObservers();  }  // This is a method which collects the descendents of the id @@ -3047,10 +3066,10 @@ void LLInventoryModel::processUpdateInventoryFolder(LLMessageSystem* msg,  	gInventory.notifyObservers();  	// *HACK: Do the 'show' logic for a new item in the inventory. -	LLFloaterInventory* view = LLFloaterInventory::getActiveInventory(); -	if(view) +	LLInventoryPanel *active_panel = LLInventoryPanel::getActiveInventoryPanel(); +	if (active_panel)  	{ -		view->getPanel()->setSelection(lastfolder->getUUID(), TAKE_FOCUS_NO); +		active_panel->setSelection(lastfolder->getUUID(), TAKE_FOCUS_NO);  	}  } @@ -3419,7 +3438,7 @@ void LLInventoryModel::processMoveInventoryItem(LLMessageSystem* msg, void**)  bool LLInventoryModel::callbackEmptyFolderType(const LLSD& notification, const LLSD& response, LLFolderType::EType preferred_type)  { -	S32 option = LLNotification::getSelectedOption(notification, response); +	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);  	if (option == 0) // YES  	{  		const LLUUID folder_id = findCategoryUUIDForType(preferred_type); @@ -3433,7 +3452,7 @@ void LLInventoryModel::emptyFolderType(const std::string notification, LLFolderT  {  	if (!notification.empty())  	{ -		LLNotifications::instance().add(notification, LLSD(), LLSD(), +		LLNotificationsUtil::add(notification, LLSD(), LLSD(),  										boost::bind(&LLInventoryModel::callbackEmptyFolderType, this, _1, _2, preferred_type));  	}  	else | 
