@@ -51,6 +51,7 @@ LLInventoryItemsList::LLInventoryItemsList(const LLInventoryItemsList::Params& p
5151: LLFlatListViewEx(p)
5252, mRefreshState(REFRESH_COMPLETE)
5353, mForceRefresh(false )
54+ , mNeedsArrange(true )
5455{
5556 // TODO: mCommitOnSelectionChange is set to "false" in LLFlatListView
5657 // but reset to true in all derived classes. This settings might need to
@@ -218,8 +219,6 @@ void LLInventoryItemsList::refresh()
218219 mRefreshState = REFRESH_LIST_SORT;
219220 }
220221
221- rearrangeItems ();
222- notifyParentItemsRectChanged ();
223222 break ;
224223 }
225224 case REFRESH_LIST_ERASE:
@@ -229,10 +228,21 @@ void LLInventoryItemsList::refresh()
229228 for (; mRemovedItems .end () != it; ++it)
230229 {
231230 // don't filter items right away
232- removeItemByUUID (*it, false );
231+ removeItemByUUID (*it, false /* don't rearrange */ );
233232 }
234233 mRemovedItems .clear ();
235- mRefreshState = REFRESH_LIST_SORT; // fix visibility and arrange
234+ mRefreshState = REFRESH_LIST_SORT; // fix visibility
235+
236+ // Assume that visible items were removed.
237+ if (getVisible ())
238+ {
239+ rearrangeItems ();
240+ notifyParentItemsRectChanged ();
241+ }
242+ else
243+ {
244+ mNeedsArrange = true ;
245+ }
236246 break ;
237247 }
238248 case REFRESH_LIST_APPEND:
@@ -275,18 +285,25 @@ void LLInventoryItemsList::refresh()
275285 LLSD action;
276286 action.with (" match_filter" , cur_filter);
277287
288+ bool new_visible_items = false ;
278289 pairs_const_iterator_t pair_it = panel_list.begin ();
279290 for (; pair_it != panel_list.end (); ++pair_it)
280291 {
281292 item_pair_t * item_pair = *pair_it;
282293 if (item_pair->first ->getParent () != NULL )
283294 {
284- updateItemVisibility (item_pair->first , action);
295+ new_visible_items |= updateItemVisibility (item_pair->first , action);
285296 }
286297 }
287298
288- rearrangeItems ();
289- notifyParentItemsRectChanged ();
299+ mNeedsArrange |= new_visible_items;
300+ if (mNeedsArrange && getVisible ())
301+ {
302+ // show changes now
303+ rearrangeItems ();
304+ notifyParentItemsRectChanged ();
305+ mNeedsArrange = false ;
306+ }
290307
291308 if (mAddedItems .size () > 0 )
292309 {
@@ -304,16 +321,33 @@ void LLInventoryItemsList::refresh()
304321 {
305322 LL_PROFILE_ZONE_NAMED (" items_refresh_sort" );
306323 // Filter, sort, rearrange and notify parent about shape changes
307- filterItems (true , true );
324+ if (filterItems (true , true ))
325+ {
326+ mNeedsArrange = false ; // just rearranged
327+ }
308328
309329 if (mAddedItems .size () == 0 )
310330 {
331+ if (mNeedsArrange )
332+ {
333+ // Done, last chance to rearrange
334+ rearrangeItems ();
335+ notifyParentItemsRectChanged ();
336+ mNeedsArrange = false ;
337+ }
311338 // After list building completed, select items that had been requested to select before list was build
312339 updateSelection ();
313340 mRefreshState = REFRESH_COMPLETE;
314341 }
315342 else
316343 {
344+ if (mNeedsArrange && getVisible ())
345+ {
346+ // show changes now
347+ rearrangeItems ();
348+ notifyParentItemsRectChanged ();
349+ mNeedsArrange = false ;
350+ }
317351 mRefreshState = REFRESH_LIST_APPEND;
318352 }
319353 break ;
@@ -347,6 +381,7 @@ void LLInventoryItemsList::computeDifference(
347381
348382LLPanel* LLInventoryItemsList::createNewItem (LLViewerInventoryItem* item)
349383{
384+ LL_PROFILE_ZONE_SCOPED;
350385 if (!item)
351386 {
352387 LL_WARNS () << " No inventory item. Couldn't create flat list item." << LL_ENDL;
0 commit comments