diff options
| -rw-r--r-- | indra/newview/llmaterialeditor.cpp | 7 | ||||
| -rw-r--r-- | indra/newview/llpreview.cpp | 20 | ||||
| -rw-r--r-- | indra/newview/llpreview.h | 2 | 
3 files changed, 22 insertions, 7 deletions
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 3a0e64985c..b30f94e145 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -238,6 +238,7 @@ struct LLSelectedTEGetMatData : public LLSelectedTEFunctor      LLUUID mTexNormalId;      LLUUID mObjectId;      S32 mObjectTE; +    LLUUID mMaterialId;      LLPointer<LLGLTFMaterial> mMaterial;      LLPointer<LLLocalGLTFMaterial> mLocalMaterial;  }; @@ -259,6 +260,7 @@ bool LLSelectedTEGetMatData::apply(LLViewerObject* objectp, S32 te_index)          return false;      }      LLUUID mat_id = objectp->getRenderMaterialID(te_index); +    mMaterialId = mat_id;      bool can_use = mIsOverride ? objectp->permModify() : objectp->permCopy();      LLTextureEntry *tep = objectp->getTE(te_index);      // We might want to disable this entirely if at least @@ -2708,7 +2710,10 @@ bool LLMaterialEditor::setFromSelection()      if (func.mMaterial.notNull())      {          setFromGLTFMaterial(func.mMaterial); -        setEnableEditing(true); +        LLViewerObject* selected_object = selected_objects->getFirstSelectedObject(NULL); +        const LLViewerInventoryItem* item = selected_object->getInventoryItemByAsset(func.mMaterialId); +        const bool allow_modify = !item || canModify(selected_object, item); +        setEnableEditing(allow_modify);      }      else      { diff --git a/indra/newview/llpreview.cpp b/indra/newview/llpreview.cpp index b9b2279e77..0117db86e8 100644 --- a/indra/newview/llpreview.cpp +++ b/indra/newview/llpreview.cpp @@ -241,14 +241,22 @@ void LLPreview::refreshFromItem()  // static  BOOL LLPreview::canModify(const LLUUID taskUUID, const LLInventoryItem* item)  { +    const LLViewerObject* object = nullptr;  	if (taskUUID.notNull())  	{ -		LLViewerObject* object = gObjectList.findObject(taskUUID); -		if(object && !object->permModify()) -		{ -			// No permission to edit in-world inventory -			return FALSE; -		} +		object = gObjectList.findObject(taskUUID); +	} + +	return canModify(object, item); +} + +// static +BOOL LLPreview::canModify(const LLViewerObject* object, const LLInventoryItem* item) +{ +	if (object && !object->permModify()) +	{ +        // No permission to edit in-world inventory +        return FALSE;  	}  	return item && gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE); diff --git a/indra/newview/llpreview.h b/indra/newview/llpreview.h index ab60f4c008..3688ee0192 100644 --- a/indra/newview/llpreview.h +++ b/indra/newview/llpreview.h @@ -36,6 +36,7 @@  #include <map>  class LLInventoryItem; +class LLViewerObject;  class LLLineEditor;  class LLRadioGroup;  class LLPreview; @@ -109,6 +110,7 @@ public:  	// We can't modify Item or description in preview if either in-world Object  	// or Item  itself is unmodifiable  	static BOOL canModify(const LLUUID taskUUID, const LLInventoryItem* item); +	static BOOL canModify(const LLViewerObject* object, const LLInventoryItem* item);  protected:  	virtual void onCommit();  | 
