From 5c9c05ebe74fee16b8c84416fed754a507bb3fbf Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 27 Nov 2014 23:48:53 -0300 Subject: [PATCH] Fix problems because excessive zoom out * Crash when the checked background is too small * Infinite loop to draw the grid --- src/app/ui/editor/editor.cpp | 2 ++ src/app/util/render.cpp | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp index 3affe2a0a..623bed330 100644 --- a/src/app/ui/editor/editor.cpp +++ b/src/app/ui/editor/editor.cpp @@ -666,6 +666,8 @@ void Editor::drawGrid(Graphics* g, const gfx::Rect& spriteBounds, const Rect& gr // Convert the "grid" rectangle to screen coordinates grid = editorToScreen(grid); + if (grid.w < 1 || grid.h < 1) + return; // Adjust for client area gfx::Rect bounds = getBounds(); diff --git a/src/app/util/render.cpp b/src/app/util/render.cpp index 51cba6c5e..152941183 100644 --- a/src/app/util/render.cpp +++ b/src/app/util/render.cpp @@ -613,6 +613,9 @@ void RenderEngine::renderCheckedBackground(Image* image, if (tile_w < zoom.apply(1)) tile_w = 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 u = (source_x / tile_w); v = (source_y / tile_h);