From 2d0b329003d0350c12ce4686f1261e68ce39573b Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Mon, 17 Jun 2013 16:20:17 -0400
Subject: [PATCH] SH-4238 WIP - postpone calling notifyObservers until all
 deletes are processed.

---
 indra/newview/llaisapi.cpp         |  4 +++-
 indra/newview/llinventorymodel.cpp | 13 +++++++++----
 indra/newview/llinventorymodel.h   |  7 +++++--
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/indra/newview/llaisapi.cpp b/indra/newview/llaisapi.cpp
index 393e5c0a68e..21f6482a06f 100755
--- a/indra/newview/llaisapi.cpp
+++ b/indra/newview/llaisapi.cpp
@@ -476,7 +476,9 @@ void AISUpdate::doUpdate()
 		 del_it != mObjectsDeleted.end(); ++del_it)
 	{
 		LL_DEBUGS("Inventory") << "deleted item " << *del_it << llendl;
-		gInventory.onObjectDeletedFromServer(*del_it, false, false);
+		gInventory.onObjectDeletedFromServer(*del_it, false, false, false);
 	}
+
+	gInventory.notifyObservers();
 }
 
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index 6dc193292e1..aadf87ab35c 100755
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -1157,6 +1157,7 @@ void LLInventoryModel::changeCategoryParent(LLViewerInventoryCategory* cat,
 
 void LLInventoryModel::onAISUpdateReceived(const std::string& context, const LLSD& update)
 {
+	LLTimer timer;
 	if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage"))
 	{
 		dump_sequential_xml(gAgentAvatarp->getFullname() + "_ais_update", update);
@@ -1164,6 +1165,7 @@ void LLInventoryModel::onAISUpdateReceived(const std::string& context, const LLS
 
 	AISUpdate ais_update(update); // parse update llsd into stuff to do.
 	ais_update.doUpdate(); // execute the updates in the appropriate order.
+	llinfos << "elapsed: " << timer.getElapsedTimeF32() << llendl;
 }
 
 void LLInventoryModel::onItemUpdated(const LLUUID& item_id, const LLSD& updates, bool update_parent_version)
@@ -1316,7 +1318,7 @@ void LLInventoryModel::onDescendentsPurgedFromServer(const LLUUID& object_id, bo
 
 // Update model after an item is confirmed as removed from
 // server. Works for categories or items.
-void LLInventoryModel::onObjectDeletedFromServer(const LLUUID& object_id, bool fix_broken_links, bool update_parent_version)
+void LLInventoryModel::onObjectDeletedFromServer(const LLUUID& object_id, bool fix_broken_links, bool update_parent_version, bool do_notify_observers)
 {
 	LLPointer<LLInventoryObject> obj = getObject(object_id);
 	if(obj)
@@ -1337,13 +1339,13 @@ void LLInventoryModel::onObjectDeletedFromServer(const LLUUID& object_id, bool f
 
 		// From purgeObject()
 		LLPreview::hide(object_id);
-		deleteObject(object_id, fix_broken_links);
+		deleteObject(object_id, fix_broken_links, do_notify_observers);
 	}
 }
 
 
 // Delete a particular inventory object by ID.
-void LLInventoryModel::deleteObject(const LLUUID& id, bool fix_broken_links)
+void LLInventoryModel::deleteObject(const LLUUID& id, bool fix_broken_links, bool do_notify_observers)
 {
 	lldebugs << "LLInventoryModel::deleteObject()" << llendl;
 	LLPointer<LLInventoryObject> obj = getObject(id);
@@ -1402,7 +1404,10 @@ void LLInventoryModel::deleteObject(const LLUUID& id, bool fix_broken_links)
 	{
 		updateLinkedObjectsFromPurge(id);
 	}
-	notifyObservers();
+	if (do_notify_observers)
+	{
+		notifyObservers();
+	}
 }
 
 void LLInventoryModel::updateLinkedObjectsFromPurge(const LLUUID &baseobj_id)
diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h
index a41a8249066..5de951ed05c 100755
--- a/indra/newview/llinventorymodel.h
+++ b/indra/newview/llinventorymodel.h
@@ -334,7 +334,10 @@ class LLInventoryModel
 		
 	// Update model after an item is confirmed as removed from
 	// server. Works for categories or items.
-	void onObjectDeletedFromServer(const LLUUID& item_id, bool fix_broken_links = true, bool update_parent_version = true);
+	void onObjectDeletedFromServer(const LLUUID& item_id,
+								   bool fix_broken_links = true,
+								   bool update_parent_version = true,
+								   bool do_notify_observers = true);
 
 	// Update model after all descendents removed from server.
 	void onDescendentsPurgedFromServer(const LLUUID& object_id, bool fix_broken_links = true);
@@ -349,7 +352,7 @@ class LLInventoryModel
 	// object from the internal data structures, maintaining a
 	// consistent internal state. No cache accounting, observer
 	// notification, or server update is performed.
-	void deleteObject(const LLUUID& id, bool fix_broken_links = true);
+	void deleteObject(const LLUUID& id, bool fix_broken_links = true, bool do_notify_observers = true);
 	/// move Item item_id to Trash
 	void removeItem(const LLUUID& item_id);
 	/// move Category category_id to Trash
-- 
GitLab