Added error handling for unsupported pixel formats on an image gradient

Signed-off-by: Chris Galvan <chgalvan@amazon.com>
monroegm-disable-blank-issue-2
Chris Galvan 4 years ago
parent c4dce0da95
commit 3207e909f7

@ -246,7 +246,7 @@ namespace AzToolsFramework
virtual void PopupAssetPicker();
virtual void PickAssetSelectionFromDialog(AssetSelectionModel& selection, QWidget* parent);
void OnClearButtonClicked();
void UpdateAssetDisplay();
virtual void UpdateAssetDisplay();
void OnLineEditFocus(bool focus);
virtual void OnEditButtonClicked();
void OnThumbnailClicked();

@ -226,6 +226,18 @@ namespace GradientSignal
return;
}
// If we have loaded in an old image asset with an unsupported pixel format,
// don't try to access the image data because there will be spam of asserts,
// so just log an error message and bail out
AZ::RHI::Format format = m_configuration.m_imageAsset->GetImageDescriptor().m_format;
bool isFormatSupported = AZ::RPI::IsImageDataPixelAPISupported(format);
if (!isFormatSupported)
{
AZ_Error("GradientSignal", false, "Image asset (%s) has an unsupported pixel format: %s",
m_configuration.m_imageAsset.GetHint().c_str(), AZ::RHI::ToString(format));
return;
}
m_imageData = m_configuration.m_imageAsset->GetSubImageData(0, 0);
}

@ -76,6 +76,20 @@ namespace GradientSignal
}
}
void StreamingImagePropertyAssetCtrl::UpdateAssetDisplay()
{
AzToolsFramework::PropertyAssetCtrl::UpdateAssetDisplay();
// If there is a valid asset selected but it's not a supported pixel format,
// show the error message state for this property
if (m_selectedAssetID.IsValid() && !Internal::IsImageDataPixelAPISupportedForAsset(m_selectedAssetID))
{
UpdateErrorButtonWithMessage(
AZStd::string::format("Image asset (%s) has an unsupported pixel format", GetCurrentAssetHint().c_str())
);
}
}
AZ::u32 StreamingImagePropertyHandler::GetHandlerName() const
{
return AZ_CRC_CE("GradientSignalStreamingImageAsset");

@ -44,6 +44,7 @@ namespace GradientSignal
public Q_SLOTS:
void OnAutocomplete(const QModelIndex& index) override;
void UpdateAssetDisplay() override;
};
//! We need a custom asset property handler for the AZ::RPI::StreamingImageAsset on our

Loading…
Cancel
Save