From 6622a3d110e50d1666ab46b1c32cd04bafa265ae Mon Sep 17 00:00:00 2001 From: MarianoGNU Date: Fri, 22 Jul 2016 21:11:12 -0300 Subject: Prevent crash in TextureRegionEditor. Fixes #5862 --- tools/editor/plugins/texture_region_editor_plugin.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/editor/plugins/texture_region_editor_plugin.cpp b/tools/editor/plugins/texture_region_editor_plugin.cpp index 63d8e2e1cf..db888208fb 100644 --- a/tools/editor/plugins/texture_region_editor_plugin.cpp +++ b/tools/editor/plugins/texture_region_editor_plugin.cpp @@ -703,14 +703,24 @@ void TextureRegionEditor::_edit_region() bool merged = true; while (merged) { merged = false; + bool queue_erase = false; for (List::Element *F = autoslice_cache.front(); F; F=F->next()) { + if (queue_erase){ + autoslice_cache.erase(F->prev()); + queue_erase = false; + } if (F==E) continue; if (E->get().grow(1).intersects(F->get())) { E->get().expand_to(F->get().pos); E->get().expand_to(F->get().pos+F->get().size); - F=F->prev(); - autoslice_cache.erase(F->next()); + if (F->prev()) { + F=F->prev(); + autoslice_cache.erase(F->next()); + } else { + queue_erase = true; + //Cant delete the first rect in the list. + } merged = true; } } -- cgit v1.2.3