From 07101fcc649576ebe9daedd2df083853513f1426 Mon Sep 17 00:00:00 2001 From: Sergey Lapin Date: Sat, 4 Apr 2026 05:36:08 +0300 Subject: [PATCH] Fixed crash on texture change --- src/features/editScene/EditorApp.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/features/editScene/EditorApp.cpp b/src/features/editScene/EditorApp.cpp index 33f3e05..41e9a4f 100644 --- a/src/features/editScene/EditorApp.cpp +++ b/src/features/editScene/EditorApp.cpp @@ -83,9 +83,16 @@ EditorApp::~EditorApp() // Delete all editor entities before OGRE cleanup // This ensures all components with Ogre resources are cleaned up while SceneManager exists + // Collect entities first, then delete after iteration (can't modify during iteration) + std::vector entitiesToDelete; m_world.query().each([&](flecs::entity e, EditorMarkerComponent) { - e.destruct(); + entitiesToDelete.push_back(e); }); + for (auto& e : entitiesToDelete) { + if (e.is_alive()) { + e.destruct(); + } + } // Release all systems m_proceduralMeshSystem.reset();