From c287bc0a860532c09b02cb1e1b233395b05bbcb7 Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Tue, 12 Jul 2022 23:38:52 +0300
Subject: SL-17760 Crash at LLFolderViewItem::refresh(318)

and at LLFolderViewItem::postBuild for LLConversationViewParticipant
---
 indra/newview/llconversationview.cpp    | 47 ++++++++++++++++++++-------------
 indra/newview/llfloaterimsessiontab.cpp | 14 +++++++---
 2 files changed, 38 insertions(+), 23 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llconversationview.cpp b/indra/newview/llconversationview.cpp
index 20fa6d490b..48c7df40df 100644
--- a/indra/newview/llconversationview.cpp
+++ b/indra/newview/llconversationview.cpp
@@ -272,9 +272,9 @@ BOOL LLConversationViewSession::postBuild()
 		default:
 			break;
 		}
-	}
 
-	refresh();
+        refresh(); // requires vmi
+	}
 
 	return TRUE;
 }
@@ -490,17 +490,20 @@ void LLConversationViewSession::refresh()
 {
 	// Refresh the session view from its model data
 	LLConversationItem* vmi = dynamic_cast<LLConversationItem*>(getViewModelItem());
-	vmi->resetRefresh();
+    if (vmi)
+    {
+        vmi->resetRefresh();
 
-	if (mSessionTitle)
-	{		
-		if (!highlightFriendTitle(vmi))
-		{
-			LLStyle::Params title_style;
-			title_style.color = LLUIColorTable::instance().getColor("LabelTextColor");
-			mSessionTitle->setText(vmi->getDisplayName(), title_style);
-		}
-	}
+        if (mSessionTitle)
+        {
+            if (!highlightFriendTitle(vmi))
+            {
+                LLStyle::Params title_style;
+                title_style.color = LLUIColorTable::instance().getColor("LabelTextColor");
+                mSessionTitle->setText(vmi->getDisplayName(), title_style);
+            }
+        }
+    }
 
 	// Update all speaking indicators
 	LLSpeakingIndicatorManager::updateSpeakingIndicators();
@@ -524,8 +527,11 @@ void LLConversationViewSession::refresh()
 	}
 
 	requestArrange();
-	// Do the regular upstream refresh
-	LLFolderViewFolder::refresh();
+    if (vmi)
+    {
+        // Do the regular upstream refresh
+        LLFolderViewFolder::refresh();
+    }
 }
 
 void LLConversationViewSession::onCurrentVoiceSessionChanged(const LLUUID& session_id)
@@ -627,8 +633,11 @@ BOOL LLConversationViewParticipant::postBuild()
     }
 
     updateChildren();
-	LLFolderViewItem::postBuild();
-    refresh();
+    if (getViewModelItem())
+    {
+        LLFolderViewItem::postBuild();
+        refresh();
+    }
     return TRUE;
 }
 
@@ -712,10 +721,10 @@ void LLConversationViewParticipant::refresh()
 
         // *TODO: We should also do something with vmi->isModerator() to echo that state in the UI somewhat
         mSpeakingIndicator->setIsModeratorMuted(participant_model->isModeratorMuted());
+        
+        // Do the regular upstream refresh
+        LLFolderViewItem::refresh();
     }
-
-	// Do the regular upstream refresh
-	LLFolderViewItem::refresh();
 }
 
 void LLConversationViewParticipant::addToFolder(LLFolderViewFolder* folder)
diff --git a/indra/newview/llfloaterimsessiontab.cpp b/indra/newview/llfloaterimsessiontab.cpp
index 34499ac170..93a0b39e02 100644
--- a/indra/newview/llfloaterimsessiontab.cpp
+++ b/indra/newview/llfloaterimsessiontab.cpp
@@ -551,7 +551,7 @@ void LLFloaterIMSessionTab::removeConversationViewParticipant(const LLUUID& part
 void LLFloaterIMSessionTab::updateConversationViewParticipant(const LLUUID& participant_id)
 {
 	LLFolderViewItem* widget = get_ptr_in_map(mConversationsWidgets,participant_id);
-	if (widget)
+	if (widget && widget->getViewModelItem())
 	{
 		widget->refresh();
 	}
@@ -576,8 +576,11 @@ void LLFloaterIMSessionTab::refreshConversation()
 		{
 			participants_uuids.push_back(widget_it->first);
 		}
-		widget_it->second->refresh();
-		widget_it->second->setVisible(TRUE);
+        if (widget_it->second->getViewModelItem())
+        {
+            widget_it->second->refresh();
+            widget_it->second->setVisible(TRUE);
+        }
 		++widget_it;
 	}
 	if (is_ad_hoc || mIsP2PChat)
@@ -1126,7 +1129,10 @@ void LLFloaterIMSessionTab::getSelectedUUIDs(uuid_vec_t& selected_uuids)
     for (; it != it_end; ++it)
     {
         LLConversationItem* conversation_item = static_cast<LLConversationItem *>((*it)->getViewModelItem());
-        selected_uuids.push_back(conversation_item->getUUID());
+        if (conversation_item)
+        {
+            selected_uuids.push_back(conversation_item->getUUID());
+        }
     }
 }
 
-- 
cgit v1.2.3