Fix problems because excessive zoom out

* Crash when the checked background is too small
* Infinite loop to draw the grid
This commit is contained in:
David Capello 2014-11-27 23:48:53 -03:00
parent adf08ac7df
commit 5c9c05ebe7
2 changed files with 5 additions and 0 deletions

View File

@ -666,6 +666,8 @@ void Editor::drawGrid(Graphics* g, const gfx::Rect& spriteBounds, const Rect& gr
// Convert the "grid" rectangle to screen coordinates // Convert the "grid" rectangle to screen coordinates
grid = editorToScreen(grid); grid = editorToScreen(grid);
if (grid.w < 1 || grid.h < 1)
return;
// Adjust for client area // Adjust for client area
gfx::Rect bounds = getBounds(); gfx::Rect bounds = getBounds();

View File

@ -613,6 +613,9 @@ void RenderEngine::renderCheckedBackground(Image* image,
if (tile_w < zoom.apply(1)) tile_w = zoom.apply(1); if (tile_w < zoom.apply(1)) tile_w = zoom.apply(1);
if (tile_h < zoom.apply(1)) tile_h = zoom.apply(1); if (tile_h < zoom.apply(1)) tile_h = zoom.apply(1);
if (tile_w < 1) tile_w = 1;
if (tile_h < 1) tile_h = 1;
// Tile position (u,v) is the number of tile we start in (source_x,source_y) coordinate // Tile position (u,v) is the number of tile we start in (source_x,source_y) coordinate
u = (source_x / tile_w); u = (source_x / tile_w);
v = (source_y / tile_h); v = (source_y / tile_h);