mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-14 04:19:12 +00:00
Don't crash with div by zero when grid bounds has an invalid value
This commit is contained in:
parent
54a1b1d67e
commit
b0163f3937
@ -1,4 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -21,6 +22,9 @@ gfx::Point snap_to_grid(const gfx::Rect& grid,
|
||||
const gfx::Point& point,
|
||||
const PreferSnapTo prefer)
|
||||
{
|
||||
if (grid.isEmpty())
|
||||
return point;
|
||||
|
||||
gfx::Point newPoint;
|
||||
div_t d, dx, dy;
|
||||
|
||||
|
@ -597,10 +597,11 @@ bool StandbyState::onUpdateStatusBar(Editor* editor)
|
||||
|
||||
if (editor->docPref().show.grid()) {
|
||||
auto gb = editor->docPref().grid.bounds();
|
||||
int col = int((std::floor(spritePos.x) - (gb.x % gb.w)) / gb.w);
|
||||
int row = int((std::floor(spritePos.y) - (gb.y % gb.h)) / gb.h);
|
||||
sprintf(
|
||||
buf+std::strlen(buf), " :grid: %d %d", col, row);
|
||||
if (!gb.isEmpty()) {
|
||||
int col = int((std::floor(spritePos.x) - (gb.x % gb.w)) / gb.w);
|
||||
int row = int((std::floor(spritePos.y) - (gb.y % gb.h)) / gb.h);
|
||||
sprintf(buf+std::strlen(buf), " :grid: %d %d", col, row);
|
||||
}
|
||||
}
|
||||
|
||||
if (editor->docPref().show.slices()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user