From b6225d1d9abc2fa180ef69dd5ea1ad8f08a0b26e Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Thu, 6 Feb 2014 14:51:36 -0500 Subject: [PATCH] [MAINT-2287] Handle refactor --- indra/newview/llfloateroutbox.cpp | 63 ++++---- indra/newview/llfloateroutbox.h | 2 +- indra/newview/llfolderview.cpp | 27 ++-- indra/newview/llfolderview.h | 7 +- indra/newview/llinventorymodel.cpp | 19 +-- indra/newview/llinventorypanel.cpp | 148 ++++++++++-------- indra/newview/llinventorypanel.h | 11 +- .../llpanelmarketplaceoutboxinventory.cpp | 6 +- 8 files changed, 151 insertions(+), 132 deletions(-) diff --git a/indra/newview/llfloateroutbox.cpp b/indra/newview/llfloateroutbox.cpp index 07b626de9..64baf95ff 100644 --- a/indra/newview/llfloateroutbox.cpp +++ b/indra/newview/llfloateroutbox.cpp @@ -111,7 +111,6 @@ LLFloaterOutbox::LLFloaterOutbox(const LLSD& key) , mInventoryText(NULL) , mInventoryTitle(NULL) , mOutboxId(LLUUID::null) - , mOutboxInventoryPanel(NULL) , mOutboxItemCount(0) , mOutboxTopLevelDropZone(NULL) // , mWindowShade(NULL) @@ -149,11 +148,10 @@ BOOL LLFloaterOutbox::postBuild() mImportButton = getChild("outbox_import_btn"); mImportButton->setCommitCallback(boost::bind(&LLFloaterOutbox::onImportButtonClicked, this)); - // // Set up the outbox inventory view - // - mOutboxInventoryPanel = getChild("panel_outbox_inventory"); - llassert(mOutboxInventoryPanel); + LLInventoryPanel* inventory_panel = getChild("panel_outbox_inventory"); + mOutboxInventoryPanel = inventory_panel->getInventoryPanelHandle(); + llassert(mOutboxInventoryPanel.get() != NULL); mOutboxTopLevelDropZone = getChild("outbox_generic_drag_target"); @@ -256,14 +254,15 @@ void LLFloaterOutbox::setupOutbox() // Set up the outbox inventory view // Singu Note: we handle this in postBuild, grabbing the panel from the built xml. + LLInventoryPanel* inventory_panel = mOutboxInventoryPanel.get(); // Reshape the inventory to the proper size LLRect inventory_placeholder_rect = mInventoryPlaceholder->getRect(); - mOutboxInventoryPanel->setShape(inventory_placeholder_rect); + inventory_panel->setShape(inventory_placeholder_rect); // Set the sort order newest to oldest - mOutboxInventoryPanel->setSortOrder(LLInventoryFilter::SO_FOLDERS_BY_NAME); - mOutboxInventoryPanel->getFilter()->markDefault(); + inventory_panel->setSortOrder(LLInventoryFilter::SO_FOLDERS_BY_NAME); + inventory_panel->getFilter()->markDefault(); // Get the content of the outbox fetchOutboxContents(); @@ -292,19 +291,22 @@ void LLFloaterOutbox::setStatusString(const std::string& statusString) void LLFloaterOutbox::updateFolderCount() { - S32 item_count = 0; - - if (mOutboxId.notNull()) + if (mOutboxInventoryPanel.get() && mOutboxId.notNull()) { - LLInventoryModel::cat_array_t * cats; - LLInventoryModel::item_array_t * items; - gInventory.getDirectDescendentsOf(mOutboxId, cats, items); + S32 item_count = 0; - item_count = cats->count() + items->count(); + if (mOutboxId.notNull()) + { + LLInventoryModel::cat_array_t * cats; + LLInventoryModel::item_array_t * items; + gInventory.getDirectDescendentsOf(mOutboxId, cats, items); + + item_count = cats->count() + items->count(); + } + + mOutboxItemCount = item_count; } - mOutboxItemCount = item_count; - if (!mImportBusy) { updateFolderCountStatus(); @@ -313,7 +315,7 @@ void LLFloaterOutbox::updateFolderCount() void LLFloaterOutbox::updateFolderCountStatus() { - if (mOutboxInventoryPanel) + if (mOutboxInventoryPanel.get() && mOutboxId.notNull()) { switch (mOutboxItemCount) { @@ -339,18 +341,19 @@ void LLFloaterOutbox::updateView() { //updateView() is called twice the first time. updateFolderCount(); + LLInventoryPanel* panel = mOutboxInventoryPanel.get(); if (mOutboxItemCount > 0) { - mOutboxInventoryPanel->setVisible(TRUE); + panel->setVisible(TRUE); mInventoryPlaceholder->setVisible(FALSE); mOutboxTopLevelDropZone->setVisible(TRUE); } else { - if (mOutboxInventoryPanel) + if (panel) { - mOutboxInventoryPanel->setVisible(FALSE); + panel->setVisible(FALSE); } // Show the drop zone if there is an outbox folder @@ -436,7 +439,7 @@ BOOL LLFloaterOutbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EAcceptance* accept, std::string& tooltip_msg) { - if ((mOutboxInventoryPanel == NULL) || + if ((mOutboxInventoryPanel.get() == NULL) || //(mWindowShade && mWindowShade->isShown()) || LLMarketplaceInventoryImporter::getInstance()->isImportInProgress()) { @@ -449,15 +452,16 @@ BOOL LLFloaterOutbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, // Determine if the mouse is inside the inventory panel itself or just within the floater bool pointInInventoryPanel = false; bool pointInInventoryPanelChild = false; - LLFolderView * root_folder = mOutboxInventoryPanel->getRootFolder(); - if (mOutboxInventoryPanel->getVisible()) + LLInventoryPanel* panel = mOutboxInventoryPanel.get(); + LLFolderView * root_folder = panel->getRootFolder(); + if (panel->getVisible()) { S32 inv_x, inv_y; - localPointToOtherView(x, y, &inv_x, &inv_y, mOutboxInventoryPanel); + localPointToOtherView(x, y, &inv_x, &inv_y, panel); - pointInInventoryPanel = mOutboxInventoryPanel->getRect().pointInRect(inv_x, inv_y); + pointInInventoryPanel = panel->getRect().pointInRect(inv_x, inv_y); - LLView * inventory_panel_child_at_point = mOutboxInventoryPanel->childFromPoint(inv_x, inv_y, true); + LLView * inventory_panel_child_at_point = panel->childFromPoint(inv_x, inv_y, true); pointInInventoryPanelChild = (inventory_panel_child_at_point != root_folder); } @@ -497,7 +501,10 @@ void LLFloaterOutbox::onMouseLeave(S32 x, S32 y, MASK mask) */ void LLFloaterOutbox::onImportButtonClicked() { - mOutboxInventoryPanel->clearSelection(); + if (mOutboxInventoryPanel.get()) + { + mOutboxInventoryPanel.get()->clearSelection(); + } mImportBusy = LLMarketplaceInventoryImporter::instance().triggerImport(); } diff --git a/indra/newview/llfloateroutbox.h b/indra/newview/llfloateroutbox.h index 9f9222cb6..c48ddb561 100644 --- a/indra/newview/llfloateroutbox.h +++ b/indra/newview/llfloateroutbox.h @@ -106,7 +106,7 @@ private: LLTextBox * mInventoryTitle; LLUUID mOutboxId; - LLInventoryPanel * mOutboxInventoryPanel; + LLHandle mOutboxInventoryPanel; U32 mOutboxItemCount; LLPanel * mOutboxTopLevelDropZone; diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index 4b6142a39..7494e9b90 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -176,7 +176,7 @@ void LLCloseAllFoldersFunctor::doItem(LLFolderViewItem* item) // Default constructor LLFolderView::LLFolderView( const std::string& name, - const LLRect& rect, const LLUUID& source_id, LLPanel *parent_view, LLFolderViewEventListener* listener ) : + const LLRect& rect, const LLUUID& source_id, LLPanel* parent_panel, LLFolderViewEventListener* listener ) : #if LL_WINDOWS #pragma warning( push ) #pragma warning( disable : 4355 ) // warning C4355: 'this' : used in base member initializer list @@ -208,12 +208,13 @@ LLFolderView::LLFolderView( const std::string& name, mSignalSelectCallback(0), mMinWidth(0), mDragAndDropThisFrame(FALSE), - mParentPanel(parent_view), mUseEllipses(FALSE), mDraggingOverItem(NULL), mStatusTextBox(NULL), mSearchType(1) { + LLPanel* panel = parent_panel; + mParentPanel = panel->getHandle(); mRoot = this; mShowLoadStatus = TRUE; @@ -256,7 +257,7 @@ LLFolderView::LLFolderView( const std::string& name, mStatusTextBox->setVPad(STATUS_TEXT_VPAD); mStatusTextBox->setFollows(FOLLOWS_LEFT|FOLLOWS_TOP); // make the popup menu available - LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_inventory.xml", parent_view); + LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_inventory.xml", parent_panel); if (!menu) { menu = new LLMenuGL(LLStringUtil::null); @@ -645,7 +646,7 @@ BOOL LLFolderView::setSelection(LLFolderViewItem* selection, BOOL openitem, if( selection && take_keyboard_focus) { - mParentPanel->setFocus(TRUE); + mParentPanel.get()->setFocus(TRUE); } // clear selection down here because change of keyboard focus can potentially @@ -1110,11 +1111,11 @@ void LLFolderView::removeSelectedItems( void ) // change selection on successful delete if (new_selection) { - setSelectionFromRoot(new_selection, new_selection->isOpen(), mParentPanel->hasFocus()); + setSelectionFromRoot(new_selection, new_selection->isOpen(), mParentPanel.get()->hasFocus()); } else { - setSelectionFromRoot(NULL, mParentPanel->hasFocus()); + setSelectionFromRoot(NULL, mParentPanel.get()->hasFocus()); } } } @@ -1140,11 +1141,11 @@ void LLFolderView::removeSelectedItems( void ) } if (new_selection) { - setSelectionFromRoot(new_selection, new_selection->isOpen(), mParentPanel->hasFocus()); + setSelectionFromRoot(new_selection, new_selection->isOpen(), mParentPanel.get()->hasFocus()); } else { - setSelectionFromRoot(NULL, mParentPanel->hasFocus()); + setSelectionFromRoot(NULL, mParentPanel.get()->hasFocus()); } for(S32 i = 0; i < count; ++i) @@ -1715,7 +1716,7 @@ BOOL LLFolderView::handleKeyHere( KEY key, MASK mask ) break; } - if (!handled && mParentPanel->hasFocus()) + if (!handled && mParentPanel.get()->hasFocus()) { if (key == KEY_BACKSPACE) { @@ -1747,7 +1748,7 @@ BOOL LLFolderView::handleUnicodeCharHere(llwchar uni_char) } BOOL handled = FALSE; - if (mParentPanel->hasFocus()) + if (mParentPanel.get()->hasFocus()) { // SL-51858: Key presses are not being passed to the Popup menu. // A proper fix is non-trivial so instead just close the menu. @@ -1804,7 +1805,7 @@ BOOL LLFolderView::handleMouseDown( S32 x, S32 y, MASK mask ) mKeyboardSelection = FALSE; mSearchString.clear(); - mParentPanel->setFocus(TRUE); + mParentPanel.get()->setFocus(TRUE); LLEditMenuHandler::gEditMenuHandler = this; @@ -1887,7 +1888,7 @@ BOOL LLFolderView::handleRightMouseDown( S32 x, S32 y, MASK mask ) { // all user operations move keyboard focus to inventory // this way, we know when to stop auto-updating a search - mParentPanel->setFocus(TRUE); + mParentPanel.get()->setFocus(TRUE); BOOL handled = childrenHandleRightMouseDown(x, y, mask) != NULL; S32 count = mSelectedItems.size(); @@ -2157,7 +2158,7 @@ void LLFolderView::doIdle() { // If this is associated with the user's inventory, don't do anything // until that inventory is loaded up. - const LLInventoryPanel *inventory_panel = dynamic_cast(mParentPanel); + const LLInventoryPanel *inventory_panel = dynamic_cast(mParentPanel.get()); if (inventory_panel && !inventory_panel->getIsViewsInitialized()) { return; diff --git a/indra/newview/llfolderview.h b/indra/newview/llfolderview.h index f441e8995..bf89339de 100644 --- a/indra/newview/llfolderview.h +++ b/indra/newview/llfolderview.h @@ -244,7 +244,7 @@ public: BOOL getDebugFilters() { return mDebugFilters; } - LLPanel* getParentPanel() { return mParentPanel; } + LLPanel* getParentPanel() { return mParentPanel.get(); } // DEBUG only void dumpSelectionInformation(); @@ -253,6 +253,9 @@ public: bool useLabelSuffix() { return mUseLabelSuffix; } void updateMenu(); + // Note: We may eventually have to move that method up the hierarchy to LLFolderViewItem. + LLHandle getHandle() const { return getDerivedHandle(); } + private: void updateMenuOptions(LLMenuGL* menu); void updateRenamerPosition(); @@ -317,7 +320,7 @@ protected: LLUUID mSelectThisID; // if non null, select this item - LLPanel* mParentPanel; + LLHandle mParentPanel; /** * Is used to determine if we need to cut text In LLFolderViewItem to avoid horizontal scroll. diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index e36753bfe..ddfb151a6 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -409,12 +409,11 @@ void LLInventoryModel::unlockDirectDescendentArrays(const LLUUID& cat_id) // specifies 'type' as what it defaults to containing. The category is // not necessarily only for that type. *NOTE: This will create a new // inventory category on the fly if one does not exist. -const LLUUID LLInventoryModel::findCategoryUUIDForType(LLFolderType::EType preferred_type, - bool create_folder, +const LLUUID LLInventoryModel::findCategoryUUIDForType(LLFolderType::EType preferred_type, + bool create_folder, bool find_in_library) { LLUUID rv = LLUUID::null; - const LLUUID &root_id = (find_in_library) ? gInventory.getLibraryRootFolderID() : gInventory.getRootFolderID(); if(LLFolderType::FT_ROOT_INVENTORY == preferred_type) { @@ -429,7 +428,7 @@ const LLUUID LLInventoryModel::findCategoryUUIDForType(LLFolderType::EType prefe S32 count = cats->count(); for(S32 i = 0; i < count; ++i) { - if(cats->get(i)->getPreferredType() == preferred_type) + if (cats->get(i)->getPreferredType() == preferred_type) { rv = cats->get(i)->getUUID(); break; @@ -611,7 +610,7 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, return id; } -// Starting with the object specified, add it's descendents to the +// Starting with the object specified, add its descendents to the // array provided, but do not add the inventory object specified by // id. There is no guaranteed order. Neither array will be erased // before adding objects to it. Do not store a copy of the pointers @@ -1038,7 +1037,7 @@ void LLInventoryModel::updateCategory(const LLViewerInventoryCategory* cat) new_cat->copyViewerCategory(cat); addCategory(new_cat); - // make sure this category is correctly referenced by it's parent. + // make sure this category is correctly referenced by its parent. cat_array_t* cat_array; cat_array = getUnlockedCatArray(cat->getParentUUID()); if(cat_array) @@ -1247,12 +1246,6 @@ void LLInventoryModel::updateLinkedObjectsFromPurge(const LLUUID &baseobj_id) // folders, items, etc in a fairly efficient manner. void LLInventoryModel::purgeDescendentsOf(const LLUUID& id) { - EHasChildren children = categoryHasChildren(id); - if(children == CHILDREN_NO) - { - llinfos << "Not purging descendents of " << id << llendl; - return; - } LLPointer cat = getCategory(id); if (cat.notNull()) { @@ -1263,7 +1256,7 @@ void LLInventoryModel::purgeDescendentsOf(const LLUUID& id) << " iterate and purge non hidden items" << llendl; cat_array_t* categories; item_array_t* items; - // Get the list of direct descendants in tha categoy passed as argument + // Get the list of direct descendants in that category passed as argument getDirectDescendentsOf(id, categories, items); std::vector list_uuids; // Make a unique list with all the UUIDs of the direct descendants (items and categories are not treated differently) diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 6d8793a4d..7a7c9b147 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -139,7 +139,6 @@ LLInventoryPanel::LLInventoryPanel(const std::string& name, LLPanel(name, rect, TRUE), mInventoryObserver(NULL), mCompletionObserver(NULL), - mFolderRoot(NULL), mScroller(NULL), mSortOrderSetting(sort_order_setting), mStartFolder(start_folder), @@ -191,7 +190,8 @@ void LLInventoryPanel::buildFolderView() NULL, root_id); - mFolderRoot = createFolderView(new_listener, true/*params.use_label_suffix()*/); + LLFolderView* folder_view = createFolderView(new_listener, true/*params.use_label_suffix()*/); + mFolderRoot = folder_view->getHandle(); } BOOL LLInventoryPanel::postBuild() { @@ -199,16 +199,16 @@ BOOL LLInventoryPanel::postBuild() buildFolderView(); { - // scroller + // Scroller LLRect scroller_view_rect = getRect(); scroller_view_rect.translate(-scroller_view_rect.mLeft, -scroller_view_rect.mBottom); mScroller = new LLScrollContainer(std::string("Inventory Scroller"), scroller_view_rect, - mFolderRoot); + mFolderRoot.get()); mScroller->setFollowsAll(); mScroller->setReserveScrollCorner(TRUE); addChild(mScroller); - mFolderRoot->setScrollContainer(mScroller); + mFolderRoot.get()->setScrollContainer(mScroller); } // Set up the callbacks from the inventory we're viewing, and then build everything. @@ -240,24 +240,42 @@ BOOL LLInventoryPanel::postBuild() LLInventoryPanel::~LLInventoryPanel() { - if (mFolderRoot) + if (mFolderRoot.get()) { - U32 sort_order = mFolderRoot->getSortOrder(); + U32 sort_order = mFolderRoot.get()->getSortOrder(); if (mSortOrderSetting != INHERIT_SORT_ORDER) { gSavedSettings.setU32(mSortOrderSetting, sort_order); } } + clearFolderRoot(); +} + +void LLInventoryPanel::clearFolderRoot() +{ gIdleCallbacks.deleteFunction(onIdle, this); - // LLView destructor will take care of the sub-views. - mInventory->removeObserver(mInventoryObserver); - mInventory->removeObserver(mCompletionObserver); - delete mInventoryObserver; - delete mCompletionObserver; + if (mInventoryObserver) + { + mInventory->removeObserver(mInventoryObserver); + delete mInventoryObserver; + mInventoryObserver = NULL; + } - mScroller = NULL; + if (mCompletionObserver) + { + mInventory->removeObserver(mCompletionObserver); + delete mCompletionObserver; + mCompletionObserver = NULL; + } + + if (mScroller) + { + removeChild(mScroller); + delete mScroller; + mScroller = NULL; + } } // virtual @@ -267,7 +285,7 @@ LLXMLNodePtr LLInventoryPanel::getXML(bool save_children) const node->setName(LL_INVENTORY_PANEL_TAG); - node->createChild("allow_multi_select", TRUE)->setBoolValue(mFolderRoot->getAllowMultiSelect()); + node->createChild("allow_multi_select", TRUE)->setBoolValue(mFolderRoot.get()->getAllowMultiSelect()); return node; } @@ -327,24 +345,24 @@ LLView* LLInventoryPanel::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac void LLInventoryPanel::draw() { // Select the desired item (in case it wasn't loaded when the selection was requested) - mFolderRoot->updateSelection(); + mFolderRoot.get()->updateSelection(); LLPanel::draw(); } LLInventoryFilter* LLInventoryPanel::getFilter() { - if (mFolderRoot) + if (mFolderRoot.get()) { - return mFolderRoot->getFilter(); + return mFolderRoot.get()->getFilter(); } return NULL; } const LLInventoryFilter* LLInventoryPanel::getFilter() const { - if (mFolderRoot) + if (mFolderRoot.get()) { - return mFolderRoot->getFilter(); + return mFolderRoot.get()->getFilter(); } return NULL; } @@ -359,12 +377,12 @@ void LLInventoryPanel::setFilterTypes(U64 types, LLInventoryFilter::EFilterType U32 LLInventoryPanel::getFilterObjectTypes() const { - return mFolderRoot->getFilterObjectTypes(); + return mFolderRoot.get()->getFilterObjectTypes(); } U32 LLInventoryPanel::getFilterPermMask() const { - return mFolderRoot->getFilterPermissions(); + return mFolderRoot.get()->getFilterPermissions(); } @@ -390,7 +408,7 @@ void LLInventoryPanel::setFilterSubString(const std::string& string) const std::string LLInventoryPanel::getFilterSubString() { - return mFolderRoot->getFilterSubString(); + return mFolderRoot.get()->getFilterSubString(); } @@ -399,20 +417,20 @@ void LLInventoryPanel::setSortOrder(U32 order) getFilter()->setSortOrder(order); if (getFilter()->isModified()) { - mFolderRoot->setSortOrder(order); + mFolderRoot.get()->setSortOrder(order); // try to keep selection onscreen, even if it wasn't to start with - mFolderRoot->scrollToShowSelection(); + mFolderRoot.get()->scrollToShowSelection(); } } U32 LLInventoryPanel::getSortOrder() const { - return mFolderRoot->getSortOrder(); + return mFolderRoot.get()->getSortOrder(); } void LLInventoryPanel::requestSort() { - mFolderRoot->requestSort(); + mFolderRoot.get()->requestSort(); } void LLInventoryPanel::setSinceLogoff(BOOL sl) @@ -459,7 +477,7 @@ void LLInventoryPanel::modelChanged(U32 mask) { const LLUUID& item_id = (*items_iter); const LLInventoryObject* model_item = model->getObject(item_id); - LLFolderViewItem* view_item = mFolderRoot->getItemByID(item_id); + LLFolderViewItem* view_item = mFolderRoot.get()->getItemByID(item_id); // LLFolderViewFolder is derived from LLFolderViewItem so dynamic_cast from item // to folder is the fast way to get a folder without searching through folders tree. @@ -548,7 +566,7 @@ void LLInventoryPanel::modelChanged(U32 mask) // Add the UI element for this item. buildNewViews(item_id); // Select any newly created object that has the auto rename at top of folder root set. - if(mFolderRoot->getRoot()->needsAutoRename()) + if(mFolderRoot.get()->getRoot()->needsAutoRename()) { setSelection(item_id, FALSE); } @@ -562,7 +580,7 @@ void LLInventoryPanel::modelChanged(U32 mask) // Don't process the item if it is the root if (view_item->getRoot() != view_item) { - LLFolderViewFolder* new_parent = (LLFolderViewFolder*)mFolderRoot->getItemByID(model_item->getParentUUID()); + LLFolderViewFolder* new_parent = (LLFolderViewFolder*)mFolderRoot.get()->getItemByID(model_item->getParentUUID()); // Item has been moved. if (view_item->getParentFolder() != new_parent) { @@ -570,7 +588,7 @@ void LLInventoryPanel::modelChanged(U32 mask) { // Item is to be moved and we found its new parent in the panel's directory, so move the item's UI. view_item->getParentFolder()->extractItem(view_item); - view_item->addToFolder(new_parent, mFolderRoot); + view_item->addToFolder(new_parent, mFolderRoot.get()); } else { @@ -594,12 +612,6 @@ void LLInventoryPanel::modelChanged(U32 mask) } } -LLFolderView* LLInventoryPanel::getRootFolder() -{ - return mFolderRoot; -} - - // static void LLInventoryPanel::onIdle(void *userdata) { @@ -620,7 +632,7 @@ void LLInventoryPanel::onIdle(void *userdata) const LLUUID& LLInventoryPanel::getRootFolderID() const { - return mFolderRoot->getListener()->getUUID(); + return mFolderRoot.get()->getListener()->getUUID(); } void LLInventoryPanel::initializeViews() @@ -637,14 +649,14 @@ void LLInventoryPanel::initializeViews() if (gAgent.isFirstLogin()) { // Auto open the user's library - LLFolderViewFolder* lib_folder = mFolderRoot->getFolderByID(gInventory.getLibraryRootFolderID()); + LLFolderViewFolder* lib_folder = mFolderRoot.get()->getFolderByID(gInventory.getLibraryRootFolderID()); if (lib_folder) { lib_folder->setOpen(TRUE); } // Auto close the user's my inventory folder - LLFolderViewFolder* my_inv_folder = mFolderRoot->getFolderByID(gInventory.getRootFolderID()); + LLFolderViewFolder* my_inv_folder = mFolderRoot.get()->getFolderByID(gInventory.getRootFolderID()); if (my_inv_folder) { my_inv_folder->setOpenArrangeRecursively(FALSE, LLFolderViewFolder::RECURSE_DOWN); @@ -654,7 +666,7 @@ void LLInventoryPanel::initializeViews() LLFolderViewItem* LLInventoryPanel::rebuildViewsFor(const LLUUID& id) { // Destroy the old view for this ID so we can rebuild it. - LLFolderViewItem* old_view = mFolderRoot->getItemByID(id); + LLFolderViewItem* old_view = mFolderRoot.get()->getItemByID(id); if (old_view) { old_view->destroyView(); @@ -687,7 +699,7 @@ LLFolderViewFolder * LLInventoryPanel::createFolderViewFolder(LLInvFVBridge * br bridge->getIcon(), bridge->getOpenIcon(), LLUI::getUIImage("inv_link_overlay.tga"), - mFolderRoot, + mFolderRoot.get(), bridge); } @@ -699,25 +711,25 @@ LLFolderViewItem * LLInventoryPanel::createFolderViewItem(LLInvFVBridge * bridge bridge->getOpenIcon(), LLUI::getUIImage("inv_link_overlay.tga"), bridge->getCreationDate(), - mFolderRoot, + mFolderRoot.get(), bridge); } LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id) { LLInventoryObject const* objectp = gInventory.getObject(id); - LLUUID root_id = mFolderRoot->getListener()->getUUID(); + LLUUID root_id = mFolderRoot.get()->getListener()->getUUID(); LLFolderViewFolder* parent_folder = NULL; LLFolderViewItem* itemp = NULL; if (id == root_id) { - parent_folder = mFolderRoot; + parent_folder = mFolderRoot.get(); } else if (objectp) { const LLUUID &parent_id = objectp->getParentUUID(); - parent_folder = (LLFolderViewFolder*)mFolderRoot->getItemByID(parent_id); + parent_folder = (LLFolderViewFolder*)mFolderRoot.get()->getItemByID(parent_id); if (parent_folder) { @@ -737,14 +749,14 @@ LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id) objectp->getType(), LLInventoryType::IT_CATEGORY, this, - mFolderRoot, + mFolderRoot.get(), objectp->getUUID()); if (new_listener) { LLFolderViewFolder* folderp = createFolderViewFolder(new_listener); if (folderp) { - folderp->setItemSortOrder(mFolderRoot->getSortOrder()); + folderp->setItemSortOrder(mFolderRoot.get()->getSortOrder()); } itemp = folderp; } @@ -757,7 +769,7 @@ LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id) item->getActualType(), item->getInventoryType(), this, - mFolderRoot, + mFolderRoot.get(), item->getUUID(), item->getFlags()); @@ -769,7 +781,7 @@ LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id) if (itemp) { - itemp->addToFolder(parent_folder, mFolderRoot); + itemp->addToFolder(parent_folder, mFolderRoot.get()); } } } @@ -815,7 +827,7 @@ LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id) void LLInventoryPanel::openStartFolderOrMyInventory() { // Find My Inventory folder and open it up by name - for (LLView *child = mFolderRoot->getFirstChild(); child; child = mFolderRoot->findNextSibling(child)) + for (LLView *child = mFolderRoot.get()->getFirstChild(); child; child = mFolderRoot.get()->findNextSibling(child)) { LLFolderViewFolder *fchild = dynamic_cast(child); if (fchild @@ -862,12 +874,12 @@ protected: void LLInventoryPanel::onItemsCompletion() { - if (mFolderRoot) mFolderRoot->updateMenu(); + if (mFolderRoot.get()) mFolderRoot.get()->updateMenu(); } void LLInventoryPanel::openSelected() { - LLFolderViewItem* folder_item = mFolderRoot->getCurSelectedItem(); + LLFolderViewItem* folder_item = mFolderRoot.get()->getCurSelectedItem(); if(!folder_item) return; LLInvFVBridge* bridge = (LLInvFVBridge*)folder_item->getListener(); if(!bridge) return; @@ -876,7 +888,7 @@ void LLInventoryPanel::openSelected() void LLInventoryPanel::unSelectAll() { - mFolderRoot->setSelection(NULL, FALSE, FALSE); + mFolderRoot.get()->setSelection(NULL, FALSE, FALSE); } @@ -913,14 +925,14 @@ BOOL LLInventoryPanel::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, // If folder view is empty the (x, y) point won't be in its rect // so the handler must be called explicitly. // but only if was not handled before. See EXT-6746. - if (!handled && !mFolderRoot->hasVisibleChildren()) + if (!handled && !mFolderRoot.get()->hasVisibleChildren()) { - handled = mFolderRoot->handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); + handled = mFolderRoot.get()->handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); } if (handled) { - mFolderRoot->setDragAndDropThisFrame(); + mFolderRoot.get()->setDragAndDropThisFrame(); } } @@ -930,7 +942,7 @@ BOOL LLInventoryPanel::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, void LLInventoryPanel::onFocusLost() { // inventory no longer handles cut/copy/paste/delete - if (LLEditMenuHandler::gEditMenuHandler == mFolderRoot) + if (LLEditMenuHandler::gEditMenuHandler == mFolderRoot.get()) { LLEditMenuHandler::gEditMenuHandler = NULL; } @@ -941,28 +953,28 @@ void LLInventoryPanel::onFocusLost() void LLInventoryPanel::onFocusReceived() { // inventory now handles cut/copy/paste/delete - LLEditMenuHandler::gEditMenuHandler = mFolderRoot; + LLEditMenuHandler::gEditMenuHandler = mFolderRoot.get(); LLPanel::onFocusReceived(); } void LLInventoryPanel::openAllFolders() { - mFolderRoot->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_DOWN); - mFolderRoot->arrangeAll(); + mFolderRoot.get()->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_DOWN); + mFolderRoot.get()->arrangeAll(); } void LLInventoryPanel::closeAllFolders() { - mFolderRoot->setOpenArrangeRecursively(FALSE, LLFolderViewFolder::RECURSE_DOWN); - mFolderRoot->arrangeAll(); + mFolderRoot.get()->setOpenArrangeRecursively(FALSE, LLFolderViewFolder::RECURSE_DOWN); + mFolderRoot.get()->arrangeAll(); } void LLInventoryPanel::openDefaultFolderForType(LLAssetType::EType type) { LLUUID category_id = mInventory->findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(type)); LLOpenFolderByID opener(category_id); - mFolderRoot->applyFunctorRecursively(opener); + mFolderRoot.get()->applyFunctorRecursively(opener); } void LLInventoryPanel::setSelection(const LLUUID& obj_id, BOOL take_keyboard_focus) @@ -973,20 +985,20 @@ void LLInventoryPanel::setSelection(const LLUUID& obj_id, BOOL take_keyboard_foc { return; } - mFolderRoot->setSelectionByID(obj_id, take_keyboard_focus); + mFolderRoot.get()->setSelectionByID(obj_id, take_keyboard_focus); } void LLInventoryPanel::setSelectCallback(const boost::function& items, BOOL user_action)>& cb) { - if (mFolderRoot) + if (mFolderRoot.get()) { - mFolderRoot->setSelectCallback(cb); + mFolderRoot.get()->setSelectCallback(cb); } } void LLInventoryPanel::clearSelection() { - mFolderRoot->clearSelection(); + mFolderRoot.get()->clearSelection(); } void LLInventoryPanel::onSelectionChange(const std::deque& items, BOOL user_action) @@ -1053,7 +1065,7 @@ BOOL LLInventoryPanel::getSinceLogoff() void LLInventoryPanel::dumpSelectionInformation(void* user_data) { LLInventoryPanel* iv = (LLInventoryPanel*)user_data; - iv->mFolderRoot->dumpSelectionInformation(); + iv->mFolderRoot.get()->dumpSelectionInformation(); } // static LLInventoryPanel* LLInventoryPanel::getActiveInventoryPanel(BOOL auto_open) diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h index 5a858143a..27f9fbb3d 100644 --- a/indra/newview/llinventorypanel.h +++ b/indra/newview/llinventorypanel.h @@ -114,7 +114,7 @@ public: void setFilterSubString(const std::string& string); const std::string getFilterSubString(); void setFilterWorn(bool worn); - bool getFilterWorn() const { return mFolderRoot->getFilterWorn(); } + bool getFilterWorn() const { return mFolderRoot.get()->getFilterWorn(); } void setSinceLogoff(BOOL sl); void setHoursAgo(U32 hours); @@ -123,10 +123,10 @@ public: void setShowFolderState(LLInventoryFilter::EFolderShow show); LLInventoryFilter::EFolderShow getShowFolderState(); - void setAllowMultiSelect(BOOL allow) { mFolderRoot->setAllowMultiSelect(allow); } + void setAllowMultiSelect(BOOL allow) { mFolderRoot.get()->setAllowMultiSelect(allow); } // This method is called when something has changed about the inventory. void modelChanged(U32 mask); - LLFolderView* getRootFolder(); + LLFolderView* getRootFolder() { return mFolderRoot.get(); } LLScrollContainer* getScrollableContainer() { return mScroller; } void onSelectionChange(const std::deque &items, BOOL user_action); @@ -155,6 +155,9 @@ public: LLInventoryType::EType inv_type, U32 next_owner_perm = 0); + // Clean up stuff when the folder root gets deleted + void clearFolderRoot(); + protected: void openStartFolderOrMyInventory(); // open the first level of inventory void onItemsCompletion(); // called when selected items are complete @@ -164,7 +167,7 @@ protected: LLInvPanelComplObserver* mCompletionObserver; BOOL mAllowMultiSelect; - LLFolderView* mFolderRoot; + LLHandle mFolderRoot; LLScrollContainer* mScroller; /** diff --git a/indra/newview/llpanelmarketplaceoutboxinventory.cpp b/indra/newview/llpanelmarketplaceoutboxinventory.cpp index 7800eb791..2a19fea07 100644 --- a/indra/newview/llpanelmarketplaceoutboxinventory.cpp +++ b/indra/newview/llpanelmarketplaceoutboxinventory.cpp @@ -83,7 +83,7 @@ void LLOutboxInventoryPanel::buildFolderView(/*const LLInventoryPanel::Params& p NULL, root_id); - mFolderRoot = createFolderView(new_listener, true/*params.use_label_suffix()*/); + mFolderRoot = createFolderView(new_listener, true/*params.use_label_suffix()*/)->getHandle(); } LLFolderViewFolder * LLOutboxInventoryPanel::createFolderViewFolder(LLInvFVBridge * bridge) @@ -93,7 +93,7 @@ LLFolderViewFolder * LLOutboxInventoryPanel::createFolderViewFolder(LLInvFVBridg bridge->getIcon(), bridge->getOpenIcon(), LLUI::getUIImage("inv_link_overlay.tga"), - mFolderRoot, + mFolderRoot.get(), bridge); } @@ -105,7 +105,7 @@ LLFolderViewItem * LLOutboxInventoryPanel::createFolderViewItem(LLInvFVBridge * bridge->getOpenIcon(), LLUI::getUIImage("inv_link_overlay.tga"), bridge->getCreationDate(), - mFolderRoot, + mFolderRoot.get(), bridge); }