summaryrefslogtreecommitdiff
path: root/indra/newview/llmaterialeditor.cpp
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2022-10-22 11:01:35 -0500
committerDave Parks <davep@lindenlab.com>2022-10-22 11:01:35 -0500
commit7135934e50bf2727c2366687af7427d44483e984 (patch)
treea63ea03f82028d6896cf30891b9d45c42d54897b /indra/newview/llmaterialeditor.cpp
parent0cd7c3842119f1801872b4db05e17544b4eb7158 (diff)
SL-18105 Fix for crash when attempting to "Edit PBR Material" when there's no PBR material
Diffstat (limited to 'indra/newview/llmaterialeditor.cpp')
-rw-r--r--indra/newview/llmaterialeditor.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index 86efdfcd06..038f4df863 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -1404,13 +1404,16 @@ void LLMaterialEditor::loadMaterialFromFile(const std::string& filename, S32 ind
void LLMaterialEditor::loadLiveMaterialEditor()
{
LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor", LLSD(LIVE_MATERIAL_EDITOR_KEY));
- me->mIsOverride = true;
- me->setTitle(me->getString("material_override_title"));
- me->childSetVisible("save", false);
- me->childSetVisible("save_as", false);
- me->setFromSelection();
- me->openFloater();
- me->setFocus(TRUE);
+ if (me->setFromSelection())
+ {
+ me->mIsOverride = true;
+ me->setTitle(me->getString("material_override_title"));
+ me->childSetVisible("save", false);
+ me->childSetVisible("save_as", false);
+
+ me->openFloater();
+ me->setFocus(TRUE);
+ }
}
void LLMaterialEditor::loadFromGLTFMaterial(LLUUID &asset_id)
@@ -1973,7 +1976,7 @@ void LLMaterialEditor::setFromGLTFMaterial(LLGLTFMaterial* mat)
setAlphaCutoff(mat->mAlphaCutoff);
}
-void LLMaterialEditor::setFromSelection()
+bool LLMaterialEditor::setFromSelection()
{
struct LLSelectedTEGetGLTFRenderMaterial : public LLSelectedTEGetFunctor<LLPointer<LLGLTFMaterial> >
{
@@ -1985,7 +1988,13 @@ void LLMaterialEditor::setFromSelection()
LLPointer<LLGLTFMaterial> mat;
LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, mat);
- setFromGLTFMaterial(mat);
+ if (mat.notNull())
+ {
+ setFromGLTFMaterial(mat);
+ return true;
+ }
+
+ return false;
}