diff --git a/src/edit/src/editor.cpp b/src/edit/src/editor.cpp index 5f5078ee16f5a3ad20ee8d962a22f5a3a331a111..111990fcea1db686622d751a6a239c8b3efad25f 100644 --- a/src/edit/src/editor.cpp +++ b/src/edit/src/editor.cpp @@ -274,6 +274,8 @@ void Editor::enterPhaseOne() scene->manageCameraAxes(false); removeRofiWorldNodeTreeFromScene(rofiworld->getNodeTree()); removeModuleFromScene(selected_module); + removeModuleFromScene(selected_add_module); + selected_add_module = nullptr; voxel_graph = nullptr; } @@ -1268,6 +1270,14 @@ void Editor::addToModules(std::string name, std::string type) linkImportVoxelGraphToNodes(new_module->getParts()); setModuleNodeHierarchy(new_module->getParts(), type); setRoFIMesh(new_module->getParts()); + + if (const auto it = std::find_if(modules.begin(), modules.end(), + [&](const module_ptr module) { return module->getName() == name; } ); + it != modules.end()) + { + modules.erase(it); + } + modules.emplace_back(new_module); } diff --git a/src/gui/src/ui.cpp b/src/gui/src/ui.cpp index b1d20b7ab4c41d4df45dc5e58ac5bb2870c44a2e..a81d0fd0a3e263bd1462e48f517ec0f71a8d3f6a 100644 --- a/src/gui/src/ui.cpp +++ b/src/gui/src/ui.cpp @@ -4,6 +4,7 @@ #include <utils/math.hpp> #include <iostream> +#include <string> void show_ui(const osi::Window &window, edit::UIData &data, const double ¤t_second) { @@ -524,7 +525,7 @@ void module_selection_ui(const osi::Window &window, edit::UIData &data) { auto & [name, type] = names_types[n]; bool is_selected = (data.add_module_list_index == n); - const auto label_string = name + " (" + type + ")"; + const auto label_string = name + " (" + type + ")" + "##ModuleSelectionItem" + std::to_string(n); const char* label = label_string.c_str(); if (ImGui::Selectable(label, is_selected)) {