summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2021-04-03 00:15:44 +0300
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2021-04-03 00:15:44 +0300
commit2be5baf70dcf4e55fcac3935e304828ced202123 (patch)
treea5e621e99d764af9528c1fbfbbfa6b584bb4498b /indra/newview
parent820ac72f8c4a07bc4310b9daac6966f2f2f2ee98 (diff)
SL-13182 Fix excessive resorting #2
Don't resort whole branch of inventory if created(loaded) item is not newer. Should also stabilize fetch phase a bit.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llfolderviewmodelinventory.cpp38
-rw-r--r--indra/newview/llfolderviewmodelinventory.h3
-rw-r--r--indra/newview/llinventorybridge.cpp6
3 files changed, 37 insertions, 10 deletions
diff --git a/indra/newview/llfolderviewmodelinventory.cpp b/indra/newview/llfolderviewmodelinventory.cpp
index 4544b083ed..b6d856e31b 100644
--- a/indra/newview/llfolderviewmodelinventory.cpp
+++ b/indra/newview/llfolderviewmodelinventory.cpp
@@ -132,6 +132,16 @@ bool LLFolderViewModelInventory::isFolderComplete(LLFolderViewFolder* folder)
return false;
}
+//virtual
+void LLFolderViewModelItemInventory::addChild(LLFolderViewModelItem* child)
+{
+ LLFolderViewModelItemInventory* model_child = static_cast<LLFolderViewModelItemInventory*>(child);
+ mLastAddedChildCreationDate = model_child->getCreationDate();
+
+ // this will requestSort()
+ LLFolderViewModelItemCommon::addChild(child);
+}
+
void LLFolderViewModelItemInventory::requestSort()
{
LLFolderViewModelItemCommon::requestSort();
@@ -142,18 +152,29 @@ void LLFolderViewModelItemInventory::requestSort()
}
LLInventorySort sorter = static_cast<LLFolderViewModelInventory&>(mRootViewModel).getSorter();
- if (sorter.isByDate())
+ // Sort by date potentially affects parent folders which use a date
+ // derived from newest item in them
+ if (sorter.isByDate() && mParent)
{
- // Sort by date potentially affects parent folders which use a date
- // derived from newest item in them
- //
- // if this is an item, parent needs to be resorted (this case shouldn't happen)
- // if this is a folder, check sort rules for folder first
- if (mParent && (!folderp || !sorter.isFoldersByName()))
+ // If this is an item, parent needs to be resorted
+ // This case shouldn't happen, unless someone calls item->requestSort()
+ if (!folderp)
{
mParent->requestSort();
}
+ // if this is a folder, check sort rules for folder first
+ else if (sorter.isFoldersByDate())
+ {
+ if (mLastAddedChildCreationDate == -1 // nothing was added, some other reason for resort
+ || mLastAddedChildCreationDate > getCreationDate()) // newer child
+ {
+ LLFolderViewModelItemInventory* model_parent = static_cast<LLFolderViewModelItemInventory*>(mParent);
+ model_parent->mLastAddedChildCreationDate = mLastAddedChildCreationDate;
+ mParent->requestSort();
+ }
+ }
}
+ mLastAddedChildCreationDate = -1;
}
void LLFolderViewModelItemInventory::setPassedFilter(bool passed, S32 filter_generation, std::string::size_type string_offset, std::string::size_type string_size)
@@ -392,6 +413,7 @@ bool LLInventorySort::operator()(const LLFolderViewModelItemInventory* const& a,
LLFolderViewModelItemInventory::LLFolderViewModelItemInventory( class LLFolderViewModelInventory& root_view_model ) :
LLFolderViewModelItemCommon(root_view_model),
- mPrevPassedAllFilters(false)
+ mPrevPassedAllFilters(false),
+ mLastAddedChildCreationDate(-1)
{
}
diff --git a/indra/newview/llfolderviewmodelinventory.h b/indra/newview/llfolderviewmodelinventory.h
index 8ee3f75002..4cb62583cc 100644
--- a/indra/newview/llfolderviewmodelinventory.h
+++ b/indra/newview/llfolderviewmodelinventory.h
@@ -46,6 +46,7 @@ public:
virtual void showProperties(void) = 0;
virtual BOOL isItemInTrash( void) const { return FALSE; } // TODO: make into pure virtual.
virtual BOOL isUpToDate() const = 0;
+ virtual void addChild(LLFolderViewModelItem* child);
virtual bool hasChildren() const = 0;
virtual LLInventoryType::EType getInventoryType() const = 0;
virtual void performAction(LLInventoryModel* model, std::string action) = 0;
@@ -62,6 +63,7 @@ public:
virtual LLToolDragAndDrop::ESource getDragSource() const = 0;
protected:
bool mPrevPassedAllFilters;
+ time_t mLastAddedChildCreationDate; // -1 if nothing was added
};
class LLInventorySort
@@ -83,6 +85,7 @@ public:
bool isByDate() const { return mByDate; }
bool isFoldersByName() const { return (!mByDate || mFoldersByName) && !mFoldersByWeight; }
+ bool isFoldersByDate() const { return mByDate && !mFoldersByName && !mFoldersByWeight; }
U32 getSortOrder() const { return mSortOrder; }
void toParams(Params& p) { p.order(mSortOrder);}
void fromParams(Params& p)
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 15c3f10436..923a06b324 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -1905,7 +1905,8 @@ void LLItemBridge::buildDisplayName() const
LLStringUtil::toUpper(mSearchableName);
//Name set, so trigger a sort
- if(mParent)
+ LLInventorySort sorter = static_cast<LLFolderViewModelInventory&>(mRootViewModel).getSorter();
+ if(mParent && !sorter.isByDate())
{
mParent->requestSort();
}
@@ -2204,7 +2205,8 @@ void LLFolderBridge::buildDisplayName() const
LLStringUtil::toUpper(mSearchableName);
//Name set, so trigger a sort
- if(mParent)
+ LLInventorySort sorter = static_cast<LLFolderViewModelInventory&>(mRootViewModel).getSorter();
+ if(mParent && sorter.isFoldersByName())
{
mParent->requestSort();
}