From 7506e45d3b34e66e9a6b40f57adfe43e55cd38af Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Mon, 26 Jul 2021 16:56:48 +0200 Subject: [PATCH] Fixed bug when removing certain modules --- core/src/gui/menus/module_manager.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/gui/menus/module_manager.cpp b/core/src/gui/menus/module_manager.cpp index c2d3e281..6f370821 100644 --- a/core/src/gui/menus/module_manager.cpp +++ b/core/src/gui/menus/module_manager.cpp @@ -7,6 +7,7 @@ namespace module_manager_menu { char modName[1024]; std::vector modTypes; + std::vector toBeRemoved; std::string modTypesTxt; int modTypeId; @@ -32,6 +33,8 @@ namespace module_manager_menu { float height = ImGui::CalcTextSize("-").y; + toBeRemoved.clear(); + for (auto& [name, inst] : core::moduleManager.instances) { ImGui::TableNextRow(); @@ -45,12 +48,16 @@ namespace module_manager_menu { ImVec2 origPos = ImGui::GetCursorPos(); ImGui::SetCursorPos(ImVec2(origPos.x - 3, origPos.y)); if (ImGui::Button(("##module_mgr_"+name).c_str(), ImVec2(height,height))) { - core::moduleManager.deleteInstance(name); + toBeRemoved.push_back(name); } ImGui::SetCursorPos(ImVec2(origPos.x + 2, origPos.y - 5)); ImGui::Text("_"); } ImGui::EndTable(); + + for (auto& rem : toBeRemoved) { + core::moduleManager.deleteInstance(rem); + } }