#2818 Creating a link to an empty notecard fails

master
Andrey Kleshchev 2025-10-13 16:19:33 +03:00
parent 38257221d0
commit 449f64caa2
4 changed files with 92 additions and 9 deletions

View File

@ -4390,6 +4390,32 @@ void LLFolderBridge::pasteLinkFromClipboard()
std::vector<LLUUID> objects;
LLClipboard::instance().pasteFromClipboard(objects);
if (objects.size() == 0)
{
LLClipboard::instance().setCutMode(false);
return;
}
LLUUID& first_id = objects[0];
LLInventoryItem* item = model->getItem(first_id);
if (item && item->getAssetUUID().isNull())
{
if (item->getActualType() == LLAssetType::AT_NOTECARD)
{
// otehrwise AIS will return 'Cannot link to items with a NULL asset_id.'
LLNotificationsUtil::add("CantLinkNotecard");
LLClipboard::instance().setCutMode(false);
return;
}
else if (item->getActualType() == LLAssetType::AT_MATERIAL)
{
LLNotificationsUtil::add("CantLinkMaterial");
LLClipboard::instance().setCutMode(false);
return;
}
}
LLPointer<LLInventoryCallback> cb = NULL;
LLInventoryPanel* panel = mInventoryPanel.get();
if (panel->getRootFolder()->isSingleFolderMode())

View File

@ -2120,6 +2120,30 @@ void LLInventoryGallery::pasteAsLink()
std::vector<LLUUID> objects;
LLClipboard::instance().pasteFromClipboard(objects);
if (objects.size() == 0)
{
LLClipboard::instance().setCutMode(false);
return;
}
LLUUID& first_id = objects[0];
LLInventoryItem* item = gInventory.getItem(first_id);
if (item && item->getAssetUUID().isNull())
{
if (item->getActualType() == LLAssetType::AT_NOTECARD)
{
LLNotificationsUtil::add("CantLinkNotecard");
LLClipboard::instance().setCutMode(false);
return;
}
else if (item->getActualType() == LLAssetType::AT_MATERIAL)
{
LLNotificationsUtil::add("CantLinkMaterial");
LLClipboard::instance().setCutMode(false);
return;
}
}
bool paste_into_root = mSelectedItemIDs.empty();
for (LLUUID& dest : mSelectedItemIDs)
{

View File

@ -603,20 +603,23 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men
bool has_children = false;
bool is_full_perm_item = false;
bool is_copyable = false;
LLViewerInventoryItem* selected_item = gInventory.getItem(selected_id);
LLViewerInventoryCategory* selected_category = nullptr;
LLViewerInventoryItem* selected_item = nullptr;
if(is_folder)
{
LLInventoryCategory* category = gInventory.getCategory(selected_id);
if (category)
selected_category = dynamic_cast<LLViewerInventoryCategory*>(obj);
if (selected_category)
{
folder_type = category->getPreferredType();
folder_type = selected_category->getPreferredType();
is_system_folder = LLFolderType::lookupIsProtectedType(folder_type);
has_children = (gInventory.categoryHasChildren(selected_id) != LLInventoryModel::CHILDREN_NO);
}
}
else
{
selected_item = dynamic_cast<LLViewerInventoryItem*>(obj);
if (selected_item)
{
is_full_perm_item = selected_item->getIsFullPerm();
@ -735,8 +738,7 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men
{
if (is_agent_inventory && !is_inbox && !is_cof && !is_in_favorites && !is_outfits && !is_in_outfits)
{
LLViewerInventoryCategory* category = gInventory.getCategory(selected_id);
if (!category || !LLFriendCardsManager::instance().isCategoryInFriendFolder(category))
if (!selected_category || !LLFriendCardsManager::instance().isCategoryInFriendFolder(selected_category))
{
items.push_back(std::string("New Folder"));
}
@ -764,6 +766,22 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men
if (inventory_linking)
{
items.push_back(std::string("Paste As Link"));
if (selected_item)
{
if (!LLAssetType::lookupCanLink(selected_item->getActualType()))
{
disabled_items.push_back(std::string("Paste As Link"));
}
else if (gInventory.isObjectDescendentOf(selected_item->getUUID(), gInventory.getLibraryRootFolderID()))
{
disabled_items.push_back(std::string("Paste As Link"));
}
}
else if (selected_category && LLFolderType::lookupIsProtectedType(selected_category->getPreferredType()))
{
disabled_items.push_back(std::string("Paste As Link"));
}
}
}
if (is_folder && is_agent_inventory)
@ -1020,9 +1038,8 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men
{
if (is_folder)
{
LLViewerInventoryCategory* cat = gInventory.getCategory(selected_id);
if (cat
&& !LLFolderType::lookupIsProtectedType(cat->getPreferredType())
if (selected_category
&& !LLFolderType::lookupIsProtectedType(selected_category->getPreferredType())
&& gInventory.isObjectDescendentOf(selected_id, gInventory.getRootFolderID()))
{
can_list = true;

View File

@ -6594,6 +6594,22 @@ Do you want to replace it with the selected object?
<tag>fail</tag>
</notification>
<notification
icon="alertmodal.tga"
name="CantLinkNotecard"
type="alertmodal">
You must save the notecard before creating a link to it.
<tag>fail</tag>
</notification>
<notification
icon="alertmodal.tga"
name="CantLinkMaterial"
type="alertmodal">
You must save the material before creating a link to it.
<tag>fail</tag>
</notification>
<notification
icon="alert.tga"
label="Do Not Disturb Mode Warning"