From 79c434559ae3df19dd84765385164ba5dbeb3450 Mon Sep 17 00:00:00 2001
From: Kitty Barnett <develop@catznip.com>
Date: Sun, 16 Jul 2017 01:21:50 +0200
Subject: [PATCH] [FIXED] CATZ-332: Crash saving a texture to disk while
 @viewtextures=n restricted

--HG--
branch : RLVa
---
 indra/newview/llinventorybridge.cpp      | 11 +++++++++--
 indra/newview/llpanelobjectinventory.cpp |  3 ++-
 indra/newview/rlvactions.cpp             |  9 +++++++--
 indra/newview/rlvactions.h               | 23 ++++++++++++++---------
 4 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 35896765df..98e2d2c967 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -863,7 +863,7 @@ void LLInvFVBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 			if ( (pItem) &&
 				 ( ((LLAssetType::AT_NOTECARD == pItem->getType()) && (gRlvHandler.hasBehaviour(RLV_BHVR_VIEWNOTE))) ||
 				   ((LLAssetType::AT_LSL_TEXT == pItem->getType()) && (gRlvHandler.hasBehaviour(RLV_BHVR_VIEWSCRIPT))) ||
-				   ((LLAssetType::AT_TEXTURE == pItem->getType()) && (gRlvHandler.hasBehaviour(RLV_BHVR_VIEWTEXTURE))) ) )
+				   ((LLAssetType::AT_TEXTURE == pItem->getType()) && (!RlvActions::canPreviewTextures()))))
 			{
 				disabled_items.push_back(std::string("Open"));
 			}
@@ -3596,7 +3596,7 @@ void LLFolderBridge::perform_pasteFromClipboard()
                 }
 
 // [RLVa:KB] - Checked: RLVa-2.1.0
-				if ( ((item) && (!RlvActions::canPaste(item, dest_folder))) || ((cat) && (!RlvActions::canPaste(cat, dest_folder))) )
+				if ( ((item) && (!RlvActions::canPasteInventory(item, dest_folder))) || ((cat) && (!RlvActions::canPasteInventory(cat, dest_folder))) )
 				{
 					RlvActions::notifyBlocked(RLV_STRING_BLOCKED_INVFOLDER);
 					return;
@@ -5137,6 +5137,13 @@ bool LLTextureBridge::canSaveTexture(void)
 		return false;
 	}
 	
+// [RLVa:KB] - Checked: RLVa-2.2
+	if (!RlvActions::canPreviewTextures())
+	{
+		return false;
+	}
+// [/RLVa:KB]
+
 	const LLViewerInventoryItem *item = model->getItem(mUUID);
 	if (item)
 	{
diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp
index a14209eacb..412637f5ac 100644
--- a/indra/newview/llpanelobjectinventory.cpp
+++ b/indra/newview/llpanelobjectinventory.cpp
@@ -67,6 +67,7 @@
 #include "llviewerobjectlist.h"
 #include "llviewermessage.h"
 // [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
+#include "rlvactions.h"
 #include "rlvhandler.h"
 #include "rlvlocks.h"
 // [/RLVa:KB]
@@ -756,7 +757,7 @@ void LLTaskInvFVBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 			bool fLocked = (pAttachObj) ? gRlvAttachmentLocks.isLockedAttachment(pAttachObj->getRootEdit()) : false;
 			if ( ((LLAssetType::AT_NOTECARD == item->getType()) && ((gRlvHandler.hasBehaviour(RLV_BHVR_VIEWNOTE)) || (fLocked))) || 
 				 ((LLAssetType::AT_LSL_TEXT == item->getType()) && ((gRlvHandler.hasBehaviour(RLV_BHVR_VIEWSCRIPT)) || (fLocked))) ||
-				 ((LLAssetType::AT_TEXTURE == item->getType()) && (gRlvHandler.hasBehaviour(RLV_BHVR_VIEWTEXTURE))) )
+				 ((LLAssetType::AT_TEXTURE == item->getType()) && (!RlvActions::canPreviewTextures())))
 			{
 				disabled_items.push_back(std::string("Task Open"));
 			}
diff --git a/indra/newview/rlvactions.cpp b/indra/newview/rlvactions.cpp
index e36c81b2f5..54f9e1e0ec 100644
--- a/indra/newview/rlvactions.cpp
+++ b/indra/newview/rlvactions.cpp
@@ -248,7 +248,7 @@ EChatType RlvActions::checkChatVolume(EChatType chatType)
 // Inventory
 //
 
-bool RlvActions::canPaste(const LLInventoryCategory* pSourceCat, const LLInventoryCategory* pDestCat)
+bool RlvActions::canPasteInventory(const LLInventoryCategory* pSourceCat, const LLInventoryCategory* pDestCat)
 {
 	// The user can paste the specified object into the destination if:
 	//   - the source and destination are subject to the same lock type (or none at all) => NOTE: this happens to be the same logic we use for moving
@@ -256,7 +256,7 @@ bool RlvActions::canPaste(const LLInventoryCategory* pSourceCat, const LLInvento
 		( (pSourceCat) && (pDestCat) && ((!RlvFolderLocks::instance().hasLockedFolder(RLV_LOCK_ANY)) || (RlvFolderLocks::instance().canMoveFolder(pSourceCat->getUUID(), pDestCat->getUUID()))) );
 }
 
-bool RlvActions::canPaste(const LLInventoryItem* pSourceItem, const LLInventoryCategory* pDestCat)
+bool RlvActions::canPasteInventory(const LLInventoryItem* pSourceItem, const LLInventoryCategory* pDestCat)
 {
 	// The user can paste the specified object into the destination if:
 	//   - the source and destination are subject to the same lock type (or none at all) => NOTE: this happens to be the same logic we use for moving
@@ -264,6 +264,11 @@ bool RlvActions::canPaste(const LLInventoryItem* pSourceItem, const LLInventoryC
 		( (pSourceItem) && (pDestCat) && ((!RlvFolderLocks::instance().hasLockedFolder(RLV_LOCK_ANY)) || (RlvFolderLocks::instance().canMoveItem(pSourceItem->getUUID(), pDestCat->getUUID()))) );
 }
 
+bool RlvActions::canPreviewTextures()
+{
+	return (!gRlvHandler.hasBehaviour(RLV_BHVR_VIEWTEXTURE));
+}
+
 // ============================================================================
 // Movement
 //
diff --git a/indra/newview/rlvactions.h b/indra/newview/rlvactions.h
index 1e094fd3f1..82d09510e4 100644
--- a/indra/newview/rlvactions.h
+++ b/indra/newview/rlvactions.h
@@ -142,8 +142,13 @@ public:
 	/*
 	 * Returns true if the user is allowed to paste the specified inventory object (item/folder) into the specified destination category (within user inventory)
 	 */
-	static bool canPaste(const LLInventoryCategory* pSourceCat, const LLInventoryCategory* pDestCat);
-	static bool canPaste(const LLInventoryItem* pSourceItem, const LLInventoryCategory* pDestCat);
+	static bool canPasteInventory(const LLInventoryCategory* pSourceCat, const LLInventoryCategory* pDestCat);
+	static bool canPasteInventory(const LLInventoryItem* pSourceItem, const LLInventoryCategory* pDestCat);
+
+	/*
+	 * Returns true if the user can open the inventory floater for (user/library/notecard/object)inventory based textures
+	 */
+	static bool canPreviewTextures();
 
 	// ========
 	// Movement
@@ -232,26 +237,26 @@ public:
 	static bool canShowHoverText(const LLViewerObject* pObj);
 
 	/*
-	 * Returns true if the user can touch the specified object (with an optional offset relative to its center)
+	 * Returns true if the user can sit on the specified object (see canGroundSit() for sitting on land)
 	 */
-	static bool canTouch(const LLViewerObject* pObj, const LLVector3& posOffset = LLVector3::zero);
+	static bool canSit(const LLViewerObject* pObj, const LLVector3& posOffset = LLVector3::zero);
 
 	/*
 	 * Returns true if the user can see their in-world location
 	 */
 	static bool canShowLocation();
 
-	/*
-	 * Returns true if the user can sit on the specified object (see canGroundSit() for sitting on land)
-	 */
-	static bool canSit(const LLViewerObject* pObj, const LLVector3& posOffset = LLVector3::zero);
-
 	/*
 	 * Returns true if the user can stand up (returns true if the user isn't currently sitting)
 	 */
 	static bool canStand();
 	static bool canStand(const LLUUID& idRlvObjExcept);
 
+	/*
+	 * Returns true if the user can touch the specified object (with an optional offset relative to its center)
+	 */
+	static bool canTouch(const LLViewerObject* pObj, const LLVector3& posOffset = LLVector3::zero);
+
 	// ================
 	// Helper functions
 	// ================
-- 
GitLab