From 561da5bd7f32e5d09849ac97c69b1acf07cd9a0f Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Fri, 6 Nov 2020 23:17:30 +0200
Subject: [PATCH] SL-14270 Crash fix

---
 indra/llui/llfolderviewmodel.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/indra/llui/llfolderviewmodel.cpp b/indra/llui/llfolderviewmodel.cpp
index adadf979b7f..eae0d2f3e4b 100644
--- a/indra/llui/llfolderviewmodel.cpp
+++ b/indra/llui/llfolderviewmodel.cpp
@@ -50,7 +50,14 @@ LLFolderViewModelItemCommon::LLFolderViewModelItemCommon(LLFolderViewModelInterf
 
 LLFolderViewModelItemCommon::~LLFolderViewModelItemCommon()
 {
-    clearChildren();
+    // Children don't belong to model, but to LLFolderViewItem, just mark them as having no parent
+    std::for_each(mChildren.begin(), mChildren.end(), [](LLFolderViewModelItem* c) {c->setParent(NULL); });
+
+    // Don't leave dead pointer in parent
+    if (mParent)
+    {
+        mParent->removeChild(this);
+    }
 }
 
 void LLFolderViewModelItemCommon::dirtyFilter()
-- 
GitLab