From 0c84313a000ff3589cef92fb8ba151ee14a51f58 Mon Sep 17 00:00:00 2001
From: andreykproductengine <andreykproductengine@lindenlab.com>
Date: Thu, 30 May 2019 18:45:02 +0300
Subject: SL-11321 Do not crash floater if capability is missing

---
 indra/newview/llfloatermyscripts.cpp | 25 +++++++++++++++++++------
 indra/newview/llfloatermyscripts.h   |  4 +++-
 2 files changed, 22 insertions(+), 7 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfloatermyscripts.cpp b/indra/newview/llfloatermyscripts.cpp
index fa2de21a8f..6f9a6c9066 100644
--- a/indra/newview/llfloatermyscripts.cpp
+++ b/indra/newview/llfloatermyscripts.cpp
@@ -41,6 +41,7 @@ const S32 SIZE_OF_ONE_KB = 1024;
 LLFloaterMyScripts::LLFloaterMyScripts(const LLSD& seed)
 	: LLFloater(seed), 
 	mGotAttachmentMemoryUsed(false),
+	mAttachmentDetailsRequested(false),
 	mAttachmentMemoryMax(0),
 	mAttachmentMemoryUsed(0),
 	mGotAttachmentURLsUsed(false),
@@ -55,12 +56,24 @@ BOOL LLFloaterMyScripts::postBuild()
 
 	std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestWaiting");
 	getChild<LLUICtrl>("loading_text")->setValue(LLSD(msg_waiting));
-	return requestAttachmentDetails();
+	mAttachmentDetailsRequested = requestAttachmentDetails();
+	return TRUE;
 }
 
-BOOL LLFloaterMyScripts::requestAttachmentDetails()
+// virtual
+void LLFloaterMyScripts::onOpen(const LLSD& key)
 {
-	if (!gAgent.getRegion()) return FALSE;
+    if (!mAttachmentDetailsRequested)
+    {
+        mAttachmentDetailsRequested = requestAttachmentDetails();
+    }
+
+    LLFloater::onOpen(key);
+}
+
+bool LLFloaterMyScripts::requestAttachmentDetails()
+{
+	if (!gAgent.getRegion()) return false;
 
 	LLSD body;
 	std::string url = gAgent.getRegion()->getCapability("AttachmentResources");
@@ -68,11 +81,11 @@ BOOL LLFloaterMyScripts::requestAttachmentDetails()
 	{
 		LLCoros::instance().launch("LLFloaterMyScripts::getAttachmentLimitsCoro",
 			boost::bind(&LLFloaterMyScripts::getAttachmentLimitsCoro, this, url));
-		return TRUE;
+		return true;
 	}
 	else
 	{
-		return FALSE;
+		return false;
 	}
 }
 
@@ -284,7 +297,7 @@ void LLFloaterMyScripts::onClickRefresh(void* userdata)
 			btn->setEnabled(false);
 		}
 		instance->clearList();
-		instance->requestAttachmentDetails();
+		instance->mAttachmentDetailsRequested = instance->requestAttachmentDetails();
 	}
 	else
 	{
diff --git a/indra/newview/llfloatermyscripts.h b/indra/newview/llfloatermyscripts.h
index fe33ab90ae..3c053a0223 100644
--- a/indra/newview/llfloatermyscripts.h
+++ b/indra/newview/llfloatermyscripts.h
@@ -36,15 +36,17 @@ public:
 	LLFloaterMyScripts(const LLSD& seed);
 
 	BOOL postBuild();
+	/*virtual*/ void onOpen(const LLSD& key);
 	void setAttachmentDetails(LLSD content);
 	void setAttachmentSummary(LLSD content);
-	BOOL requestAttachmentDetails();
+	bool requestAttachmentDetails();
 	void clearList();
 
 private:
 	void getAttachmentLimitsCoro(std::string url);
 
 	bool mGotAttachmentMemoryUsed;
+	bool mAttachmentDetailsRequested;
 	S32 mAttachmentMemoryMax;
 	S32 mAttachmentMemoryUsed;
 
-- 
cgit v1.2.3