diff options
Diffstat (limited to 'indra/newview/llpanelface.cpp')
| -rw-r--r-- | indra/newview/llpanelface.cpp | 64 |
1 files changed, 61 insertions, 3 deletions
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 3849e5c8f7..641a3602c8 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -2869,7 +2869,8 @@ void LLPanelFace::onCopyTexture() { LLUUID item_id; LLUUID id = te_data["te"]["imageid"].asUUID(); - bool full_perm = get_is_library_texture(id) || (objectp->permCopy() && objectp->permTransfer() && objectp->permModify()); + bool from_library = get_is_predefined_texture(id); + bool full_perm = from_library || (objectp->permCopy() && objectp->permTransfer() && objectp->permModify()); if (id.notNull() && !full_perm) { @@ -2890,6 +2891,12 @@ void LLPanelFace::onCopyTexture() } } + if (item_id.notNull() && gInventory.isObjectDescendentOf(item_id, gInventory.getLibraryRootFolderID())) + { + full_perm = true; + from_library = true; + } + if (id.isNull() || (!full_perm && item_id.isNull())) { @@ -2899,10 +2906,15 @@ void LLPanelFace::onCopyTexture() te_data["te"]["imageid"] = LLUUID(gSavedSettings.getString("DefaultObjectTexture")); } te_data["te"]["itemfullperm"] = true; + te_data["te"]["fromlibrary"] = true; } else { te_data["te"]["itemfullperm"] = full_perm; + // from_library is unreliable since we don't get texture item if source object + // is fullperm but it merely means additional checks when assigning texture + te_data["te"]["fromlibrary"] = from_library; + // If full permission object, texture is free to copy, // but otherwise we need to check inventory and extract permissions // @@ -3046,6 +3058,40 @@ void LLPanelFace::onPasteTexture() return; } + bool full_perm = true; + LLSD::array_const_iterator iter = clipboard.beginArray(); + LLSD::array_const_iterator end = clipboard.endArray(); + for (; iter != end; ++iter) + { + const LLSD& te_data = *iter; + if (te_data.has("te")) + { + full_perm &= te_data["te"].has("itemfullperm") && te_data["te"]["itemfullperm"].asBoolean(); + if (te_data["te"].has("imageitemid")) + { + LLUUID item_id = te_data["te"]["imageitemid"].asUUID(); + if (item_id.notNull()) + { + LLViewerInventoryItem* itemp = gInventory.getItem(item_id); + if (!itemp) + { + // image might be in object's inventory, but it can be not up to date + LLSD notif_args; + static std::string reason = getString("paste_error_inventory_not_found"); + notif_args["REASON"] = reason; + LLNotificationsUtil::add("FacePasteFailed", notif_args); + return; + } + } + } + } + } + + if (!full_perm) + { + LLNotificationsUtil::add("FacePasteTexturePermissions"); + } + LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); LLPanelFacePasteTexFunctor paste_func(this, PASTE_TEXTURE); @@ -3082,6 +3128,7 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te) { // Texture bool full_perm = te_data["te"].has("itemfullperm") && te_data["te"]["itemfullperm"].asBoolean(); + bool from_library = te_data["te"].has("fromlibrary") && te_data["te"]["fromlibrary"].asBoolean(); if (te_data["te"].has("imageid")) { const LLUUID& imageid = te_data["te"]["imageid"].asUUID(); //texture or asset id @@ -3098,12 +3145,21 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te) // dropTextureAllFaces will fail if incomplete itemp_res = itemp; } + else + { + // Theoretically shouldn't happend, but if it does happen, we + // might need to add a notification to user that paste will fail + // since inventory isn't fully loaded + LL_WARNS() << "Item " << item_id << " is incomplete, paste might fail silently." << LL_ENDL; + } } } // for case when item got removed from inventory after we pressed 'copy' // or texture got pasted into previous object if (!itemp_res && !full_perm) { + // Due to checks for imageitemid in LLPanelFace::onPasteTexture() this should no longer be reachable. + LL_INFOS() << "Item " << te_data["te"]["imageitemid"].asUUID() << " no longer in inventory." << LL_ENDL; // Todo: fix this, we are often searching same texture multiple times (equal to number of faces) // Perhaps just mPanelFace->onPasteTexture(objectp, te, &asset_to_item_id_map); ? Not pretty, but will work LLViewerInventoryCategory::cat_array_t cats; @@ -3137,11 +3193,13 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te) if (itemp_res) { + // from_library is unreliable since we don't get texture item if object is + // fullperm but it merely means additional checks when assigning texture if (te == -1) // all faces { LLToolDragAndDrop::dropTextureAllFaces(objectp, itemp_res, - LLToolDragAndDrop::SOURCE_AGENT, + from_library ? LLToolDragAndDrop::SOURCE_LIBRARY : LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); } else // one face @@ -3149,7 +3207,7 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te) LLToolDragAndDrop::dropTextureOneFace(objectp, te, itemp_res, - LLToolDragAndDrop::SOURCE_AGENT, + from_library ? LLToolDragAndDrop::SOURCE_LIBRARY : LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); } } |
