From d66012f85e885679738cf8c488fd8ff460319c85 Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Fri, 30 Nov 2018 17:48:08 +0200
Subject: [PATCH] SL-9716 [EEP] "Use Shared Environment" does not enable when
 applying an environment to a parcel or region

---
 indra/newview/llenvironment.cpp                       | 7 +++++++
 indra/newview/llenvironment.h                         | 2 ++
 indra/newview/llfloatermyenvironment.cpp              | 2 ++
 indra/newview/llinventorybridge.cpp                   | 1 +
 indra/newview/skins/default/xui/en/menu_inventory.xml | 1 -
 5 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp
index 580d0e785a3..3a030bb09d8 100644
--- a/indra/newview/llenvironment.cpp
+++ b/indra/newview/llenvironment.cpp
@@ -1731,6 +1731,13 @@ void LLEnvironment::clearExperienceEnvironment(LLUUID experience_id, F32 transit
         updateEnvironment(LLSettingsBase::Seconds(transition_time));
 }
 
+void LLEnvironment::setSharedEnvironment()
+{
+    clearEnvironment(LLEnvironment::ENV_LOCAL);
+    setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
+    updateEnvironment();
+}
+
 void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLUUID asset_id, F32 transition_time)
 {
     LLSettingsVOBase::getSettingsAsset(asset_id,
diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h
index 55881f1c750..7e35fdcfac0 100644
--- a/indra/newview/llenvironment.h
+++ b/indra/newview/llenvironment.h
@@ -144,6 +144,8 @@ class LLEnvironment : public LLSingleton<LLEnvironment>
     void                        setEnvironment(EnvSelection_t env, const LLUUID &assetId, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset);
     void                        setEnvironment(EnvSelection_t env, const LLUUID &assetId);
 
+    void                        setSharedEnvironment();
+
     void                        clearEnvironment(EnvSelection_t env);
     LLSettingsDay::ptr_t        getEnvironmentDay(EnvSelection_t env);
     LLSettingsDay::Seconds      getEnvironmentDayLength(EnvSelection_t env);
diff --git a/indra/newview/llfloatermyenvironment.cpp b/indra/newview/llfloatermyenvironment.cpp
index c34ca9e458b..f93d7ce8ed3 100644
--- a/indra/newview/llfloatermyenvironment.cpp
+++ b/indra/newview/llfloatermyenvironment.cpp
@@ -325,6 +325,7 @@ void LLFloaterMyEnvironment::onDoApply(const std::string &context)
         if (context == PARAMETER_REGION)
         {
             LLEnvironment::instance().updateRegion(asset_id, name, -1, -1);
+            LLEnvironment::instance().setSharedEnvironment();
         }
         else if (context == PARAMETER_PARCEL)
         {
@@ -335,6 +336,7 @@ void LLFloaterMyEnvironment::onDoApply(const std::string &context)
                 return;
             }
             LLEnvironment::instance().updateParcel(parcel->getLocalID(), asset_id, name, -1, -1);
+            LLEnvironment::instance().setSharedEnvironment();
         }
         else if (context == PARAMETER_LOCAL)
         {
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 6a5c1241084..f2d418fc9db 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -6945,6 +6945,7 @@ void LLSettingsBridge::performAction(LLInventoryModel* model, std::string action
 
         LL_WARNS("LAPRAS") << "Applying asset ID " << asset_id << " to parcel " << parcel_id << LL_ENDL;
         LLEnvironment::instance().updateParcel(parcel_id, asset_id, name, -1, -1);
+        LLEnvironment::instance().setSharedEnvironment();
     }
     else
         LLItemBridge::performAction(model, action);
diff --git a/indra/newview/skins/default/xui/en/menu_inventory.xml b/indra/newview/skins/default/xui/en/menu_inventory.xml
index 9b24e2ffcfc..33ecb4477a7 100644
--- a/indra/newview/skins/default/xui/en/menu_inventory.xml
+++ b/indra/newview/skins/default/xui/en/menu_inventory.xml
@@ -879,7 +879,6 @@
         <menu_item_call.on_click 
                 function="Inventory.DoToSelected"
                 parameter="apply_settings_parcel" />
-    </menu_item_call>
     </menu_item_call>
 	<menu_item_separator
 	 layout="topleft"
-- 
GitLab