From 65352e988410d8001d485fa9d72858e21cc80df7 Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Fri, 19 Mar 2021 13:47:32 +0200
Subject: [PATCH] SL-14927 Some avatar names not resolving in chat

---
 indra/llui/llfolderviewitem.cpp         | 8 ++++++--
 indra/llui/llfolderviewitem.h           | 2 +-
 indra/newview/llfloaterimsessiontab.cpp | 2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp
index 9f6ceac768c..285bf9f4845 100644
--- a/indra/llui/llfolderviewitem.cpp
+++ b/indra/llui/llfolderviewitem.cpp
@@ -1608,7 +1608,7 @@ void LLFolderViewFolder::destroyView()
 
 // extractItem() removes the specified item from the folder, but
 // doesn't delete it.
-void LLFolderViewFolder::extractItem( LLFolderViewItem* item )
+void LLFolderViewFolder::extractItem( LLFolderViewItem* item, bool deparent_model )
 {
 	if (item->isSelected())
 		getRoot()->clearSelection();
@@ -1631,7 +1631,11 @@ void LLFolderViewFolder::extractItem( LLFolderViewItem* item )
 		mItems.erase(it);
 	}
 	//item has been removed, need to update filter
-	getViewModelItem()->removeChild(item->getViewModelItem());
+    if (deparent_model)
+    {
+        // in some cases model does not belong to parent view, is shared between views
+        getViewModelItem()->removeChild(item->getViewModelItem());
+    }
 	//because an item is going away regardless of filter status, force rearrange
 	requestArrange();
 	removeChild(item);
diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h
index da09d139e98..616d2e7d863 100644
--- a/indra/llui/llfolderviewitem.h
+++ b/indra/llui/llfolderviewitem.h
@@ -387,7 +387,7 @@ class LLFolderViewFolder : public LLFolderViewItem
 
 	// extractItem() removes the specified item from the folder, but
 	// doesn't delete it.
-	virtual void extractItem( LLFolderViewItem* item );
+	virtual void extractItem( LLFolderViewItem* item, bool deparent_model = true);
 
 	// This function is called by a child that needs to be resorted.
 	void resort(LLFolderViewItem* item);
diff --git a/indra/newview/llfloaterimsessiontab.cpp b/indra/newview/llfloaterimsessiontab.cpp
index 80165f9b9a7..ed1d7a81cc4 100644
--- a/indra/newview/llfloaterimsessiontab.cpp
+++ b/indra/newview/llfloaterimsessiontab.cpp
@@ -532,7 +532,7 @@ void LLFloaterIMSessionTab::removeConversationViewParticipant(const LLUUID& part
 	LLFolderViewItem* widget = get_ptr_in_map(mConversationsWidgets,participant_id);
 	if (widget)
 	{
-		mConversationsRoot->extractItem(widget);
+		mConversationsRoot->extractItem(widget, false);
 		delete widget;
 	}
 	mConversationsWidgets.erase(participant_id);
-- 
GitLab