From 08a3b56669880101aa705c98e60b76e92d26c93b Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Thu, 5 Oct 2023 20:08:36 +0300 Subject: SL-19826 Fix mac build issue (unused variable) --- indra/newview/llinventorygallery.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llinventorygallery.cpp') diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index 4838ba7a47..0e4c64a641 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -2420,7 +2420,7 @@ void LLInventoryGallery::startDrag() ids.push_back(selected_id); } } - LLToolDragAndDrop::getInstance()->beginMultiDrag(types, ids, LLToolDragAndDrop::SOURCE_AGENT); + LLToolDragAndDrop::getInstance()->beginMultiDrag(types, ids, src); } bool LLInventoryGallery::areViewsInitialized() -- cgit v1.3 From 2968e8bea5cde5b27ae806cf4bb2d36b254e94d8 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 6 Oct 2023 23:27:11 +0300 Subject: SL-20411 Don't load all thumnails at once for large folders #2 --- indra/newview/llinventorygallery.cpp | 26 ++++++++++-- indra/newview/llinventorygallery.h | 4 ++ indra/newview/llthumbnailctrl.cpp | 77 ++++++++++++++++++++++++++---------- indra/newview/llthumbnailctrl.h | 8 ++++ 4 files changed, 90 insertions(+), 25 deletions(-) (limited to 'indra/newview/llinventorygallery.cpp') diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index 0e4c64a641..d4ca58f778 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -58,6 +58,7 @@ static LLPanelInjector t_inventory_gallery("inventory_gallery"); const S32 GALLERY_ITEMS_PER_ROW_MIN = 2; +const S32 FAST_LOAD_THUMBNAIL_TRSHOLD = 50; // load folders below this value immediately // Helper dnd functions BOOL dragCategoryIntoFolder(LLUUID dest_id, LLInventoryCategory* inv_cat, BOOL drop, std::string& tooltip_msg, BOOL is_link); @@ -106,6 +107,7 @@ LLInventoryGallery::LLInventoryGallery(const LLInventoryGallery::Params& p) mGalleryWidthFactor(p.gallery_width_factor), mIsInitialized(false), mRootDirty(false), + mLoadThumbnailsImmediately(true), mNeedsArrange(false), mSearchType(LLInventoryFilter::SEARCHTYPE_NAME), mSortOrder(LLInventoryFilter::SO_DATE) @@ -540,6 +542,12 @@ void LLInventoryGallery::addToGallery(LLInventoryGalleryItem* item) int n_prev = n - 1; int row_count_prev = (n_prev % mItemsInRow) == 0 ? n_prev / mItemsInRow : n_prev / mItemsInRow + 1; + // Avoid loading too many items. + // Intent is for small folders to display all content fast + // and for large folders to load content mostly as needed + // Todo: ideally needs to unload images outside visible area + mLoadThumbnailsImmediately = mItemsAddedCount < FAST_LOAD_THUMBNAIL_TRSHOLD; + bool add_row = row_count != row_count_prev; int pos = 0; if (add_row) @@ -573,6 +581,8 @@ void LLInventoryGallery::removeFromGalleryLast(LLInventoryGalleryItem* item, boo mItemsAddedCount--; mIndexToItemMap.erase(mItemsAddedCount); + mLoadThumbnailsImmediately = mItemsAddedCount < FAST_LOAD_THUMBNAIL_TRSHOLD; + bool remove_row = row_count != row_count_prev; removeFromLastRow(mItems[mItemsAddedCount]); mItems.pop_back(); @@ -636,6 +646,7 @@ LLInventoryGalleryItem* LLInventoryGallery::buildGalleryItem(std::string name, L gitem->setUUID(item_id); gitem->setGallery(this); gitem->setType(type, inventory_type, flags, is_link); + gitem->setLoadImmediately(mLoadThumbnailsImmediately); gitem->setThumbnail(thumbnail_id); gitem->setWorn(is_worn); gitem->setCreatorName(get_searchable_creator_name(&gInventory, item_id)); @@ -997,6 +1008,7 @@ void LLInventoryGallery::updateItemThumbnail(LLUUID item_id) if (mItemMap[item_id]) { + mItemMap[item_id]->setLoadImmediately(mLoadThumbnailsImmediately); mItemMap[item_id]->setThumbnail(thumbnail_id); bool passes_filter = checkAgainstFilters(mItemMap[item_id], mFilterSubString); @@ -2568,6 +2580,7 @@ BOOL LLInventoryGalleryItem::postBuild() { mNameText = getChild("item_name"); mTextBgPanel = getChild("text_bg_panel"); + mThumbnailCtrl = getChild("preview_thumbnail"); return TRUE; } @@ -2643,14 +2656,19 @@ void LLInventoryGalleryItem::setThumbnail(LLUUID id) mDefaultImage = id.isNull(); if(mDefaultImage) { - getChild("preview_thumbnail")->clearTexture(); + mThumbnailCtrl->clearTexture(); } else { - getChild("preview_thumbnail")->setValue(id); + mThumbnailCtrl->setValue(id); } } +void LLInventoryGalleryItem::setLoadImmediately(bool val) +{ + mThumbnailCtrl->setInitImmediately(val); +} + void LLInventoryGalleryItem::draw() { if (isFadeItem()) @@ -2665,7 +2683,7 @@ void LLInventoryGalleryItem::draw() // Draw border LLUIColor border_color = LLUIColorTable::instance().getColor(mSelected ? "MenuItemHighlightBgColor" : "TextFgTentativeColor", LLColor4::white); - LLRect border = getChildView("preview_thumbnail")->getRect(); + LLRect border = mThumbnailCtrl->getRect(); border.mRight = border.mRight + 1; border.mTop = border.mTop + 1; gl_rect_2d(border, border_color.get(), FALSE); @@ -2887,7 +2905,7 @@ void LLInventoryGalleryItem::updateNameText() mNameText->setFont(getTextFont()); mNameText->setText(mItemName + mPermSuffix + mWornSuffix); mNameText->setToolTip(mItemName + mPermSuffix + mWornSuffix); - getChild("preview_thumbnail")->setToolTip(mItemName + mPermSuffix + mWornSuffix); + mThumbnailCtrl->setToolTip(mItemName + mPermSuffix + mWornSuffix); } bool LLInventoryGalleryItem::isFadeItem() diff --git a/indra/newview/llinventorygallery.h b/indra/newview/llinventorygallery.h index 9b3f12701f..0c52e7b713 100644 --- a/indra/newview/llinventorygallery.h +++ b/indra/newview/llinventorygallery.h @@ -39,6 +39,7 @@ class LLInventoryGalleryItem; class LLScrollContainer; class LLTextBox; class LLThumbnailsObserver; +class LLThumbnailCtrl; class LLGalleryGestureObserver; class LLInventoryGalleryContextMenu; @@ -246,6 +247,7 @@ private: int mRowCount; int mItemsAddedCount; bool mGalleryCreated; + bool mLoadThumbnailsImmediately; bool mNeedsArrange; /* Params */ @@ -342,6 +344,7 @@ public: LLAssetType::EType getAssetType() { return mType; } void setThumbnail(LLUUID id); void setGallery(LLInventoryGallery* gallery) { mGallery = gallery; } + void setLoadImmediately(bool val); bool isFolder() { return mIsFolder; } bool isLink() { return mIsLink; } EInventorySortGroup getSortGroup() { return mSortGroup; } @@ -354,6 +357,7 @@ private: LLUUID mUUID; LLTextBox* mNameText; LLPanel* mTextBgPanel; + LLThumbnailCtrl* mThumbnailCtrl; bool mSelected; bool mWorn; bool mDefaultImage; diff --git a/indra/newview/llthumbnailctrl.cpp b/indra/newview/llthumbnailctrl.cpp index 72818cf991..78204204af 100644 --- a/indra/newview/llthumbnailctrl.cpp +++ b/indra/newview/llthumbnailctrl.cpp @@ -57,6 +57,8 @@ LLThumbnailCtrl::LLThumbnailCtrl(const LLThumbnailCtrl::Params& p) , mFallbackImagep(p.fallback_image) , mInteractable(p.interactable()) , mShowLoadingPlaceholder(p.show_loading()) +, mInited(false) +, mInitImmediately(true) { mLoadingPlaceholderString = LLTrans::getString("texture_loading"); @@ -83,6 +85,10 @@ LLThumbnailCtrl::~LLThumbnailCtrl() void LLThumbnailCtrl::draw() { + if (!mInited) + { + initImage(); + } LLRect draw_rect = getLocalRect(); if (mBorderVisible) @@ -170,11 +176,19 @@ void LLThumbnailCtrl::draw() LLUICtrl::draw(); } +void LLThumbnailCtrl::setVisible(BOOL visible) +{ + if (!visible && mInited) + { + unloadImage(); + } + LLUICtrl::setVisible(visible); +} + void LLThumbnailCtrl::clearTexture() { - mImageAssetID = LLUUID::null; - mTexturep = nullptr; - mImagep = nullptr; + setValue(LLSD()); + mInited = true; // nothing to do } // virtual @@ -190,33 +204,56 @@ void LLThumbnailCtrl::setValue(const LLSD& value) LLUICtrl::setValue(tvalue); - mImageAssetID = LLUUID::null; - mTexturep = nullptr; - mImagep = nullptr; - - if (tvalue.isUUID()) - { + unloadImage(); + + if (mInitImmediately) + { + initImage(); + } +} + +BOOL LLThumbnailCtrl::handleHover(S32 x, S32 y, MASK mask) +{ + if (mInteractable && getEnabled()) + { + getWindow()->setCursor(UI_CURSOR_HAND); + return TRUE; + } + return LLUICtrl::handleHover(x, y, mask); +} + +void LLThumbnailCtrl::initImage() +{ + if (mInited) + { + return; + } + mInited = true; + LLSD tvalue = getValue(); + + if (tvalue.isUUID()) + { mImageAssetID = tvalue.asUUID(); if (mImageAssetID.notNull()) { // Should it support baked textures? mTexturep = LLViewerTextureManager::getFetchedTexture(mImageAssetID, FTT_DEFAULT, MIPMAP_YES, LLGLTexture::BOOST_THUMBNAIL); - + mTexturep->forceToSaveRawImage(0); - + S32 desired_draw_width = mTexturep->getWidth(); S32 desired_draw_height = mTexturep->getHeight(); - + mTexturep->setKnownDrawSize(desired_draw_width, desired_draw_height); } - } + } else if (tvalue.isString()) { mImagep = LLUI::getUIImage(tvalue.asString(), LLGLTexture::BOOST_UI); if (mImagep) { LLViewerFetchedTexture* texture = dynamic_cast(mImagep->getImage().get()); - if(texture) + if (texture) { mImageAssetID = texture->getID(); } @@ -224,14 +261,12 @@ void LLThumbnailCtrl::setValue(const LLSD& value) } } -BOOL LLThumbnailCtrl::handleHover(S32 x, S32 y, MASK mask) +void LLThumbnailCtrl::unloadImage() { - if (mInteractable && getEnabled()) - { - getWindow()->setCursor(UI_CURSOR_HAND); - return TRUE; - } - return LLUICtrl::handleHover(x, y, mask); + mImageAssetID = LLUUID::null; + mTexturep = nullptr; + mImagep = nullptr; + mInited = false; } diff --git a/indra/newview/llthumbnailctrl.h b/indra/newview/llthumbnailctrl.h index 70f56c429c..f84a583271 100644 --- a/indra/newview/llthumbnailctrl.h +++ b/indra/newview/llthumbnailctrl.h @@ -64,16 +64,24 @@ public: virtual ~LLThumbnailCtrl(); virtual void draw() override; + void setVisible(BOOL visible) override; virtual void setValue(const LLSD& value ) override; + void setInitImmediately(bool val) { mInitImmediately = val; } void clearTexture(); virtual BOOL handleHover(S32 x, S32 y, MASK mask) override; + +protected: + void initImage(); + void unloadImage(); private: bool mBorderVisible; bool mInteractable; bool mShowLoadingPlaceholder; + bool mInited; + bool mInitImmediately; std::string mLoadingPlaceholderString; LLUUID mImageAssetID; LLViewBorder* mBorder; -- cgit v1.3 From a62f5bfac1e55455c67e1c36eb388af99795dab6 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Sat, 14 Oct 2023 02:40:59 +0300 Subject: SL-20232 Allow deletion of worn items #1 --- indra/llui/llfolderview.cpp | 2 +- indra/llui/llfolderviewmodel.h | 2 +- indra/newview/llappearancemgr.cpp | 9 ++- indra/newview/llappearancemgr.h | 4 +- indra/newview/llcofwearables.cpp | 4 +- indra/newview/llconversationmodel.h | 2 +- indra/newview/llinventorybridge.cpp | 15 ++-- indra/newview/llinventorybridge.h | 4 +- indra/newview/llinventoryfunctions.cpp | 87 +++++++++++++++++++--- indra/newview/llinventoryfunctions.h | 2 +- indra/newview/llinventorygallery.cpp | 6 +- indra/newview/llinventorygallerymenu.cpp | 2 +- indra/newview/llpanelobjectinventory.cpp | 8 +- indra/newview/llpanelwearing.cpp | 4 +- indra/newview/llwearableitemslist.cpp | 6 +- .../newview/skins/default/xui/en/notifications.xml | 27 +++++++ 16 files changed, 138 insertions(+), 46 deletions(-) (limited to 'indra/newview/llinventorygallery.cpp') diff --git a/indra/llui/llfolderview.cpp b/indra/llui/llfolderview.cpp index bbbb4afb54..d7ba47c9f5 100644 --- a/indra/llui/llfolderview.cpp +++ b/indra/llui/llfolderview.cpp @@ -765,7 +765,7 @@ void LLFolderView::removeSelectedItems() } else { - LL_INFOS() << "Cannot delete " << item->getName() << LL_ENDL; + LL_DEBUGS() << "Cannot delete " << item->getName() << LL_ENDL; return; } } diff --git a/indra/llui/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h index 551a60e097..0f11560790 100644 --- a/indra/llui/llfolderviewmodel.h +++ b/indra/llui/llfolderviewmodel.h @@ -170,7 +170,7 @@ public: virtual BOOL isItemMovable( void ) const = 0; // Can be moved to another folder virtual void move( LLFolderViewModelItem* parent_listener ) = 0; - virtual BOOL isItemRemovable( void ) const = 0; // Can be destroyed + virtual BOOL isItemRemovable( bool check_worn = true ) const = 0; // Can be destroyed virtual BOOL removeItem() = 0; virtual void removeBatch(std::vector& batch) = 0; diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 8010b84c20..61b86d6a4a 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -3176,6 +3176,7 @@ void LLAppearanceMgr::removeCOFItemLinks(const LLUUID& item_id, LLPointergetUUID(), cb, true); + remove_inventory_item(item->getUUID(), cb, true); gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); } else @@ -4117,7 +4118,7 @@ void LLAppearanceMgr::wearBaseOutfit() updateCOF(base_outfit_id); } -void LLAppearanceMgr::removeItemsFromAvatar(const uuid_vec_t& ids_to_remove) +void LLAppearanceMgr::removeItemsFromAvatar(const uuid_vec_t& ids_to_remove, nullary_func_t post_update_func) { LL_DEBUGS("UIUsage") << "removeItemsFromAvatar" << LL_ENDL; LLUIUsage::instance().logCommand("Avatar.RemoveItem"); @@ -4127,7 +4128,7 @@ void LLAppearanceMgr::removeItemsFromAvatar(const uuid_vec_t& ids_to_remove) LL_WARNS() << "called with empty list, nothing to do" << LL_ENDL; return; } - LLPointer cb = new LLUpdateAppearanceOnDestroy; + LLPointer cb = new LLUpdateAppearanceOnDestroy(true, true, post_update_func); for (uuid_vec_t::const_iterator it = ids_to_remove.begin(); it != ids_to_remove.end(); ++it) { const LLUUID& id_to_remove = *it; @@ -4146,11 +4147,11 @@ void LLAppearanceMgr::removeItemsFromAvatar(const uuid_vec_t& ids_to_remove) } } -void LLAppearanceMgr::removeItemFromAvatar(const LLUUID& id_to_remove) +void LLAppearanceMgr::removeItemFromAvatar(const LLUUID& id_to_remove, nullary_func_t post_update_func) { uuid_vec_t ids_to_remove; ids_to_remove.push_back(id_to_remove); - removeItemsFromAvatar(ids_to_remove); + removeItemsFromAvatar(ids_to_remove, post_update_func); } diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index 43839e47a6..80d6587ad3 100644 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -195,8 +195,8 @@ public: bool updateBaseOutfit(); //Remove clothing or detach an object from the agent (a bodypart cannot be removed) - void removeItemsFromAvatar(const uuid_vec_t& item_ids); - void removeItemFromAvatar(const LLUUID& item_id); + void removeItemsFromAvatar(const uuid_vec_t& item_ids, nullary_func_t post_update_func = no_op); + void removeItemFromAvatar(const LLUUID& item_id, nullary_func_t post_update_func = no_op); void onOutfitFolderCreated(const LLUUID& folder_id, bool show_panel); diff --git a/indra/newview/llcofwearables.cpp b/indra/newview/llcofwearables.cpp index aa2ba752b7..b138db48b5 100644 --- a/indra/newview/llcofwearables.cpp +++ b/indra/newview/llcofwearables.cpp @@ -142,7 +142,7 @@ protected: registrar.add("Attachment.Touch", boost::bind(handleMultiple, handle_attachment_touch, mUUIDs)); registrar.add("Attachment.Edit", boost::bind(handleMultiple, handle_item_edit, mUUIDs)); - registrar.add("Attachment.Detach", boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), mUUIDs)); + registrar.add("Attachment.Detach", boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), mUUIDs, no_op)); LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; enable_registrar.add("Attachment.OnEnable", boost::bind(&CofAttachmentContextMenu::onEnable, this, _2)); @@ -195,7 +195,7 @@ protected: LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; LLUUID selected_id = mUUIDs.back(); - registrar.add("Clothing.TakeOff", boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), mUUIDs)); + registrar.add("Clothing.TakeOff", boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), mUUIDs, no_op)); registrar.add("Clothing.Replace", boost::bind(replaceWearable, selected_id)); registrar.add("Clothing.Edit", boost::bind(LLAgentWearables::editWearable, selected_id)); registrar.add("Clothing.Create", boost::bind(&CofClothingContextMenu::createNew, this, selected_id)); diff --git a/indra/newview/llconversationmodel.h b/indra/newview/llconversationmodel.h index 3f607d434e..6b2fecdc61 100644 --- a/indra/newview/llconversationmodel.h +++ b/indra/newview/llconversationmodel.h @@ -82,7 +82,7 @@ public: virtual BOOL isItemRenameable() const { return TRUE; } virtual BOOL renameItem(const std::string& new_name) { mName = new_name; mNeedsRefresh = true; return TRUE; } virtual BOOL isItemMovable( void ) const { return FALSE; } - virtual BOOL isItemRemovable( void ) const { return FALSE; } + virtual BOOL isItemRemovable(bool check_worn = true) const { return FALSE; } virtual BOOL isItemInTrash( void) const { return FALSE; } virtual BOOL removeItem() { return FALSE; } virtual void removeBatch(std::vector& batch) { } diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index c41a4c5686..4d7fc41ae3 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -309,9 +309,9 @@ void LLInvFVBridge::setCreationDate(time_t creation_date_utc) // Can be destroyed (or moved to trash) -BOOL LLInvFVBridge::isItemRemovable() const +BOOL LLInvFVBridge::isItemRemovable(bool check_worn) const { - return get_is_item_removable(getInventoryModel(), mUUID); + return get_is_item_removable(getInventoryModel(), mUUID, check_worn); } // Can be moved to another folder @@ -1063,7 +1063,7 @@ void LLInvFVBridge::addDeleteContextMenuOptions(menuentry_vec_t &items, items.push_back(std::string("Delete")); - if (!isItemRemovable() || isPanelActive("Favorite Items")) + if (!isItemRemovable(false) || isPanelActive("Favorite Items")) { disabled_items.push_back(std::string("Delete")); } @@ -2405,20 +2405,21 @@ void LLFolderBridge::update() class LLIsItemRemovable : public LLFolderViewFunctor { public: - LLIsItemRemovable() : mPassed(TRUE) {} + LLIsItemRemovable(bool check_worn = true) : mPassed(TRUE), mCheckWorn(check_worn) {} virtual void doFolder(LLFolderViewFolder* folder) { - mPassed &= folder->getViewModelItem()->isItemRemovable(); + mPassed &= folder->getViewModelItem()->isItemRemovable(mCheckWorn); } virtual void doItem(LLFolderViewItem* item) { - mPassed &= item->getViewModelItem()->isItemRemovable(); + mPassed &= item->getViewModelItem()->isItemRemovable(mCheckWorn); } BOOL mPassed; + bool mCheckWorn; }; // Can be destroyed (or moved to trash) -BOOL LLFolderBridge::isItemRemovable() const +BOOL LLFolderBridge::isItemRemovable(bool check_worn) const { if (!get_is_category_removable(getInventoryModel(), mUUID)) { diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index decaee7db3..62e26b2f28 100644 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -114,7 +114,7 @@ public: virtual BOOL isItemRenameable() const { return TRUE; } virtual BOOL isMultiPreviewAllowed() { return TRUE; } //virtual BOOL renameItem(const std::string& new_name) {} - virtual BOOL isItemRemovable() const; + virtual BOOL isItemRemovable(bool check_worn = true) const; virtual BOOL isItemMovable() const; virtual BOOL isItemInTrash() const; virtual bool isItemInOutfits() const; @@ -321,7 +321,7 @@ public: void* cargo_data, std::string& tooltip_msg); - virtual BOOL isItemRemovable() const; + virtual BOOL isItemRemovable(bool check_worn = true) const; virtual BOOL isItemMovable() const ; virtual BOOL isUpToDate() const; virtual bool isItemCopyable(bool can_copy_as_link = true) const; diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 4aeacae6ed..109dffae6b 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -682,17 +682,17 @@ BOOL get_can_item_be_worn(const LLUUID& id) return FALSE; } -BOOL get_is_item_removable(const LLInventoryModel* model, const LLUUID& id) +bool get_is_item_removable(const LLInventoryModel* model, const LLUUID& id, bool check_worn) { if (!model) { - return FALSE; + return false; } // Can't delete an item that's in the library. if (!model->isObjectDescendentOf(id, gInventory.getRootFolderID())) { - return FALSE; + return false; } // Disable delete from COF folder; have users explicitly choose "detach/take off", @@ -701,20 +701,20 @@ BOOL get_is_item_removable(const LLInventoryModel* model, const LLUUID& id) { if (get_is_item_worn(id)) { - return FALSE; + return false; } } const LLInventoryObject *obj = model->getItem(id); if (obj && obj->getIsLinkType()) { - return TRUE; + return true; } - if (get_is_item_worn(id)) + if (check_worn && get_is_item_worn(id)) { - return FALSE; + return false; } - return TRUE; + return true; } bool get_is_item_editable(const LLUUID& inv_item_id) @@ -2759,7 +2759,7 @@ bool LLFindNonRemovableObjects::operator()(LLInventoryCategory* cat, LLInventory { if (item) { - return !get_is_item_removable(&gInventory, item->getUUID()); + return !get_is_item_removable(&gInventory, item->getUUID(), true); } if (cat) { @@ -3024,6 +3024,8 @@ void LLInventoryAction::doToSelected(LLInventoryModel* model, LLFolderView* root { const LLUUID &marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS); bool marketplacelistings_item = false; + bool worn_item = false; + bool needs_replacement = false; LLAllDescendentsPassedFilter f; for (std::set::iterator it = selected_items.begin(); (it != selected_items.end()) && (f.allDescendentsPassedFilter()); ++it) { @@ -3037,9 +3039,32 @@ void LLInventoryAction::doToSelected(LLInventoryModel* model, LLFolderView* root marketplacelistings_item = true; break; } + if (get_is_item_worn(viewModel->getUUID())) + { + worn_item = true; + LLWearableType::EType type = viewModel->getWearableType(); + if (type == LLWearableType::WT_SHAPE + || type == LLWearableType::WT_SKIN + || type == LLWearableType::WT_HAIR + || type == LLWearableType::WT_EYES) + { + needs_replacement = true; + break; + } + } } // Fall through to the generic confirmation if the user choose to ignore the specialized one - if ( (!f.allDescendentsPassedFilter()) && !marketplacelistings_item && (!LLNotifications::instance().getIgnored("DeleteFilteredItems")) ) + if (needs_replacement) + { + LLNotificationsUtil::add("CantDeleteRequiredClothing"); + } + else if (worn_item) + { + LLSD payload; + payload["has_worn"] = true; + LLNotificationsUtil::add("DeleteWornItems", LLSD(), payload, boost::bind(&LLInventoryAction::onItemsRemovalConfirmation, _1, _2, root->getHandle())); + } + else if ( (!f.allDescendentsPassedFilter()) && !marketplacelistings_item && (!LLNotifications::instance().getIgnored("DeleteFilteredItems")) ) { LLNotificationsUtil::add("DeleteFilteredItems", LLSD(), LLSD(), boost::bind(&LLInventoryAction::onItemsRemovalConfirmation, _1, _2, root->getHandle())); } @@ -3356,17 +3381,55 @@ void LLInventoryAction::removeItemFromDND(LLFolderView* root) } } } - void LLInventoryAction::onItemsRemovalConfirmation(const LLSD& notification, const LLSD& response, LLHandle root) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option == 0 && !root.isDead() && !root.get()->isDead()) { + bool has_worn = notification["payload"]["has_worn"].asBoolean(); LLFolderView* folder_root = root.get(); //Need to remove item from DND before item is removed from root folder view //because once removed from root folder view the item is no longer a selected item removeItemFromDND(folder_root); - folder_root->removeSelectedItems(); + + // removeSelectedItems will change selection, collect worn items beforehand + uuid_vec_t worn; + if (has_worn) + { + //Get selected items + LLFolderView::selected_items_t selectedItems = folder_root->getSelectedItems(); + + //If user is in DND and deletes item, make sure the notification is not displayed by removing the notification + //from DND history and .xml file. Once this is done, upon exit of DND mode the item deleted will not show a notification. + for (LLFolderView::selected_items_t::iterator it = selectedItems.begin(); it != selectedItems.end(); ++it) + { + LLObjectBridge* view_model = dynamic_cast((*it)->getViewModelItem()); + + if (view_model && get_is_item_worn(view_model->getUUID())) + { + worn.push_back(view_model->getUUID()); + } + } + } + + // removeSelectedItems will check if items are worn before deletion, + // don't 'unwear' yet to prevent a race condition from unwearing + // and removing simultaneously + folder_root->removeSelectedItems(); + + // unwear then delete the rest + if (!worn.empty()) + { + // should fire once after every item gets detached + LLAppearanceMgr::instance().removeItemsFromAvatar(worn, + [worn]() + { + for (const LLUUID& id : worn) + { + remove_inventory_item(id, NULL); + } + }); + } // Update the marketplace listings that have been affected by the operation updateMarketplaceFolders(); diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h index 925217dda3..cac1d77f5e 100644 --- a/indra/newview/llinventoryfunctions.h +++ b/indra/newview/llinventoryfunctions.h @@ -51,7 +51,7 @@ BOOL get_is_item_worn(const LLUUID& id); // Could this item be worn (correct type + not already being worn) BOOL get_can_item_be_worn(const LLUUID& id); -BOOL get_is_item_removable(const LLInventoryModel* model, const LLUUID& id); +bool get_is_item_removable(const LLInventoryModel* model, const LLUUID& id, bool check_worn); // Performs the appropiate edit action (if one exists) for this item bool get_is_item_editable(const LLUUID& inv_item_id); diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index d4ca58f778..9074c8466a 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -1685,7 +1685,7 @@ BOOL LLInventoryGallery::canCut() const return FALSE; } } - else if (!get_is_item_removable(&gInventory, id)) + else if (!get_is_item_removable(&gInventory, id, true)) { return FALSE; } @@ -1880,7 +1880,7 @@ void LLInventoryGallery::onDelete(const LLSD& notification, const LLSD& response } else { - if (get_is_item_removable(&gInventory, id)) + if (get_is_item_removable(&gInventory, id, true)) { gInventory.removeItem(id); } @@ -1925,7 +1925,7 @@ bool LLInventoryGallery::canDeleteSelection() return false; } } - else if (!get_is_item_removable(&gInventory, id)) + else if (!get_is_item_removable(&gInventory, id, true)) { return false; } diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 5f4b816b99..50eefc7d25 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -577,7 +577,7 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men { items.push_back(std::string("Delete")); } - if(!get_is_item_removable(&gInventory, selected_id)) + if(!get_is_item_removable(&gInventory, selected_id, true)) { disabled_items.push_back(std::string("Delete")); disabled_items.push_back(std::string("Cut")); diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index a3bbd00601..922dccf7be 100644 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -129,7 +129,7 @@ public: virtual BOOL isItemRenameable() const; virtual BOOL renameItem(const std::string& new_name); virtual BOOL isItemMovable() const; - virtual BOOL isItemRemovable() const; + virtual BOOL isItemRemovable(bool check_worn = true) const; virtual BOOL removeItem(); virtual void removeBatch(std::vector& batch); virtual void move(LLFolderViewModelItem* parent_listener); @@ -335,7 +335,7 @@ BOOL LLTaskInvFVBridge::isItemMovable() const return TRUE; } -BOOL LLTaskInvFVBridge::isItemRemovable() const +BOOL LLTaskInvFVBridge::isItemRemovable(bool check_worn) const { const LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); if(object @@ -587,7 +587,7 @@ public: virtual BOOL isItemRenameable() const; // virtual BOOL isItemCopyable() const { return FALSE; } virtual BOOL renameItem(const std::string& new_name); - virtual BOOL isItemRemovable() const; + virtual BOOL isItemRemovable(bool check_worn = true) const; virtual void buildContextMenu(LLMenuGL& menu, U32 flags); virtual bool hasChildren() const; virtual BOOL startDrag(EDragAndDropType* type, LLUUID* id) const; @@ -647,7 +647,7 @@ BOOL LLTaskCategoryBridge::renameItem(const std::string& new_name) return FALSE; } -BOOL LLTaskCategoryBridge::isItemRemovable() const +BOOL LLTaskCategoryBridge::isItemRemovable(bool check_worn) const { return FALSE; } diff --git a/indra/newview/llpanelwearing.cpp b/indra/newview/llpanelwearing.cpp index bfdb0fbc88..35eba16afe 100644 --- a/indra/newview/llpanelwearing.cpp +++ b/indra/newview/llpanelwearing.cpp @@ -110,9 +110,9 @@ protected: registrar.add("Wearing.EditOutfit", boost::bind(&edit_outfit)); registrar.add("Wearing.ShowOriginal", boost::bind(show_item_original, mUUIDs.front())); registrar.add("Wearing.TakeOff", - boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), mUUIDs)); + boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), mUUIDs, no_op)); registrar.add("Wearing.Detach", - boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), mUUIDs)); + boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), mUUIDs, no_op)); LLContextMenu* menu = createFromFile("menu_wearing_tab.xml"); updateMenuItemsVisibility(menu); diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp index 948fe55e0d..49c35c7ad5 100644 --- a/indra/newview/llwearableitemslist.cpp +++ b/indra/newview/llwearableitemslist.cpp @@ -925,17 +925,17 @@ LLContextMenu* LLWearableItemsList::ContextMenu::createMenu() registrar.add("Wearable.CreateNew", boost::bind(createNewWearable, selected_id)); registrar.add("Wearable.ShowOriginal", boost::bind(show_item_original, selected_id)); registrar.add("Wearable.TakeOffDetach", - boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), ids)); + boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), ids, no_op)); // Register handlers for clothing. registrar.add("Clothing.TakeOff", - boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), ids)); + boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), ids, no_op)); // Register handlers for body parts. // Register handlers for attachments. registrar.add("Attachment.Detach", - boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), ids)); + boost::bind(&LLAppearanceMgr::removeItemsFromAvatar, LLAppearanceMgr::getInstance(), ids, no_op)); registrar.add("Attachment.Touch", boost::bind(handle_attachment_touch, selected_id)); registrar.add("Attachment.Profile", boost::bind(show_item_profile, selected_id)); registrar.add("Object.Attach", boost::bind(LLViewerAttachMenu::attachObjects, ids, _2)); diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index ac63786b15..5115bcb27f 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -6153,6 +6153,33 @@ Are you sure you want to delete them? notext="Cancel" yestext="OK"/> + + + +Some item(s) you wish to delete are being worn on your avatar. +Remove these items from your avatar? + confirm + + + + + +Some item(s) you wish to delete are required clothing layers (skin, shape, hair, eyes). +You must replace those layers before deleting them. + confirm + + Date: Sat, 14 Oct 2023 12:14:51 +0300 Subject: SL-20232 Allow deletion of worn items #2 --- indra/newview/llinventoryfunctions.cpp | 7 ++-- indra/newview/llinventorygallery.cpp | 64 +++++++++++++++++++++++++++++--- indra/newview/llinventorygallerymenu.cpp | 7 +++- 3 files changed, 68 insertions(+), 10 deletions(-) (limited to 'indra/newview/llinventorygallery.cpp') diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 109dffae6b..5e702ef755 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -3024,7 +3024,7 @@ void LLInventoryAction::doToSelected(LLInventoryModel* model, LLFolderView* root { const LLUUID &marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS); bool marketplacelistings_item = false; - bool worn_item = false; + bool has_worn = false; bool needs_replacement = false; LLAllDescendentsPassedFilter f; for (std::set::iterator it = selected_items.begin(); (it != selected_items.end()) && (f.allDescendentsPassedFilter()); ++it) @@ -3041,7 +3041,7 @@ void LLInventoryAction::doToSelected(LLInventoryModel* model, LLFolderView* root } if (get_is_item_worn(viewModel->getUUID())) { - worn_item = true; + has_worn = true; LLWearableType::EType type = viewModel->getWearableType(); if (type == LLWearableType::WT_SHAPE || type == LLWearableType::WT_SKIN @@ -3058,7 +3058,7 @@ void LLInventoryAction::doToSelected(LLInventoryModel* model, LLFolderView* root { LLNotificationsUtil::add("CantDeleteRequiredClothing"); } - else if (worn_item) + else if (has_worn) { LLSD payload; payload["has_worn"] = true; @@ -3411,6 +3411,7 @@ void LLInventoryAction::onItemsRemovalConfirmation(const LLSD& notification, con } } } + // TODO: collect worn items from content and folders that neede to be deleted after that // removeSelectedItems will check if items are worn before deletion, // don't 'unwear' yet to prevent a race condition from unwearing diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index 9074c8466a..23a00e2e51 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -1864,6 +1864,8 @@ void LLInventoryGallery::onDelete(const LLSD& notification, const LLSD& response S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option == 0) { + bool has_worn = notification["payload"]["has_worn"].asBoolean(); + uuid_vec_t worn; for (const LLUUID& id : selected_ids) { LLInventoryObject* obj = gInventory.getObject(id); @@ -1884,22 +1886,72 @@ void LLInventoryGallery::onDelete(const LLSD& notification, const LLSD& response { gInventory.removeItem(id); } + else if (has_worn && get_is_item_worn(id)) + { + worn.push_back(id); + } } } + + if (!worn.empty()) + { + // should fire once after every item gets detached + LLAppearanceMgr::instance().removeItemsFromAvatar(worn, + [worn]() + { + for (const LLUUID& id : worn) + { + remove_inventory_item(id, NULL); + } + }); + } } } void LLInventoryGallery::deleteSelection() { - if (!LLInventoryAction::sDeleteConfirmationDisplayed) // ask for the confirmation at least once per session + bool has_worn = false; + bool needs_replacement = false; + for (const LLUUID& id : mSelectedItemIDs) { - LLNotifications::instance().setIgnored("DeleteItems", false); - LLInventoryAction::sDeleteConfirmationDisplayed = true; + if (get_is_item_worn(id)) + { + has_worn = true; + const LLViewerInventoryItem* item = gInventory.getItem(id); + LLWearableType::EType type = item->getWearableType(); + if (type == LLWearableType::WT_SHAPE + || type == LLWearableType::WT_SKIN + || type == LLWearableType::WT_HAIR + || type == LLWearableType::WT_EYES) + { + needs_replacement = true; + break; + } + } } - LLSD args; - args["QUESTION"] = LLTrans::getString("DeleteItem"); - LLNotificationsUtil::add("DeleteItems", args, LLSD(), boost::bind(&LLInventoryGallery::onDelete, _1, _2, mSelectedItemIDs)); + if (needs_replacement) + { + LLNotificationsUtil::add("CantDeleteRequiredClothing"); + } + else if (has_worn) + { + LLSD payload; + payload["has_worn"] = true; + LLNotificationsUtil::add("DeleteWornItems", LLSD(), payload, boost::bind(&LLInventoryGallery::onDelete, _1, _2, mSelectedItemIDs)); + } + else + { + if (!LLInventoryAction::sDeleteConfirmationDisplayed) // ask for the confirmation at least once per session + { + LLNotifications::instance().setIgnored("DeleteItems", false); + LLInventoryAction::sDeleteConfirmationDisplayed = true; + } + + LLSD args; + args["QUESTION"] = LLTrans::getString("DeleteItem"); + LLNotificationsUtil::add("DeleteItems", args, LLSD(), boost::bind(&LLInventoryGallery::onDelete, _1, _2, mSelectedItemIDs)); + } } bool LLInventoryGallery::canDeleteSelection() diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 50eefc7d25..d4cf9c2f9f 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -542,6 +542,7 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men } items.push_back(std::string("Cut")); items.push_back(std::string("Delete")); + // TODO: check descendants!!! if(!get_is_category_removable(&gInventory, selected_id)) { disabled_items.push_back(std::string("Delete")); @@ -577,11 +578,15 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men { items.push_back(std::string("Delete")); } - if(!get_is_item_removable(&gInventory, selected_id, true)) + if (!get_is_item_removable(&gInventory, selected_id, false)) { disabled_items.push_back(std::string("Delete")); disabled_items.push_back(std::string("Cut")); } + else if(!get_is_item_removable(&gInventory, selected_id, true)) + { + disabled_items.push_back(std::string("Cut")); + } if (selected_item && (selected_item->getInventoryType() != LLInventoryType::IT_CALLINGCARD) && !is_inbox && selected_item->getPermissions().allowOperationBy(PERM_MODIFY, gAgent.getID())) { -- cgit v1.3 From 7d82ee8075e81a6d3640103b68e98a6a2cbbe623 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 17 Oct 2023 01:17:51 +0300 Subject: SL-20232 Allow deletion of folders with worn content in gallery view #4 --- indra/newview/llinventorygallery.cpp | 86 +++++++++++++++++++++++++------- indra/newview/llinventorygallerymenu.cpp | 7 ++- 2 files changed, 73 insertions(+), 20 deletions(-) (limited to 'indra/newview/llinventorygallery.cpp') diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index 23a00e2e51..058bbde8b9 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -1866,29 +1866,49 @@ void LLInventoryGallery::onDelete(const LLSD& notification, const LLSD& response { bool has_worn = notification["payload"]["has_worn"].asBoolean(); uuid_vec_t worn; - for (const LLUUID& id : selected_ids) + uuid_vec_t deletion_list; + for (const LLUUID& obj_id : selected_ids) { - LLInventoryObject* obj = gInventory.getObject(id); - if (!obj) + LLViewerInventoryCategory* cat = gInventory.getCategory(obj_id); + if (cat) { - return; - } - if (obj->getType() == LLAssetType::AT_CATEGORY) - { - if (get_is_category_removable(&gInventory, id)) + bool cat_has_worn = false; + if (has_worn) { - gInventory.removeCategory(id); + LLInventoryModel::cat_array_t categories; + LLInventoryModel::item_array_t items; + + gInventory.collectDescendents(obj_id, categories, items, FALSE); + + for (LLInventoryModel::item_array_t::value_type& item : items) + { + if (get_is_item_worn(item)) + { + worn.push_back(item->getUUID()); + cat_has_worn = true; + } + } + } + if (cat_has_worn) + { + deletion_list.push_back(obj_id); + } + else + { + gInventory.removeCategory(obj_id); } } - else + LLViewerInventoryItem* item = gInventory.getItem(obj_id); + if (item) { - if (get_is_item_removable(&gInventory, id, true)) + if (has_worn && get_is_item_worn(item)) { - gInventory.removeItem(id); + worn.push_back(item->getUUID()); + deletion_list.push_back(item->getUUID()); } - else if (has_worn && get_is_item_worn(id)) + else { - worn.push_back(id); + gInventory.removeItem(obj_id); } } } @@ -1897,9 +1917,9 @@ void LLInventoryGallery::onDelete(const LLSD& notification, const LLSD& response { // should fire once after every item gets detached LLAppearanceMgr::instance().removeItemsFromAvatar(worn, - [worn]() + [deletion_list]() { - for (const LLUUID& id : worn) + for (const LLUUID& id : deletion_list) { remove_inventory_item(id, NULL); } @@ -1914,10 +1934,40 @@ void LLInventoryGallery::deleteSelection() bool needs_replacement = false; for (const LLUUID& id : mSelectedItemIDs) { - if (get_is_item_worn(id)) + LLViewerInventoryCategory* cat = gInventory.getCategory(id); + if (cat) + { + LLInventoryModel::cat_array_t categories; + LLInventoryModel::item_array_t items; + + gInventory.collectDescendents(id, categories, items, FALSE); + + for (LLInventoryModel::item_array_t::value_type& item : items) + { + if (get_is_item_worn(item)) + { + has_worn = true; + LLWearableType::EType type = item->getWearableType(); + if (type == LLWearableType::WT_SHAPE + || type == LLWearableType::WT_SKIN + || type == LLWearableType::WT_HAIR + || type == LLWearableType::WT_EYES) + { + needs_replacement = true; + break; + } + } + } + if (needs_replacement) + { + break; + } + } + + LLViewerInventoryItem* item = gInventory.getItem(id); + if (item && get_is_item_worn(item)) { has_worn = true; - const LLViewerInventoryItem* item = gInventory.getItem(id); LLWearableType::EType type = item->getWearableType(); if (type == LLWearableType::WT_SHAPE || type == LLWearableType::WT_SKIN diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 49969e1a52..2bca33dec4 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -425,7 +425,6 @@ bool is_category_removable(const LLUUID &folder_id, bool check_worn) return true; } - void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* menu) { LLUUID selected_id = mUUIDs.front(); @@ -581,11 +580,15 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men items.push_back(std::string("Cut")); items.push_back(std::string("Delete")); - if(!is_category_removable(selected_id, true)) + if(!is_category_removable(selected_id, false)) { disabled_items.push_back(std::string("Delete")); disabled_items.push_back(std::string("Cut")); } + else if (!is_category_removable(selected_id, true)) + { + disabled_items.push_back(std::string("Cut")); + } if(!is_inbox) { -- cgit v1.3 From e233e4fb50e513b58f4452086182b60b25440fac Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 17 Oct 2023 01:35:47 +0300 Subject: SL-20232 Allow deletion of worn items #5 --- indra/newview/llinventorybridge.cpp | 2 +- indra/newview/llinventoryfunctions.cpp | 15 ++++++++++----- indra/newview/llinventorygallery.cpp | 15 ++++++++++----- 3 files changed, 21 insertions(+), 11 deletions(-) (limited to 'indra/newview/llinventorygallery.cpp') diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 02ca331bff..a12c4f7f76 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -4504,7 +4504,7 @@ void LLFolderBridge::buildContextMenuFolderOptions(U32 flags, menuentry_vec_t& return; } - if (!isItemRemovable()) + if (!isItemRemovable(false)) { disabled_items.push_back(std::string("Delete")); } diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 849f641758..c2cbf4b8ac 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -3441,7 +3441,8 @@ void LLInventoryAction::onItemsRemovalConfirmation(const LLSD& notification, con // removeSelectedItems will change selection, collect worn items beforehand uuid_vec_t worn; - uuid_vec_t deletion_list; + uuid_vec_t item_deletion_list; + uuid_vec_t cat_deletion_list; if (has_worn) { //Get selected items @@ -3473,14 +3474,14 @@ void LLInventoryAction::onItemsRemovalConfirmation(const LLSD& notification, con } if (cat_has_worn) { - deletion_list.push_back(obj_id); + cat_deletion_list.push_back(obj_id); } } LLViewerInventoryItem* item = gInventory.getItem(obj_id); if (item && get_is_item_worn(item)) { worn.push_back(obj_id); - deletion_list.push_back(obj_id); + item_deletion_list.push_back(obj_id); } } } @@ -3495,12 +3496,16 @@ void LLInventoryAction::onItemsRemovalConfirmation(const LLSD& notification, con { // should fire once after every item gets detached LLAppearanceMgr::instance().removeItemsFromAvatar(worn, - [deletion_list]() + [item_deletion_list, cat_deletion_list]() { - for (const LLUUID& id : deletion_list) + for (const LLUUID& id : item_deletion_list) { remove_inventory_item(id, NULL); } + for (const LLUUID& id : cat_deletion_list) + { + remove_inventory_category(id, NULL); + } }); } diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index 058bbde8b9..d5fce2cda7 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -1866,7 +1866,8 @@ void LLInventoryGallery::onDelete(const LLSD& notification, const LLSD& response { bool has_worn = notification["payload"]["has_worn"].asBoolean(); uuid_vec_t worn; - uuid_vec_t deletion_list; + uuid_vec_t item_deletion_list; + uuid_vec_t cat_deletion_list; for (const LLUUID& obj_id : selected_ids) { LLViewerInventoryCategory* cat = gInventory.getCategory(obj_id); @@ -1891,7 +1892,7 @@ void LLInventoryGallery::onDelete(const LLSD& notification, const LLSD& response } if (cat_has_worn) { - deletion_list.push_back(obj_id); + cat_deletion_list.push_back(obj_id); } else { @@ -1904,7 +1905,7 @@ void LLInventoryGallery::onDelete(const LLSD& notification, const LLSD& response if (has_worn && get_is_item_worn(item)) { worn.push_back(item->getUUID()); - deletion_list.push_back(item->getUUID()); + item_deletion_list.push_back(item->getUUID()); } else { @@ -1917,12 +1918,16 @@ void LLInventoryGallery::onDelete(const LLSD& notification, const LLSD& response { // should fire once after every item gets detached LLAppearanceMgr::instance().removeItemsFromAvatar(worn, - [deletion_list]() + [item_deletion_list, cat_deletion_list]() { - for (const LLUUID& id : deletion_list) + for (const LLUUID& id : item_deletion_list) { remove_inventory_item(id, NULL); } + for (const LLUUID& id : cat_deletion_list) + { + remove_inventory_category(id, NULL); + } }); } } -- cgit v1.3 From bf740d67a6c68a94cc79fd25478bdb6fb6443fa3 Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Thu, 9 Nov 2023 22:08:39 +0200 Subject: SL-20576 FIXED Viewer crashes when clicking scroll bar after switching views --- indra/newview/llinventorygallery.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llinventorygallery.cpp') diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index d5fce2cda7..ad6c3909ef 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -1435,7 +1435,7 @@ void LLInventoryGallery::onFocusReceived() LLInventoryGalleryItem* focus_item = NULL; for (const LLUUID& id : mSelectedItemIDs) { - if (mItemMap[id]) + if (mItemMap[id] && !mItemMap[id]->isHidden()) { focus_item = mItemMap[id]; focus_item->setSelected(true); -- cgit v1.3 From aff01e2fd4fb5475eb42ce58d1ad997341cb7a94 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 10 Nov 2023 23:36:33 +0200 Subject: SL-20575 Fix some deletion issues - Fixes 'cut' checks for gallery - Checking if large folder is deletable should be faster now - For large flat root folders eliminated delay of looking for cof Might be a good idea to start cashing isItemRemovable if category version hasn't changed. --- indra/newview/llappearancemgr.cpp | 48 +++++++++++++++++--- indra/newview/llappearancemgr.h | 9 +++- indra/newview/llinventorybridge.cpp | 42 +++--------------- indra/newview/llinventoryfunctions.cpp | 76 +++++++++++++++++++++++++++++--- indra/newview/llinventoryfunctions.h | 1 + indra/newview/llinventorygallery.cpp | 41 ++++++++++++++++- indra/newview/llinventorygallerymenu.cpp | 43 ++---------------- indra/newview/llstartup.cpp | 6 ++- 8 files changed, 176 insertions(+), 90 deletions(-) (limited to 'indra/newview/llinventorygallery.cpp') diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 8673dc6a33..10b3f4b573 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -1399,7 +1399,7 @@ const std::string LLAppearanceMgr::sExpectedTextureName = "OutfitPreview"; const LLUUID LLAppearanceMgr::getCOF() const { - return gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); + return mCOFID; } S32 LLAppearanceMgr::getCOFVersion() const @@ -1415,6 +1415,11 @@ S32 LLAppearanceMgr::getCOFVersion() const } } +void LLAppearanceMgr::initCOFID() +{ + mCOFID = gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); +} + const LLViewerInventoryItem* LLAppearanceMgr::getBaseOutfitLink() { const LLUUID& current_outfit_cat = getCOF(); @@ -3749,6 +3754,14 @@ LLSD LLAppearanceMgr::dumpCOF() const return result; } +void LLAppearanceMgr::cleanup() +{ + mIsInUpdateAppearanceFromCOF = false; + mOutstandingAppearanceBakeRequest = false; + mRerequestAppearanceBake = false; + mCOFID.setNull(); +} + // static void LLAppearanceMgr::onIdle(void *) { @@ -4387,20 +4400,45 @@ BOOL LLAppearanceMgr::getIsInCOF(const LLUUID& obj_id) const return FALSE; } -BOOL LLAppearanceMgr::getIsProtectedCOFItem(const LLUUID& obj_id) const +bool LLAppearanceMgr::getIsInCOF(const LLInventoryObject* obj) const { - if (!getIsInCOF(obj_id)) return FALSE; + const LLUUID& cof = getCOF(); + if (obj->getUUID() == cof) + return true; + if (obj && obj->getParentUUID() == cof) + return true; + return false; +} + +bool LLAppearanceMgr::getIsProtectedCOFItem(const LLUUID& obj_id) const +{ + if (!getIsInCOF(obj_id)) return false; // If a non-link somehow ended up in COF, allow deletion. const LLInventoryObject *obj = gInventory.getObject(obj_id); if (obj && !obj->getIsLinkType()) { - return FALSE; + return false; } // For now, don't allow direct deletion from the COF. Instead, force users // to choose "Detach" or "Take Off". - return TRUE; + return true; +} + +bool LLAppearanceMgr::getIsProtectedCOFItem(const LLInventoryObject* obj) const +{ + if (!getIsInCOF(obj)) return false; + + // If a non-link somehow ended up in COF, allow deletion. + if (obj && !obj->getIsLinkType()) + { + return false; + } + + // For now, don't allow direct deletion from the COF. Instead, force users + // to choose "Detach" or "Take Off". + return true; } class CallAfterCategoryFetchStage2: public LLInventoryFetchItemsObserver diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index 80d6587ad3..02859dc12c 100644 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -111,9 +111,11 @@ public: // Find the Current Outfit folder. const LLUUID getCOF() const; S32 getCOFVersion() const; + void initCOFID(); // Debugging - get truncated LLSD summary of COF contents. LLSD dumpCOF() const; + void cleanup(); // Finds the folder link to the currently worn outfit const LLViewerInventoryItem *getBaseOutfitLink(); @@ -276,6 +278,7 @@ private: attachments_changed_signal_t mAttachmentsChangeSignal; LLUUID mCOFImageID; + LLUUID mCOFID; std::unique_ptr mUnlockOutfitTimer; @@ -290,8 +293,10 @@ private: public: // Is this in the COF? BOOL getIsInCOF(const LLUUID& obj_id) const; - // Is this in the COF and can the user delete it from the COF? - BOOL getIsProtectedCOFItem(const LLUUID& obj_id) const; + bool getIsInCOF(const LLInventoryObject* obj) const; + // Is this in the COF and can the user delete it from the COF? + bool getIsProtectedCOFItem(const LLUUID& obj_id) const; + bool getIsProtectedCOFItem(const LLInventoryObject* obj) const; // Outfits will prioritize textures with such name to use for preview in gallery static const std::string sExpectedTextureName; diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index a12c4f7f76..4fb60b4c55 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -2399,49 +2399,19 @@ void LLFolderBridge::update() } } - -// Iterate through a folder's children to determine if -// all the children are removable. -class LLIsItemRemovable : public LLFolderViewFunctor -{ -public: - LLIsItemRemovable(bool check_worn = true) : mPassed(TRUE), mCheckWorn(check_worn) {} - virtual void doFolder(LLFolderViewFolder* folder) - { - mPassed &= folder->getViewModelItem()->isItemRemovable(mCheckWorn); - } - virtual void doItem(LLFolderViewItem* item) - { - mPassed &= item->getViewModelItem()->isItemRemovable(mCheckWorn); - } - BOOL mPassed; - bool mCheckWorn; -}; - // Can be destroyed (or moved to trash) BOOL LLFolderBridge::isItemRemovable(bool check_worn) const { - if (!get_is_category_removable(getInventoryModel(), mUUID)) + if (!get_is_category_and_children_removable(getInventoryModel(), mUUID, check_worn)) { return FALSE; } - LLInventoryPanel* panel = mInventoryPanel.get(); - LLFolderViewFolder* folderp = dynamic_cast(panel ? panel->getItemByID(mUUID) : NULL); - if (folderp) - { - LLIsItemRemovable folder_test(check_worn); - folderp->applyFunctorToChildren(folder_test); - if (!folder_test.mPassed) - { - return FALSE; - } - } - - if (isMarketplaceListingsFolder() && (!LLMarketplaceData::instance().isSLMDataFetched() || LLMarketplaceData::instance().getActivationState(mUUID))) - { - return FALSE; - } + if (isMarketplaceListingsFolder() + && (!LLMarketplaceData::instance().isSLMDataFetched() || LLMarketplaceData::instance().getActivationState(mUUID))) + { + return FALSE; + } return TRUE; } diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index c2cbf4b8ac..5d6bf8ab4b 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -621,7 +621,7 @@ BOOL get_is_item_worn(const LLUUID& id, const LLViewerInventoryItem* item) BOOL get_is_item_worn(const LLUUID& id) { const LLViewerInventoryItem* item = gInventory.getItem(id); - return get_is_item_worn(item); + return get_is_item_worn(id, item); } BOOL get_is_item_worn(const LLViewerInventoryItem* item) @@ -711,20 +711,20 @@ bool get_is_item_removable(const LLInventoryModel* model, const LLUUID& id, bool // Disable delete from COF folder; have users explicitly choose "detach/take off", // unless the item is not worn but in the COF (i.e. is bugged). - if (LLAppearanceMgr::instance().getIsProtectedCOFItem(id)) + const LLViewerInventoryItem* obj = model->getItem(id); + if (LLAppearanceMgr::instance().getIsProtectedCOFItem(obj)) { - if (get_is_item_worn(id)) + if (get_is_item_worn(id, obj)) { return false; } } - const LLInventoryObject *obj = model->getItem(id); if (obj && obj->getIsLinkType()) { return true; } - if (check_worn && get_is_item_worn(id)) + if (check_worn && get_is_item_worn(id, obj)) { return false; } @@ -819,6 +819,72 @@ BOOL get_is_category_removable(const LLInventoryModel* model, const LLUUID& id) return TRUE; } +bool get_is_category_and_children_removable(LLInventoryModel* model, const LLUUID& folder_id, bool check_worn) +{ + if (!get_is_category_removable(model, folder_id)) + { + return false; + } + + const LLUUID mp_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS); + if (mp_id.notNull() && gInventory.isObjectDescendentOf(folder_id, mp_id)) + { + return false; + } + + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + model->collectDescendents( + folder_id, + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH); + + for (LLInventoryModel::item_array_t::value_type& item : item_array) + { + // Disable delete from COF folder; have users explicitly choose "detach/take off", + // unless the item is not worn but in the COF (i.e. is bugged). + if (LLAppearanceMgr::instance().getIsProtectedCOFItem(item)) + { + if (get_is_item_worn(item)) + { + return false; + } + } + + if (item && item->getIsLinkType()) + { + return true; + } + if (check_worn && get_is_item_worn(item)) + { + return false; + } + } + + const LLViewerInventoryItem* base_outfit_link = LLAppearanceMgr::instance().getBaseOutfitLink(); + LLViewerInventoryCategory* outfit_linked_category = base_outfit_link ? base_outfit_link->getLinkedCategory() : nullptr; + for (LLInventoryModel::cat_array_t::value_type& cat : cat_array) + { + const LLFolderType::EType folder_type = cat->getPreferredType(); + if (LLFolderType::lookupIsProtectedType(folder_type)) + { + return false; + } + + // Can't delete the outfit that is currently being worn. + if (folder_type == LLFolderType::FT_OUTFIT) + { + if (cat == outfit_linked_category) + { + return false; + } + } + } + + return true; +} + BOOL get_is_category_renameable(const LLInventoryModel* model, const LLUUID& id) { if (!model) diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h index a8a9bb9735..deacaced42 100644 --- a/indra/newview/llinventoryfunctions.h +++ b/indra/newview/llinventoryfunctions.h @@ -59,6 +59,7 @@ bool get_is_item_editable(const LLUUID& inv_item_id); void handle_item_edit(const LLUUID& inv_item_id); BOOL get_is_category_removable(const LLInventoryModel* model, const LLUUID& id); +bool get_is_category_and_children_removable(LLInventoryModel* model, const LLUUID& folder_id, bool check_worn); BOOL get_is_category_renameable(const LLInventoryModel* model, const LLUUID& id); diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index ad6c3909ef..3c3da253d3 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -1668,6 +1668,45 @@ void LLInventoryGallery::cut() mFilterSubString.clear(); } + + +bool is_category_removable(const LLUUID& folder_id, bool check_worn) +{ + if (!get_is_category_removable(&gInventory, folder_id)) + { + return false; + } + + // check children + LLInventoryModel::cat_array_t* cat_array; + LLInventoryModel::item_array_t* item_array; + gInventory.getDirectDescendentsOf(folder_id, cat_array, item_array); + + for (LLInventoryModel::item_array_t::value_type& item : *item_array) + { + if (!get_is_item_removable(&gInventory, item->getUUID(), check_worn)) + { + return false; + } + } + + for (LLInventoryModel::cat_array_t::value_type& cat : *cat_array) + { + if (!is_category_removable(cat->getUUID(), check_worn)) + { + return false; + } + } + + const LLUUID mp_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS); + if (mp_id.notNull() && gInventory.isObjectDescendentOf(folder_id, mp_id)) + { + return false; + } + + return true; +} + BOOL LLInventoryGallery::canCut() const { if (!getVisible() || !getEnabled() || mSelectedItemIDs.empty()) @@ -1680,7 +1719,7 @@ BOOL LLInventoryGallery::canCut() const LLViewerInventoryCategory* cat = gInventory.getCategory(id); if (cat) { - if (!get_is_category_removable(&gInventory, id)) + if (!get_is_category_and_children_removable(&gInventory, id, true)) { return FALSE; } diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 2bca33dec4..4b47346473 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -388,43 +388,6 @@ bool is_inbox_folder(LLUUID item_id) return gInventory.isObjectDescendentOf(item_id, inbox_id); } -bool is_category_removable(const LLUUID &folder_id, bool check_worn) -{ - if (!get_is_category_removable(&gInventory, folder_id)) - { - return false; - } - - // check children - LLInventoryModel::cat_array_t* cat_array; - LLInventoryModel::item_array_t* item_array; - gInventory.getDirectDescendentsOf(folder_id, cat_array, item_array); - - for (LLInventoryModel::item_array_t::value_type& item : *item_array) - { - if (!get_is_item_removable(&gInventory, item->getUUID(), check_worn)) - { - return false; - } - } - - for (LLInventoryModel::cat_array_t::value_type& cat : *cat_array) - { - if (!is_category_removable(cat->getUUID(), check_worn)) - { - return false; - } - } - - const LLUUID mp_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS); - if (mp_id.notNull() && gInventory.isObjectDescendentOf(folder_id, mp_id)) - { - return false; - } - - return true; -} - void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* menu) { LLUUID selected_id = mUUIDs.front(); @@ -532,7 +495,7 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men } } items.push_back(std::string("Purge Item")); - if (is_folder && !is_category_removable(selected_id, true)) + if (is_folder && !get_is_category_and_children_removable(&gInventory, selected_id, true)) { disabled_items.push_back(std::string("Purge Item")); } @@ -580,12 +543,12 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men items.push_back(std::string("Cut")); items.push_back(std::string("Delete")); - if(!is_category_removable(selected_id, false)) + if(!get_is_category_and_children_removable(&gInventory, selected_id, false)) { disabled_items.push_back(std::string("Delete")); disabled_items.push_back(std::string("Cut")); } - else if (!is_category_removable(selected_id, true)) + else if (!get_is_category_and_children_removable(&gInventory, selected_id, true)) { disabled_items.push_back(std::string("Cut")); } diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 916848ff5f..bb867f7b23 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -1938,8 +1938,10 @@ bool idle_startup() display_startup(); return FALSE; } + LLInventoryModelBackgroundFetch::instance().start(); - LLUUID cof_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); + LLAppearanceMgr::instance().initCOFID(); + LLUUID cof_id = LLAppearanceMgr::instance().getCOF(); LLViewerInventoryCategory* cof = gInventory.getCategory(cof_id); if (cof && cof->getVersion() == LLViewerInventoryCategory::VERSION_UNKNOWN) @@ -2812,6 +2814,7 @@ void LLStartUp::loadInitialOutfit( const std::string& outfit_folder_name, LLAppearanceMgr::instance().setAttachmentInvLinkEnable(true); // Initiate creation of COF, since we're also bypassing that. gInventory.ensureCategoryForTypeExists(LLFolderType::FT_CURRENT_OUTFIT); + LLAppearanceMgr::getInstance()->initCOFID(); ESex gender; if (gender_name == "male") @@ -2968,6 +2971,7 @@ void reset_login() gAgent.cleanup(); gSky.cleanup(); // mVOSkyp is an inworld object. LLWorld::getInstance()->resetClass(); + LLAppearanceMgr::getInstance()->cleanup(); if ( gViewerWindow ) { // Hide menus and normal buttons -- cgit v1.3