From 7748898b25202b5c90f676bd8e3e8a258a307723 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> Date: Fri, 26 Sep 2025 23:44:12 +0300 Subject: [PATCH 1/4] #4739 Wearables sort order reliability --- indra/newview/llagentwearables.cpp | 23 ++++++++++- indra/newview/llagentwearables.h | 1 + indra/newview/llappearancemgr.cpp | 63 ++++++++++++++++++----------- indra/newview/llviewerinventory.cpp | 4 +- 4 files changed, 66 insertions(+), 25 deletions(-) diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp index 25f5cbd78f..a075b6f004 100644 --- a/indra/newview/llagentwearables.cpp +++ b/indra/newview/llagentwearables.cpp @@ -538,6 +538,27 @@ LLInventoryItem* LLAgentWearables::getWearableInventoryItem(LLWearableType::ETyp return item; } +const S32 LLAgentWearables::getWearableIdxFromItem(const LLViewerInventoryItem* item) const +{ + if (!item) return -1; + if (!item->isWearableType()) return -1; + + LLWearableType::EType type = item->getWearableType(); + U32 wearable_count = getWearableCount(type); + if (0 == wearable_count) return -1; + + const LLUUID& asset_id = item->getAssetUUID(); + + for (U32 i = 0; i < wearable_count; ++i) + { + const LLViewerWearable* wearable = getViewerWearable(type, i); + if (!wearable) continue; + if (wearable->getAssetID() != asset_id) continue; + return i; + } + + return -1; +} const LLViewerWearable* LLAgentWearables::getWearableFromItemID(const LLUUID& item_id) const { const LLUUID& base_item_id = gInventory.getLinkedItemID(item_id); @@ -1471,7 +1492,7 @@ bool LLAgentWearables::moveWearable(const LLViewerInventoryItem* item, bool clos LLWearableType::EType type = item->getWearableType(); U32 wearable_count = getWearableCount(type); - if (0 == wearable_count) return false; + if (wearable_count < 2) return false; const LLUUID& asset_id = item->getAssetUUID(); diff --git a/indra/newview/llagentwearables.h b/indra/newview/llagentwearables.h index 3b8ff93c76..1e118ffa98 100644 --- a/indra/newview/llagentwearables.h +++ b/indra/newview/llagentwearables.h @@ -87,6 +87,7 @@ public: public: const LLUUID getWearableItemID(LLWearableType::EType type, U32 index /*= 0*/) const; const LLUUID getWearableAssetID(LLWearableType::EType type, U32 index /*= 0*/) const; + const S32 getWearableIdxFromItem(const LLViewerInventoryItem* item) const; const LLViewerWearable* getWearableFromItemID(const LLUUID& item_id) const; LLViewerWearable* getWearableFromItemID(const LLUUID& item_id); LLViewerWearable* getWearableFromAssetID(const LLUUID& asset_id); diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 6fa23727b1..caf3990801 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -4218,37 +4218,54 @@ bool LLAppearanceMgr::moveWearable(LLViewerInventoryItem* item, bool closer_to_b if (item->getType() != LLAssetType::AT_CLOTHING) return false; if (!gInventory.isObjectDescendentOf(item->getUUID(), getCOF())) return false; + S32 pos = gAgentWearables.getWearableIdxFromItem(item); + if (pos < 0) return false; // Not found + + U32 count = gAgentWearables.getWearableCount(item->getWearableType()); + if (count < 2) return false; // Nothing to swap with + if (closer_to_body) + { + if (pos == 0) return false; // already first + } + else + { + if (pos == count - 1) return false; // already last + } + + U32 old_pos = (U32)pos; + U32 swap_with = closer_to_body ? old_pos - 1 : old_pos + 1; + LLUUID swap_item_id = gAgentWearables.getWearableItemID(item->getWearableType(), swap_with); + + // Find link item from item id. LLInventoryModel::cat_array_t cats; LLInventoryModel::item_array_t items; LLFindWearablesOfType filter_wearables_of_type(item->getWearableType()); gInventory.collectDescendentsIf(getCOF(), cats, items, true, filter_wearables_of_type); if (items.empty()) return false; - // We assume that the items have valid descriptions. - std::sort(items.begin(), items.end(), WearablesOrderComparator(item->getWearableType())); + LLViewerInventoryItem* swap_item = nullptr; + for (auto iter : items) + { + if (iter->getLinkedUUID() == swap_item_id) + { + swap_item = iter.get(); + break; + } + } + if (!swap_item) + { + return false; + } - if (closer_to_body && items.front() == item) return false; - if (!closer_to_body && items.back() == item) return false; + // Description is supposed to hold sort index, but user could have changed + // order rapidly and there might be a state mismatch between description + // and gAgentWearables, trust gAgentWearables over description. + // Generate new description. + std::string new_desc = build_order_string(item->getWearableType(), old_pos); + swap_item->setDescription(new_desc); + new_desc = build_order_string(item->getWearableType(), swap_with); + item->setDescription(new_desc); - LLInventoryModel::item_array_t::iterator it = std::find(items.begin(), items.end(), item); - if (items.end() == it) return false; - - - //swapping descriptions - closer_to_body ? --it : ++it; - LLViewerInventoryItem* swap_item = *it; - if (!swap_item) return false; - std::string tmp = swap_item->getActualDescription(); - swap_item->setDescription(item->getActualDescription()); - item->setDescription(tmp); - - // LL_DEBUGS("Inventory") << "swap, item " - // << ll_pretty_print_sd(item->asLLSD()) - // << " swap_item " - // << ll_pretty_print_sd(swap_item->asLLSD()) << LL_ENDL; - - // FIXME switch to use AISv3 where supported. - //items need to be updated on a dataserver item->setComplete(true); item->updateServer(false); gInventory.updateItem(item); diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 6155058f14..ec5381ddfc 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -419,7 +419,9 @@ void LLViewerInventoryItem::updateServer(bool is_new) const << LL_ENDL; return; } - if(gAgent.getID() != mPermissions.getOwner()) + LLUUID owner = mPermissions.getOwner(); + if(gAgent.getID() != owner + && owner.notNull()) // incomplete? { // *FIX: deal with this better. LL_WARNS(LOG_INV) << "LLViewerInventoryItem::updateServer() - for unowned item " From d5e8f51b615cee91bf072e2c3b111c7f5af0e052 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> Date: Mon, 29 Sep 2025 21:51:30 +0300 Subject: [PATCH 2/4] #4750 Crash in LLToolBarView::handleDropTool --- indra/llui/lltoolbar.cpp | 2 +- indra/llui/lltoolbar.h | 2 +- indra/newview/llfloatertoybox.cpp | 2 +- indra/newview/lltoolbarview.cpp | 29 +++++++++++++++++++---------- indra/newview/lltoolbarview.h | 2 +- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 5955a28fa3..56ab6e9bae 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -1054,7 +1054,7 @@ bool LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop, // if drop is set, it's time to call the callback to get the operation done if (handled && drop) { - handled = mHandleDropCallback(cargo_data, x, y, this); + handled = mHandleDropCallback(cargo_data, cargo_type, x, y, this); } // We accept only single tool drop on toolbars diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 5556406fbd..a3f044c256 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -41,7 +41,7 @@ class LLIconCtrl; typedef boost::function tool_startdrag_callback_t; typedef boost::function tool_handledrag_callback_t; -typedef boost::function tool_handledrop_callback_t; +typedef boost::function tool_handledrop_callback_t; class LLToolBarButton : public LLButton { diff --git a/indra/newview/llfloatertoybox.cpp b/indra/newview/llfloatertoybox.cpp index f6257dbd3d..5e3ec366d5 100644 --- a/indra/newview/llfloatertoybox.cpp +++ b/indra/newview/llfloatertoybox.cpp @@ -63,7 +63,7 @@ bool LLFloaterToybox::postBuild() mToolBar->setStartDragCallback(boost::bind(LLToolBarView::startDragTool,_1,_2,_3)); mToolBar->setHandleDragCallback(boost::bind(LLToolBarView::handleDragTool,_1,_2,_3,_4)); - mToolBar->setHandleDropCallback(boost::bind(LLToolBarView::handleDropTool,_1,_2,_3,_4)); + mToolBar->setHandleDropCallback(boost::bind(LLToolBarView::handleDropTool,_1,_2,_3,_4,_5)); mToolBar->setButtonEnterCallback(boost::bind(&LLFloaterToybox::onToolBarButtonEnter,this,_1)); // diff --git a/indra/newview/lltoolbarview.cpp b/indra/newview/lltoolbarview.cpp index 0063e0b7fd..c1ec5fa183 100644 --- a/indra/newview/lltoolbarview.cpp +++ b/indra/newview/lltoolbarview.cpp @@ -110,7 +110,7 @@ bool LLToolBarView::postBuild() { mToolbars[i]->setStartDragCallback(boost::bind(LLToolBarView::startDragTool,_1,_2,_3)); mToolbars[i]->setHandleDragCallback(boost::bind(LLToolBarView::handleDragTool,_1,_2,_3,_4)); - mToolbars[i]->setHandleDropCallback(boost::bind(LLToolBarView::handleDropTool,_1,_2,_3,_4)); + mToolbars[i]->setHandleDropCallback(boost::bind(LLToolBarView::handleDropTool,_1,_2,_3,_4,_5)); mToolbars[i]->setButtonAddCallback(boost::bind(LLToolBarView::onToolBarButtonAdded,_1)); mToolbars[i]->setButtonRemoveCallback(boost::bind(LLToolBarView::onToolBarButtonRemoved,_1)); } @@ -624,8 +624,14 @@ bool LLToolBarView::handleDragTool( S32 x, S32 y, const LLUUID& uuid, LLAssetTyp return false; } -bool LLToolBarView::handleDropTool( void* cargo_data, S32 x, S32 y, LLToolBar* toolbar) +bool LLToolBarView::handleDropTool( void* cargo_data, EDragAndDropType cargo_type, S32 x, S32 y, LLToolBar* toolbar) { + if (cargo_type == DAD_PERSON) + { + // DAD_PERSON means that cargo_data contains an uuid, not an LLInventoryObject + resetDragTool(NULL); + return false; + } bool handled = false; LLInventoryObject* inv_item = static_cast(cargo_data); @@ -647,15 +653,18 @@ bool LLToolBarView::handleDropTool( void* cargo_data, S32 x, S32 y, LLToolBar* t if (old_toolbar_loc != LLToolBarEnums::TOOLBAR_NONE) { llassert(gToolBarView->mDragToolbarButton); - old_toolbar = gToolBarView->mDragToolbarButton->getParentByType(); - if (old_toolbar->isReadOnly() && toolbar->isReadOnly()) + if (gToolBarView->mDragToolbarButton) { - // do nothing - } - else - { - int old_rank = LLToolBar::RANK_NONE; - gToolBarView->removeCommand(command_id, old_rank); + old_toolbar = gToolBarView->mDragToolbarButton->getParentByType(); + if (old_toolbar->isReadOnly() && toolbar->isReadOnly()) + { + // do nothing + } + else + { + int old_rank = LLToolBar::RANK_NONE; + gToolBarView->removeCommand(command_id, old_rank); + } } } diff --git a/indra/newview/lltoolbarview.h b/indra/newview/lltoolbarview.h index 7cecd81052..7212f099b7 100644 --- a/indra/newview/lltoolbarview.h +++ b/indra/newview/lltoolbarview.h @@ -92,7 +92,7 @@ public: static void startDragTool(S32 x, S32 y, LLToolBarButton* toolbarButton); static bool handleDragTool(S32 x, S32 y, const LLUUID& uuid, LLAssetType::EType type); - static bool handleDropTool(void* cargo_data, S32 x, S32 y, LLToolBar* toolbar); + static bool handleDropTool(void* cargo_data, EDragAndDropType cargo_type, S32 x, S32 y, LLToolBar* toolbar); static void resetDragTool(LLToolBarButton* toolbarButton); LLInventoryObject* getDragItem(); LLView* getBottomToolbar() { return mBottomToolbarPanel; } From f25314737f3599d9d44fac77f7cfb7b1f0648fff Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> Date: Mon, 29 Sep 2025 22:20:29 +0300 Subject: [PATCH 3/4] #4753 Crash at LLScriptFloater::setNotificationId --- indra/newview/llscriptfloater.cpp | 34 ++++++++++++++++--------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/indra/newview/llscriptfloater.cpp b/indra/newview/llscriptfloater.cpp index 22a9dd0027..2fdec14f6d 100644 --- a/indra/newview/llscriptfloater.cpp +++ b/indra/newview/llscriptfloater.cpp @@ -109,25 +109,27 @@ bool LLScriptFloater::toggle(const LLUUID& notification_id) LLScriptFloater* LLScriptFloater::show(const LLUUID& notification_id) { LLScriptFloater* floater = LLFloaterReg::getTypedInstance("script_floater", notification_id); - floater->setNotificationId(notification_id); - floater->createForm(notification_id); - - //LLDialog(LLGiveInventory and LLLoadURL) should no longer steal focus (see EXT-5445) - floater->setAutoFocus(false); - - if(LLScriptFloaterManager::OBJ_SCRIPT == LLScriptFloaterManager::getObjectType(notification_id)) + if (floater) { - floater->setSavePosition(true); - floater->restorePosition(); - } - else - { - floater->dockToChiclet(true); - } + floater->setNotificationId(notification_id); + floater->createForm(notification_id); - //LLDialog(LLGiveInventory and LLLoadURL) should no longer steal focus (see EXT-5445) - LLFloaterReg::showTypedInstance("script_floater", notification_id, false); + //LLDialog(LLGiveInventory and LLLoadURL) should no longer steal focus (see EXT-5445) + floater->setAutoFocus(false); + if (LLScriptFloaterManager::OBJ_SCRIPT == LLScriptFloaterManager::getObjectType(notification_id)) + { + floater->setSavePosition(true); + floater->restorePosition(); + } + else + { + floater->dockToChiclet(true); + } + + //LLDialog(LLGiveInventory and LLLoadURL) should no longer steal focus (see EXT-5445) + LLFloaterReg::showTypedInstance("script_floater", notification_id, false); + } return floater; } From ec3fe8c2a56d92c5eff480d7f027a1b6062bb4cf Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> Date: Mon, 29 Sep 2025 23:40:41 +0300 Subject: [PATCH 4/4] #3189 Fix missed else condition --- indra/newview/llgltfmateriallist.cpp | 4 +++- indra/newview/llselectmgr.cpp | 16 +--------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp index 8da835ed7d..3e4aadc381 100644 --- a/indra/newview/llgltfmateriallist.cpp +++ b/indra/newview/llgltfmateriallist.cpp @@ -359,6 +359,7 @@ void LLGLTFMaterialList::queueApply(const LLViewerObject* obj, S32 side, const L { if (asset_id.isNull() || override_json.empty()) { + // If there is no asset, there can't be an override queueApply(obj, side, asset_id); } else @@ -371,6 +372,7 @@ void LLGLTFMaterialList::queueApply(const LLViewerObject* obj, S32 side, const L { if (asset_id.isNull() || material_override == nullptr) { + // If there is no asset, there can't be an override queueApply(obj, side, asset_id); } else @@ -470,7 +472,7 @@ void LLGLTFMaterialList::flushUpdatesOnce(std::shared_ptr callba { data[i]["gltf_json"] = e.override_data->asJSON(); } - if (!e.override_json.empty()) + else if (!e.override_json.empty()) { data[i]["gltf_json"] = e.override_json; } diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 01fd5ae63c..291e3c2ed3 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2265,23 +2265,9 @@ void LLSelectMgr::selectionRevertGLTFMaterials() //blank override out LLGLTFMaterialList::queueApply(objectp, te, asset_id); } - if (old_asset_id != asset_id) - { - // Restore overrides and base material - // Note: might not work reliably if asset is already there, might - // have a server sided problem where servers applies override - // first then resets it by adding asset, in which case need - // to create a server ticket and chain asset then override - // application. - LLGLTFMaterialList::queueApply(objectp, te, asset_id, material); - } else { - // Enqueue override update to server - // Note: this is suboptimal, better to send asset id as well - // but there seems to be a server problem with queueApply - // that ignores override in some cases - LLGLTFMaterialList::queueModify(objectp, te, material); + LLGLTFMaterialList::queueApply(objectp, te, asset_id, material); } } return true;