From 7135934e50bf2727c2366687af7427d44483e984 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Sat, 22 Oct 2022 11:01:35 -0500 Subject: SL-18105 Fix for crash when attempting to "Edit PBR Material" when there's no PBR material --- indra/newview/llmaterialeditor.cpp | 27 ++++++++++++++++++--------- indra/newview/llmaterialeditor.h | 2 +- 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'indra/newview') 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 > { @@ -1985,7 +1988,13 @@ void LLMaterialEditor::setFromSelection() LLPointer mat; LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, mat); - setFromGLTFMaterial(mat); + if (mat.notNull()) + { + setFromGLTFMaterial(mat); + return true; + } + + return false; } diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h index 0aaf391431..9cd8bcd88b 100644 --- a/indra/newview/llmaterialeditor.h +++ b/indra/newview/llmaterialeditor.h @@ -222,7 +222,7 @@ public: private: void setFromGLTFMaterial(LLGLTFMaterial* mat); - void setFromSelection(); + bool setFromSelection(); void loadMaterial(const tinygltf::Model &model, const std::string &filename_lc, S32 index); -- cgit v1.2.3