mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-01 18:00:26 +00:00
Avoid div by zero by preventing returning a grid bounds with zero width or height (fix #4146)
This commit is contained in:
parent
d3562b140c
commit
3f00b3e593
@ -98,15 +98,17 @@ Grid Site::grid() const
|
|||||||
|
|
||||||
gfx::Rect Site::gridBounds() const
|
gfx::Rect Site::gridBounds() const
|
||||||
{
|
{
|
||||||
|
gfx::Rect bounds;
|
||||||
if (m_layer && m_layer->isTilemap()) {
|
if (m_layer && m_layer->isTilemap()) {
|
||||||
const Grid& grid = static_cast<LayerTilemap*>(m_layer)->tileset()->grid();
|
const Grid& grid = static_cast<LayerTilemap*>(m_layer)->tileset()->grid();
|
||||||
gfx::Point offset = grid.tileOffset();
|
gfx::Point offset = grid.tileOffset();
|
||||||
if (const Cel* cel = m_layer->cel(m_frame))
|
if (const Cel* cel = m_layer->cel(m_frame))
|
||||||
offset += cel->bounds().origin();
|
offset += cel->bounds().origin();
|
||||||
return gfx::Rect(offset, grid.tileSize());
|
bounds = gfx::Rect(offset, grid.tileSize());
|
||||||
|
if (!bounds.isEmpty())
|
||||||
|
return bounds;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
gfx::Rect bounds;
|
|
||||||
if (m_sprite) {
|
if (m_sprite) {
|
||||||
bounds = m_sprite->gridBounds();
|
bounds = m_sprite->gridBounds();
|
||||||
if (!bounds.isEmpty())
|
if (!bounds.isEmpty())
|
||||||
@ -117,6 +119,8 @@ gfx::Rect Site::gridBounds() const
|
|||||||
if (!bounds.isEmpty())
|
if (!bounds.isEmpty())
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return doc::Sprite::DefaultGridBounds();
|
return doc::Sprite::DefaultGridBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user