From 89e46a8291cc0de20b20bed18ad4c75948341133 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 6 May 2024 04:12:36 +0200 Subject: editor: fix crash when chunk::_objects array reallocates itself --- editor/update.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/editor/update.cpp b/editor/update.cpp index ce9fa874..52c84d4d 100644 --- a/editor/update.cpp +++ b/editor/update.cpp @@ -238,12 +238,10 @@ void app::update_world(Ns dt) if (!cʹ) continue; auto& c = *cʹ; - const auto& es = c.objects(); -start: auto size = (uint32_t)es.size(); + auto size = (uint32_t)c.objects().size(); for (auto i = 0u; i < size; i++) { - Debug{} << "world::update start"; - auto eʹ = es[i]; + auto& eʹ = c.objects().data()[i]; auto index = size_t{i}; auto& e = *eʹ; if (e.last_frame_no == frame_no) [[unlikely]] @@ -252,12 +250,9 @@ start: auto size = (uint32_t)es.size(); e.update(eʹ, index, dt); // objects can't delete themselves during update() if (&e.chunk() != cʹ || index > i) [[unlikely]] { - Debug{} << "changed" << c.coord() << "to" << e.chunk().coord(); - goto start; + i--; + size = (uint32_t)c.objects().size(); } - else - Debug{} << "unchanged"; - Debug{} << "world::update end"; } } -- cgit v1.2.3