summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2022-10-27 01:42:45 +0300
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2022-10-27 01:46:31 +0300
commit0c0b66388fddb70c4e9ac7660ba5dd709bc4cfc9 (patch)
tree958ce97e4a8e3dc7ccb3a90bd838fcdecaf2490c
parent65eec2ca8fb34fb2aca8e93c8ce6d8e39cfae3e9 (diff)
SL-18465 Crash opening Material Editor
-rw-r--r--indra/newview/llmaterialeditor.cpp35
-rw-r--r--indra/newview/llpreview.cpp7
2 files changed, 29 insertions, 13 deletions
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index 7cd9b9198f..7ffa767e37 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -65,7 +65,9 @@ const std::string MATERIAL_NORMAL_DEFAULT_NAME = "Normal";
const std::string MATERIAL_METALLIC_DEFAULT_NAME = "Metallic Roughness";
const std::string MATERIAL_EMISSIVE_DEFAULT_NAME = "Emissive";
-const LLUUID LIVE_MATERIAL_EDITOR_KEY("6cf97162-8b68-49eb-b627-79886c9fd17d");
+// Don't use ids here, LLPreview will attempt to use it as an inventory item
+static const std::string LIVE_MATERIAL_EDITOR_KEY = "Live Editor";
+static const std::string SAVE_LIVE_MATERIAL_KEY = "Save Material Editor";
// Dirty flags
static const U32 MATERIAL_BASE_COLOR_DIRTY = 0x1 << 0;
@@ -1169,6 +1171,12 @@ void LLMaterialEditor::finishSaveAs(
void LLMaterialEditor::refreshFromInventory(const LLUUID& new_item_id)
{
+ if (mIsOverride)
+ {
+ // refreshFromInventory shouldn't be called for overrides,
+ // but just in case.
+ return;
+ }
if (new_item_id.notNull())
{
mItemUUID = new_item_id;
@@ -1536,11 +1544,12 @@ void LLMaterialEditor::saveLiveValues()
void LLMaterialEditor::loadLive()
{
- LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor", LLSD(LIVE_MATERIAL_EDITOR_KEY));
+ const LLSD floater_key(LIVE_MATERIAL_EDITOR_KEY);
+ LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor", floater_key);
if (me)
{
- me->setFromSelection();
me->mIsOverride = true;
+ me->setFromSelection();
me->setTitle(me->getString("material_override_title"));
me->childSetVisible("save", false);
me->childSetVisible("save_as", false);
@@ -1553,19 +1562,20 @@ void LLMaterialEditor::loadLive()
// Collect ids to be able to revert overrides on cancel.
me->saveLiveValues();
- me->openFloater();
+ me->openFloater(floater_key);
me->setFocus(TRUE);
}
}
void LLMaterialEditor::loadObjectSave()
{
- LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor", LLSD(LIVE_MATERIAL_EDITOR_KEY));
- if (me->setFromSelection())
+ const LLSD floater_key(SAVE_LIVE_MATERIAL_KEY);
+ LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor", floater_key);
+ if (me && me->setFromSelection())
{
me->mIsOverride = false;
me->childSetVisible("save", false);
- me->openFloater();
+ me->openFloater(floater_key);
me->setFocus(TRUE);
}
}
@@ -2226,10 +2236,13 @@ bool LLMaterialEditor::setFromSelection()
setFromGLTFMaterial(&blank_mat);
}
- mBaseColorTextureCtrl->setTentative(!identical);
- mMetallicTextureCtrl->setTentative(!identical);
- mEmissiveTextureCtrl->setTentative(!identical);
- mNormalTextureCtrl->setTentative(!identical);
+ if (mIsOverride)
+ {
+ mBaseColorTextureCtrl->setTentative(!identical);
+ mMetallicTextureCtrl->setTentative(!identical);
+ mEmissiveTextureCtrl->setTentative(!identical);
+ mNormalTextureCtrl->setTentative(!identical);
+ }
return mat.notNull();
}
diff --git a/indra/newview/llpreview.cpp b/indra/newview/llpreview.cpp
index fc2de4844e..b9b2279e77 100644
--- a/indra/newview/llpreview.cpp
+++ b/indra/newview/llpreview.cpp
@@ -115,8 +115,11 @@ const LLInventoryItem *LLPreview::getItem() const
}
else if (mObjectUUID.isNull())
{
- // it's an inventory item, so get the item.
- item = gInventory.getItem(mItemUUID);
+ if (mItemUUID.notNull())
+ {
+ // it's an inventory item, so get the item.
+ item = gInventory.getItem(mItemUUID);
+ }
}
else
{