Remove container stack and user profile for extruders when removing a printer

CURA-1896
This commit is contained in:
fieldOfView 2016-07-12 10:53:50 +02:00
parent a7cfe1b5af
commit ae4beeb0ed
2 changed files with 17 additions and 1 deletions

View File

@ -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):

View File

@ -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: