From 7d8b90ce98e0b88cf8cfb5c6f6d4e0ce31eaaf64 Mon Sep 17 00:00:00 2001
From: andreykproductengine <akleshchev@productengine.com>
Date: Tue, 29 Jul 2014 17:55:06 +0300
Subject: [PATCH] MAINT-4289 FIXED [BEAR] Recent Items "Reset Filters" not
 working correctly

---
 indra/llui/llfolderviewitem.cpp              | 36 +++++++++++++-------
 indra/llui/llfolderviewitem.h                |  1 +
 indra/newview/llfolderviewmodelinventory.cpp |  4 +--
 3 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp
index 9a14d0e4193..e3ec333e213 100644
--- a/indra/llui/llfolderviewitem.cpp
+++ b/indra/llui/llfolderviewitem.cpp
@@ -256,6 +256,24 @@ BOOL LLFolderViewItem::passedFilter(S32 filter_generation)
 	return getViewModelItem()->passedFilter(filter_generation);
 }
 
+BOOL LLFolderViewItem::isPotentiallyVisible(S32 filter_generation)
+{
+	// Item should be visible if:
+	// 1. item passed current filter
+	// 2. item was updated (gen < 0) but has descendants that passed filter
+	// 3. item was recently updated and was visible before update
+
+	LLFolderViewModelItem* model = getViewModelItem();
+	if (model->getLastFilterGeneration() < 0)
+	{
+		return model->descendantsPassedFilter(filter_generation) || getVisible();
+	}
+	else
+	{
+		return model->passedFilter(filter_generation);
+	}
+}
+
 void LLFolderViewItem::refresh()
 {
 	LLFolderViewModelItem& vmi = *getViewModelItem();
@@ -970,9 +988,8 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height )
 	LL_RECORD_BLOCK_TIME(FTM_ARRANGE);
 
 	// evaluate mHasVisibleChildren
-	bool default_filter = getRoot()->getFolderViewModel()->getFilter().isDefault();
-	mHasVisibleChildren = default_filter && (mItems.size() || mFolders.size());
-	if (!default_filter && getViewModelItem()->descendantsPassedFilter())
+	mHasVisibleChildren = false;
+	if (getViewModelItem()->descendantsPassedFilter())
 	{
 		// We have to verify that there's at least one child that's not filtered out
 		bool found = false;
@@ -980,7 +997,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height )
 		for (items_t::iterator iit = mItems.begin(); iit != mItems.end(); ++iit)
 		{
 			LLFolderViewItem* itemp = (*iit);
-			found = itemp->passedFilter();
+			found = itemp->isPotentiallyVisible();
 			if (found)
 				break;
 		}
@@ -990,7 +1007,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height )
 			for (folders_t::iterator fit = mFolders.begin(); fit != mFolders.end(); ++fit)
 			{
 				LLFolderViewFolder* folderp = (*fit);
-				found = folderp->passedFilter();
+				found = folderp->isPotentiallyVisible();
 				if (found)
 					break;
 			}
@@ -1023,12 +1040,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height )
 			for(folders_t::iterator fit = mFolders.begin(); fit != mFolders.end(); ++fit)
 			{
 				LLFolderViewFolder* folderp = (*fit);
-
-				// passedFilter() will show everything  that passed filter or has descendants that passed filter
-				// also it will hide all filter-pending folders (they will be shown later if needed).
-				// but since refreshed folders are 'pending', they can be rendered invisible by passedFilter()
-				// even if we are not using filter at the moment, default_filter is used to prevent it
-				folderp->setVisible(default_filter || folderp->passedFilter());
+				folderp->setVisible(folderp->isPotentiallyVisible());
 
 				if (folderp->getVisible())
 				{
@@ -1047,7 +1059,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height )
 				iit != mItems.end(); ++iit)
 			{
 				LLFolderViewItem* itemp = (*iit);
-				itemp->setVisible(default_filter || itemp->passedFilter());
+				itemp->setVisible(itemp->isPotentiallyVisible());
 
 				if (itemp->getVisible())
 				{
diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h
index a9b0201236b..0cd20a0f2d9 100644
--- a/indra/llui/llfolderviewitem.h
+++ b/indra/llui/llfolderviewitem.h
@@ -254,6 +254,7 @@ class LLFolderViewItem : public LLView
 	S32				getIndentation() { return mIndentation; }
 
 	virtual BOOL	passedFilter(S32 filter_generation = -1);
+	virtual BOOL	isPotentiallyVisible(S32 filter_generation = -1);
 
 	// refresh information from the object being viewed.
 	virtual void refresh();
diff --git a/indra/newview/llfolderviewmodelinventory.cpp b/indra/newview/llfolderviewmodelinventory.cpp
index 11d49ff784e..7615c12043c 100755
--- a/indra/newview/llfolderviewmodelinventory.cpp
+++ b/indra/newview/llfolderviewmodelinventory.cpp
@@ -129,15 +129,13 @@ void LLFolderViewModelItemInventory::requestSort()
 
 void LLFolderViewModelItemInventory::setPassedFilter(bool passed, S32 filter_generation, std::string::size_type string_offset, std::string::size_type string_size)
 {
-	bool init_state = getLastFilterGeneration() < 0;
 	LLFolderViewModelItemCommon::setPassedFilter(passed, filter_generation, string_offset, string_size);
 	bool before = mPrevPassedAllFilters;
 	mPrevPassedAllFilters = passedFilter(filter_generation);
 
-	if (before != mPrevPassedAllFilters || (init_state && before && !mFolderViewItem->getVisible()))
+	if (before != mPrevPassedAllFilters)
 	{
 		// Need to rearrange the folder if the filtered state of the item changed
-		// or folder was hidden during update as filter-dirty (MAINT-4218)
 		LLFolderViewFolder* parent_folder = mFolderViewItem->getParentFolder();
 		if (parent_folder)
 		{
-- 
GitLab