mirror of
https://github.com/aseprite/aseprite.git
synced 2024-12-29 18:20:44 +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 bounds;
|
||||
if (m_layer && m_layer->isTilemap()) {
|
||||
const Grid& grid = static_cast<LayerTilemap*>(m_layer)->tileset()->grid();
|
||||
gfx::Point offset = grid.tileOffset();
|
||||
if (const Cel* cel = m_layer->cel(m_frame))
|
||||
offset += cel->bounds().origin();
|
||||
return gfx::Rect(offset, grid.tileSize());
|
||||
bounds = gfx::Rect(offset, grid.tileSize());
|
||||
if (!bounds.isEmpty())
|
||||
return bounds;
|
||||
}
|
||||
|
||||
gfx::Rect bounds;
|
||||
else {
|
||||
if (m_sprite) {
|
||||
bounds = m_sprite->gridBounds();
|
||||
if (!bounds.isEmpty())
|
||||
@ -117,6 +119,8 @@ gfx::Rect Site::gridBounds() const
|
||||
if (!bounds.isEmpty())
|
||||
return bounds;
|
||||
}
|
||||
}
|
||||
|
||||
return doc::Sprite::DefaultGridBounds();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user