EXP-1065 FIX -- Inventory has slowed to a crawl. Clicking between items has an average one second delay. Same with switching between tabs.

* Removed numerous places in the code that called findChild across the inventory panel unnecessarily.
* Conglomerated uses of inbox and outbox inventory panels to the sidepanel class so the pointers can be cached and functionality like selection handling can be done more efficiently.
* Optimized LLView::childHasKeyboardFocus() to work backwards up from the focus object rather than searching for children that may or may not turn out to have focus.

Reviewed by Richard.
Leslie Linden 2011-08-08 15:13:53 -07:00
parent 7ea93d2756
commit a3298c978c
11 changed files with 132 additions and 114 deletions

View File

@ -1655,15 +1655,19 @@ BOOL LLView::hasAncestor(const LLView* parentp) const
BOOL LLView::childHasKeyboardFocus( const std::string& childname ) const
{
LLView *child = findChildView(childname, TRUE);
if (child)
LLView *focus = dynamic_cast<LLView *>(gFocusMgr.getKeyboardFocus());
while (focus != NULL)
{
return gFocusMgr.childHasKeyboardFocus(child);
}
else
{
return FALSE;
if (focus->getName() == childname)
{
return TRUE;
}
focus = focus->getParent();
}
return FALSE;
}
//-----------------------------------------------------------------------------

View File

@ -860,12 +860,8 @@ std::set<LLUUID> LLAvatarActions::getInventorySelectedUUIDs()
if (inventory_selected_uuids.empty())
{
LLSidepanelInventory * sidepanel_inventory = LLSideTray::getInstance()->getPanel<LLSidepanelInventory>("sidepanel_inventory");
LLInventoryPanel * inbox = sidepanel_inventory->findChild<LLInventoryPanel>("inventory_inbox");
if (inbox)
{
inventory_selected_uuids = inbox->getRootFolder()->getSelectionList();
}
inventory_selected_uuids = sidepanel_inventory->getInboxOrOutboxSelectionList();
}
return inventory_selected_uuids;

View File

@ -241,16 +241,19 @@ const LLUUID LLFloaterWorldMap::sHomeID( "10000000-0000-0000-0000-000000000001"
LLFloaterWorldMap::LLFloaterWorldMap(const LLSD& key)
: LLFloater(key),
mInventory(NULL),
mInventoryObserver(NULL),
mFriendObserver(NULL),
mCompletingRegionName(),
mCompletingRegionPos(),
mWaitingForTracker(FALSE),
mIsClosing(FALSE),
mSetToUserPosition(TRUE),
mTrackedLocation(0,0,0),
mTrackedStatus(LLTracker::TRACKING_NOTHING)
mInventory(NULL),
mInventoryObserver(NULL),
mFriendObserver(NULL),
mCompletingRegionName(),
mCompletingRegionPos(),
mWaitingForTracker(FALSE),
mIsClosing(FALSE),
mSetToUserPosition(TRUE),
mTrackedLocation(0,0,0),
mTrackedStatus(LLTracker::TRACKING_NOTHING),
mListFriendCombo(NULL),
mListLandmarkCombo(NULL),
mListSearchResults(NULL)
{
gFloaterWorldMap = this;
@ -285,17 +288,20 @@ BOOL LLFloaterWorldMap::postBuild()
avatar_combo->selectFirstItem();
avatar_combo->setPrearrangeCallback( boost::bind(&LLFloaterWorldMap::onAvatarComboPrearrange, this) );
avatar_combo->setTextEntryCallback( boost::bind(&LLFloaterWorldMap::onComboTextEntry, this) );
mListFriendCombo = dynamic_cast<LLCtrlListInterface *>(avatar_combo);
LLSearchEditor *location_editor = getChild<LLSearchEditor>("location");
location_editor->setFocusChangedCallback(boost::bind(&LLFloaterWorldMap::onLocationFocusChanged, this, _1));
location_editor->setKeystrokeCallback( boost::bind(&LLFloaterWorldMap::onSearchTextEntry, this));
getChild<LLScrollListCtrl>("search_results")->setDoubleClickCallback( boost::bind(&LLFloaterWorldMap::onClickTeleportBtn, this));
mListSearchResults = childGetListInterface("search_results");
LLComboBox *landmark_combo = getChild<LLComboBox>( "landmark combo");
landmark_combo->selectFirstItem();
landmark_combo->setPrearrangeCallback( boost::bind(&LLFloaterWorldMap::onLandmarkComboPrearrange, this) );
landmark_combo->setTextEntryCallback( boost::bind(&LLFloaterWorldMap::onComboTextEntry, this) );
mListLandmarkCombo = dynamic_cast<LLCtrlListInterface *>(landmark_combo);
mCurZoomVal = log(LLWorldMapView::sMapScale)/log(2.f);
getChild<LLUICtrl>("zoom slider")->setValue(LLWorldMapView::sMapScale);
@ -884,7 +890,7 @@ void LLFloaterWorldMap::friendsChanged()
// No longer really builds a list. Instead, just updates mAvatarCombo.
void LLFloaterWorldMap::buildAvatarIDList()
{
LLCtrlListInterface *list = childGetListInterface("friend combo");
LLCtrlListInterface *list = mListFriendCombo;
if (!list) return;
// Delete all but the "None" entry
@ -914,7 +920,7 @@ void LLFloaterWorldMap::buildAvatarIDList()
void LLFloaterWorldMap::buildLandmarkIDLists()
{
LLCtrlListInterface *list = childGetListInterface("landmark combo");
LLCtrlListInterface *list = mListLandmarkCombo;
if (!list) return;
// Delete all but the "None" entry
@ -992,7 +998,7 @@ F32 LLFloaterWorldMap::getDistanceToDestination(const LLVector3d &destination,
void LLFloaterWorldMap::clearLocationSelection(BOOL clear_ui)
{
LLCtrlListInterface *list = childGetListInterface("search_results");
LLCtrlListInterface *list = mListSearchResults;
if (list)
{
list->operateOnAll(LLCtrlListInterface::OP_DELETE);
@ -1006,7 +1012,7 @@ void LLFloaterWorldMap::clearLandmarkSelection(BOOL clear_ui)
{
if (clear_ui || !childHasKeyboardFocus("landmark combo"))
{
LLCtrlListInterface *list = childGetListInterface("landmark combo");
LLCtrlListInterface *list = mListLandmarkCombo;
if (list)
{
list->selectByValue( "None" );
@ -1020,7 +1026,7 @@ void LLFloaterWorldMap::clearAvatarSelection(BOOL clear_ui)
if (clear_ui || !childHasKeyboardFocus("friend combo"))
{
mTrackedStatus = LLTracker::TRACKING_NOTHING;
LLCtrlListInterface *list = childGetListInterface("friend combo");
LLCtrlListInterface *list = mListFriendCombo;
if (list)
{
list->selectByValue( "None" );
@ -1088,7 +1094,7 @@ void LLFloaterWorldMap::onLandmarkComboPrearrange( )
return;
}
LLCtrlListInterface *list = childGetListInterface("landmark combo");
LLCtrlListInterface *list = mListLandmarkCombo;
if (!list) return;
LLUUID current_choice = list->getCurrentID();
@ -1124,7 +1130,7 @@ void LLFloaterWorldMap::onLandmarkComboCommit()
return;
}
LLCtrlListInterface *list = childGetListInterface("landmark combo");
LLCtrlListInterface *list = mListLandmarkCombo;
if (!list) return;
LLUUID asset_id;
@ -1171,7 +1177,7 @@ void LLFloaterWorldMap::onAvatarComboPrearrange( )
return;
}
LLCtrlListInterface *list = childGetListInterface("friend combo");
LLCtrlListInterface *list = mListFriendCombo;
if (!list) return;
LLUUID current_choice;
@ -1196,7 +1202,7 @@ void LLFloaterWorldMap::onAvatarComboCommit()
return;
}
LLCtrlListInterface *list = childGetListInterface("friend combo");
LLCtrlListInterface *list = mListFriendCombo;
if (!list) return;
const LLUUID& new_avatar_id = list->getCurrentID();
@ -1593,7 +1599,7 @@ void LLFloaterWorldMap::updateSims(bool found_null_sim)
void LLFloaterWorldMap::onCommitSearchResult()
{
LLCtrlListInterface *list = childGetListInterface("search_results");
LLCtrlListInterface *list = mListSearchResults;
if (!list) return;
LLSD selected_value = list->getSelectedValue();

View File

@ -39,6 +39,7 @@
#include "lltracker.h"
#include "llslurl.h"
class LLCtrlListInterface;
class LLFriendObserver;
class LLInventoryModel;
class LLInventoryObserver;
@ -190,6 +191,10 @@ private:
std::string mTrackedSimName;
std::string mTrackedAvatarName;
LLSLURL mSLURL;
LLCtrlListInterface * mListFriendCombo;
LLCtrlListInterface * mListLandmarkCombo;
LLCtrlListInterface * mListSearchResults;
};
extern LLFloaterWorldMap* gFloaterWorldMap;

View File

@ -622,28 +622,16 @@ void LLPanelMainInventory::updateItemcountText()
{
text = getString("ItemcountUnknown");
}
// *TODO: Cache the LLUICtrl* for the ItemcountText control
getChild<LLUICtrl>("ItemcountText")->setValue(text);
}
void LLPanelMainInventory::onFocusReceived()
{
LLSidepanelInventory * sidepanel_inventory = LLSideTray::getInstance()->getPanel<LLSidepanelInventory>("sidepanel_inventory");
LLInventoryPanel * inbox_panel = sidepanel_inventory->findChild<LLInventoryPanel>("inventory_inbox");
if (inbox_panel)
{
inbox_panel->clearSelection();
}
LLInventoryPanel * outbox_panel = sidepanel_inventory->findChild<LLInventoryPanel>("inventory_outbox");
if (outbox_panel)
{
outbox_panel->clearSelection();
}
sidepanel_inventory->updateVerbs();
sidepanel_inventory->clearSelections(false, true, true);
}
void LLPanelMainInventory::setFilterTextFromFilter()

View File

@ -83,7 +83,7 @@ void LLPanelMarketplaceInbox::handleLoginComplete()
LLSideTray::getInstance()->setTabButtonBadgeDriver("sidebar_inventory", this);
}
void LLPanelMarketplaceInbox::setupInventoryPanel()
LLInventoryPanel * LLPanelMarketplaceInbox::setupInventoryPanel()
{
LLView * inbox_inventory_placeholder = getChild<LLView>("inbox_inventory_placeholder");
LLView * inbox_inventory_parent = inbox_inventory_placeholder->getParent();
@ -106,30 +106,15 @@ void LLPanelMarketplaceInbox::setupInventoryPanel()
// Hide the placeholder text
inbox_inventory_placeholder->setVisible(FALSE);
return mInventoryPanel;
}
void LLPanelMarketplaceInbox::onFocusReceived()
{
LLSidepanelInventory * sidepanel_inventory = LLSideTray::getInstance()->getPanel<LLSidepanelInventory>("sidepanel_inventory");
if (sidepanel_inventory)
{
LLInventoryPanel * inv_panel = sidepanel_inventory->getActivePanel();
if (inv_panel)
{
inv_panel->clearSelection();
}
LLInventoryPanel * outbox_panel = sidepanel_inventory->findChild<LLInventoryPanel>("inventory_outbox");
if (outbox_panel)
{
outbox_panel->clearSelection();
}
sidepanel_inventory->updateVerbs();
}
sidepanel_inventory->clearSelections(true, false, true);
}
BOOL LLPanelMarketplaceInbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, std::string& tooltip_msg)

View File

@ -55,7 +55,7 @@ public:
/*virtual*/ void draw();
void setupInventoryPanel();
LLInventoryPanel * setupInventoryPanel();
U32 getFreshItemCount() const;
U32 getTotalItemCount() const;

View File

@ -83,25 +83,8 @@ void LLPanelMarketplaceOutbox::handleLoginComplete()
void LLPanelMarketplaceOutbox::onFocusReceived()
{
LLSidepanelInventory * sidepanel_inventory = LLSideTray::getInstance()->getPanel<LLSidepanelInventory>("sidepanel_inventory");
if (sidepanel_inventory)
{
LLInventoryPanel * inv_panel = sidepanel_inventory->getActivePanel();
if (inv_panel)
{
inv_panel->clearSelection();
}
LLInventoryPanel * inbox_panel = sidepanel_inventory->findChild<LLInventoryPanel>("inventory_inbox");
if (inbox_panel)
{
inbox_panel->clearSelection();
}
sidepanel_inventory->updateVerbs();
}
sidepanel_inventory->clearSelections(true, true, false);
}
void LLPanelMarketplaceOutbox::onSelectionChange()
@ -111,7 +94,7 @@ void LLPanelMarketplaceOutbox::onSelectionChange()
sidepanel_inventory->updateVerbs();
}
void LLPanelMarketplaceOutbox::setupInventoryPanel()
LLInventoryPanel * LLPanelMarketplaceOutbox::setupInventoryPanel()
{
LLView * outbox_inventory_placeholder = getChild<LLView>("outbox_inventory_placeholder");
LLView * outbox_inventory_parent = outbox_inventory_placeholder->getParent();
@ -134,6 +117,8 @@ void LLPanelMarketplaceOutbox::setupInventoryPanel()
// Hide the placeholder text
outbox_inventory_placeholder->setVisible(FALSE);
return mInventoryPanel;
}
bool LLPanelMarketplaceOutbox::isOutboxEmpty() const

View File

@ -54,7 +54,7 @@ public:
/*virtual*/ BOOL postBuild();
void setupInventoryPanel();
LLInventoryPanel * setupInventoryPanel();
bool isOutboxEmpty() const;
bool isSyncInProgress() const;

View File

@ -133,6 +133,8 @@ private:
LLSidepanelInventory::LLSidepanelInventory()
: LLPanel()
, mItemPanel(NULL)
, mInventoryPanelInbox(NULL)
, mInventoryPanelOutbox(NULL)
, mPanelMainInventory(NULL)
, mInboxEnabled(false)
, mOutboxEnabled(false)
@ -352,7 +354,7 @@ void LLSidepanelInventory::observeInboxModifications(const LLUUID& inboxID)
//
LLPanelMarketplaceInbox * inbox = getChild<LLPanelMarketplaceInbox>(MARKETPLACE_INBOX_PANEL);
inbox->setupInventoryPanel();
mInventoryPanelInbox = inbox->setupInventoryPanel();
}
@ -381,7 +383,7 @@ void LLSidepanelInventory::observeOutboxModifications(const LLUUID& outboxID)
//
LLPanelMarketplaceOutbox * outbox = getChild<LLPanelMarketplaceOutbox>(MARKETPLACE_OUTBOX_PANEL);
outbox->setupInventoryPanel();
mInventoryPanelOutbox = outbox->setupInventoryPanel();
}
void LLSidepanelInventory::enableInbox(bool enabled)
@ -535,14 +537,12 @@ void LLSidepanelInventory::onShopButtonClicked()
void LLSidepanelInventory::performActionOnSelection(const std::string &action)
{
LLPanelMainInventory *panel_main_inventory = mInventoryPanel->getChild<LLPanelMainInventory>("panel_main_inventory");
LLFolderViewItem* current_item = panel_main_inventory->getActivePanel()->getRootFolder()->getCurSelectedItem();
LLFolderViewItem* current_item = mPanelMainInventory->getActivePanel()->getRootFolder()->getCurSelectedItem();
if (!current_item)
{
LLInventoryPanel* inbox = findChild<LLInventoryPanel>("inventory_inbox");
if (inbox)
if (mInventoryPanelInbox)
{
current_item = inbox->getRootFolder()->getCurSelectedItem();
current_item = mInventoryPanelInbox->getRootFolder()->getCurSelectedItem();
}
if (!current_item)
@ -551,7 +551,7 @@ void LLSidepanelInventory::performActionOnSelection(const std::string &action)
}
}
current_item->getListener()->performAction(panel_main_inventory->getActivePanel()->getModel(), action);
current_item->getListener()->performAction(mPanelMainInventory->getActivePanel()->getModel(), action);
}
void LLSidepanelInventory::onWearButtonClicked()
@ -693,19 +693,16 @@ void LLSidepanelInventory::updateVerbs()
bool LLSidepanelInventory::canShare()
{
LLPanelMainInventory* panel_main_inventory =
mInventoryPanel->findChild<LLPanelMainInventory>("panel_main_inventory");
LLInventoryPanel* inbox = findChild<LLInventoryPanel>("inventory_inbox");
LLInventoryPanel* inbox = mInventoryPanelInbox;
// Avoid flicker in the Recent tab while inventory is being loaded.
if ( (!inbox || inbox->getRootFolder()->getSelectionList().empty())
&& (panel_main_inventory && !panel_main_inventory->getActivePanel()->getRootFolder()->hasVisibleChildren()) )
&& (mPanelMainInventory && !mPanelMainInventory->getActivePanel()->getRootFolder()->hasVisibleChildren()) )
{
return false;
}
return ( (panel_main_inventory ? LLAvatarActions::canShareSelectedItems(panel_main_inventory->getActivePanel()) : false)
return ( (mPanelMainInventory ? LLAvatarActions::canShareSelectedItems(mPanelMainInventory->getActivePanel()) : false)
|| (inbox ? LLAvatarActions::canShareSelectedItems(inbox) : false) );
}
@ -730,14 +727,13 @@ bool LLSidepanelInventory::canWearSelected()
LLInventoryItem *LLSidepanelInventory::getSelectedItem()
{
LLPanelMainInventory *panel_main_inventory = mInventoryPanel->getChild<LLPanelMainInventory>("panel_main_inventory");
LLFolderViewItem* current_item = panel_main_inventory->getActivePanel()->getRootFolder()->getCurSelectedItem();
LLFolderViewItem* current_item = mPanelMainInventory->getActivePanel()->getRootFolder()->getCurSelectedItem();
if (!current_item)
{
LLInventoryPanel* inbox = findChild<LLInventoryPanel>("inventory_inbox");
if (inbox)
if (mInventoryPanelInbox)
{
current_item = inbox->getRootFolder()->getCurSelectedItem();
current_item = mInventoryPanelInbox->getRootFolder()->getCurSelectedItem();
}
if (!current_item)
@ -754,14 +750,20 @@ U32 LLSidepanelInventory::getSelectedCount()
{
int count = 0;
LLPanelMainInventory *panel_main_inventory = mInventoryPanel->getChild<LLPanelMainInventory>("panel_main_inventory");
std::set<LLUUID> selection_list = panel_main_inventory->getActivePanel()->getRootFolder()->getSelectionList();
std::set<LLUUID> selection_list = mPanelMainInventory->getActivePanel()->getRootFolder()->getSelectionList();
count += selection_list.size();
LLInventoryPanel* inbox = findChild<LLInventoryPanel>("inventory_inbox");
if (inbox)
if ((count == 0) && mInboxEnabled && (mInventoryPanelInbox != NULL))
{
selection_list = inbox->getRootFolder()->getSelectionList();
selection_list = mInventoryPanelInbox->getRootFolder()->getSelectionList();
count += selection_list.size();
}
if ((count == 0) && mOutboxEnabled && (mInventoryPanelOutbox != NULL))
{
selection_list = mInventoryPanelOutbox->getRootFolder()->getSelectionList();
count += selection_list.size();
}
@ -785,3 +787,45 @@ BOOL LLSidepanelInventory::isMainInventoryPanelActive() const
{
return mInventoryPanel->getVisible();
}
void LLSidepanelInventory::clearSelections(bool clearMain, bool clearInbox, bool clearOutbox)
{
if (clearMain)
{
LLInventoryPanel * inv_panel = getActivePanel();
if (inv_panel)
{
inv_panel->clearSelection();
}
}
if (clearInbox && mInboxEnabled && (mInventoryPanelInbox != NULL))
{
mInventoryPanelInbox->clearSelection();
}
if (clearOutbox && mOutboxEnabled && (mInventoryPanelOutbox != NULL))
{
mInventoryPanelOutbox->clearSelection();
}
updateVerbs();
}
std::set<LLUUID> LLSidepanelInventory::getInboxOrOutboxSelectionList()
{
std::set<LLUUID> inventory_selected_uuids;
if (mInboxEnabled && (mInventoryPanelInbox != NULL))
{
inventory_selected_uuids = mInventoryPanelInbox->getRootFolder()->getSelectionList();
}
if (inventory_selected_uuids.empty() && mOutboxEnabled && (mInventoryPanelOutbox != NULL))
{
inventory_selected_uuids = mInventoryPanelOutbox->getRootFolder()->getSelectionList();
}
return inventory_selected_uuids;
}

View File

@ -58,6 +58,9 @@ public:
LLInventoryPanel* getActivePanel(); // Returns an active inventory panel, if any.
LLPanelMainInventory* getMainInventoryPanel() const { return mPanelMainInventory; }
BOOL isMainInventoryPanelActive() const;
void clearSelections(bool clearMain, bool clearInbox, bool clearOutbox);
std::set<LLUUID> getInboxOrOutboxSelectionList();
void showItemInfoPanel();
void showTaskInfoPanel();
@ -95,6 +98,8 @@ protected:
//
private:
LLPanel* mInventoryPanel; // Main inventory view
LLInventoryPanel* mInventoryPanelInbox;
LLInventoryPanel* mInventoryPanelOutbox;
LLSidepanelItemInfo* mItemPanel; // Individual item view
LLSidepanelTaskInfo* mTaskPanel; // Individual in-world object view
LLPanelMainInventory* mPanelMainInventory;