Fix icon button widget crash

This commit is contained in:
CodingJellyfish 2024-04-26 10:38:41 +08:00
parent 5adbb3f16b
commit 8e5304d4a9

View File

@ -370,11 +370,14 @@ void IconButtonWidget::updateIconRect()
if (m_scale_mode == SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO || if (m_scale_mode == SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO ||
m_scale_mode == SCALE_MODE_LIST_WIDGET) m_scale_mode == SCALE_MODE_LIST_WIDGET)
{
if (m_texture)
{ {
assert(m_texture->getOriginalSize().Height > 0); assert(m_texture->getOriginalSize().Height > 0);
useAspectRatio = (float)m_texture->getOriginalSize().Width / useAspectRatio = (float)m_texture->getOriginalSize().Width /
(float)m_texture->getOriginalSize().Height; (float)m_texture->getOriginalSize().Height;
} }
}
else if (m_scale_mode == SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO) else if (m_scale_mode == SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO)
{ {
useAspectRatio = m_custom_aspect_ratio; useAspectRatio = m_custom_aspect_ratio;