diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index 5062fc93b4..775596104b 100644 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -221,7 +221,18 @@ class ExtruderManager(QObject): container_registry.addContainer(container_stack) - ## Generates extruders for a specific machine. + ## Removes the container stack and user profile for the extruders for a specific machine. + # + # \param machine_id The machine to remove the extruders for. + def removeMachineExtruders(self, machine_id): + for extruder in self.getMachineExtruders(machine_id): + current_settings_id = extruder.getId() + "_current_settings" + containers = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(id = current_settings_id) + for container in containers: + UM.Settings.ContainerRegistry.getInstance().removeContainer(container.getId()) + UM.Settings.ContainerRegistry.getInstance().removeContainer(extruder.getId()) + + ## Returns extruders for a specific machine. # # \param machine_id The machine to get the extruders of. def getMachineExtruders(self, machine_id): diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index f670bf2bf2..cb761032d8 100644 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -635,6 +635,11 @@ class MachineManager(QObject): # If the machine that is being removed is the currently active machine, set another machine as the active machine. activate_new_machine = (self._global_container_stack and self._global_container_stack.getId() == machine_id) + stacks = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(id = machine_id) + if not stacks: + return + ExtruderManager.getInstance().removeMachineExtruders(stacks[0].getBottom().getId()) + current_settings_id = machine_id + "_current_settings" containers = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(id = current_settings_id) for container in containers: