Cherrypick from 1.0 branch of...

6c2a243cdc3dbe8cf5cb2ec9063585255607f8e5

LYN-2905 Script Canvas: Saving a graph that contains an Item Variable crashes the Editor

Added a check for m_shaderAsset.IsReady() before trying to use the asset data. Also added a check before calling BlockUntilLoadComplete() to prevent reporting an error message unnecessarily.
This commit is contained in:
Chris Santora
2021-04-24 10:10:02 -07:00
parent 92199d9f2e
commit 6b3abe3c56
@@ -40,13 +40,22 @@ namespace AZ
// Dependent asset references aren't guaranteed to finish loading by the time this asset is serialized, only by
// the time this asset load is completed. But since the data is needed here, we will deliberately block until the
// shader asset has finished loading.
shaderVariantReference->m_shaderAsset.QueueLoad();
shaderVariantReference->m_shaderAsset.BlockUntilLoadComplete();
if (shaderVariantReference->m_shaderAsset.QueueLoad())
{
shaderVariantReference->m_shaderAsset.BlockUntilLoadComplete();
}
shaderVariantReference->m_shaderOptionGroup = ShaderOptionGroup{
shaderVariantReference->m_shaderAsset->GetShaderOptionGroupLayout(),
shaderVariantReference->m_shaderVariantId
};
if (shaderVariantReference->m_shaderAsset.IsReady())
{
shaderVariantReference->m_shaderOptionGroup = ShaderOptionGroup{
shaderVariantReference->m_shaderAsset->GetShaderOptionGroupLayout(),
shaderVariantReference->m_shaderVariantId
};
}
else
{
shaderVariantReference->m_shaderOptionGroup = {};
}
}
};