summaryrefslogtreecommitdiff
path: root/tools/editor/plugins
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2016-01-24 17:22:17 -0300
committerreduz <reduzio@gmail.com>2016-01-24 17:22:17 -0300
commit48d2b7f4be56a463551c78da84696ea0909e5c0f (patch)
tree8d197bd4b07e51cf796c1f6453ca0056443ed4a3 /tools/editor/plugins
parent341f8e6d2bb395c7cfebb817a5e18674f6f1dae9 (diff)
avoid crash when scaling tilemap too much, fixes #266
Diffstat (limited to 'tools/editor/plugins')
-rw-r--r--tools/editor/plugins/tile_map_editor_plugin.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp
index 29326a2222..acacd37f66 100644
--- a/tools/editor/plugins/tile_map_editor_plugin.cpp
+++ b/tools/editor/plugins/tile_map_editor_plugin.cpp
@@ -533,6 +533,8 @@ void TileMapEditor::_canvas_draw() {
if (node->get_half_offset()!=TileMap::HALF_OFFSET_X) {
+ int max_lines=2000; //avoid crash if size too smal
+
for(int i=(si.pos.x)-1;i<=(si.pos.x+si.size.x);i++) {
Vector2 from = xform.xform(node->map_to_world(Vector2(i,si.pos.y)));
@@ -540,10 +542,12 @@ void TileMapEditor::_canvas_draw() {
Color col=i==0?Color(1,0.8,0.2,0.5):Color(1,0.3,0.1,0.2);
canvas_item_editor->draw_line(from,to,col,1);
-
+ if (max_lines--==0)
+ break;
}
} else {
+ int max_lines=10000; //avoid crash if size too smal
for(int i=(si.pos.x)-1;i<=(si.pos.x+si.size.x);i++) {
@@ -558,11 +562,17 @@ void TileMapEditor::_canvas_draw() {
Vector2 to = xform.xform(node->map_to_world(Vector2(i,j+1),true)+ofs);
Color col=i==0?Color(1,0.8,0.2,0.5):Color(1,0.3,0.1,0.2);
canvas_item_editor->draw_line(from,to,col,1);
+
+ if (max_lines--==0)
+ break;
+
}
}
}
+ int max_lines=10000; //avoid crash if size too smal
+
if (node->get_half_offset()!=TileMap::HALF_OFFSET_Y) {
for(int i=(si.pos.y)-1;i<=(si.pos.y+si.size.y);i++) {
@@ -573,6 +583,9 @@ void TileMapEditor::_canvas_draw() {
Color col=i==0?Color(1,0.8,0.2,0.5):Color(1,0.3,0.1,0.2);
canvas_item_editor->draw_line(from,to,col,1);
+ if (max_lines--==0)
+ break;
+
}
} else {
@@ -590,6 +603,10 @@ void TileMapEditor::_canvas_draw() {
Vector2 to = xform.xform(node->map_to_world(Vector2(j+1,i),true)+ofs);
Color col=i==0?Color(1,0.8,0.2,0.5):Color(1,0.3,0.1,0.2);
canvas_item_editor->draw_line(from,to,col,1);
+
+ if (max_lines--==0)
+ break;
+
}
}