Fix activating another container stack when the currently active stack is removed

CURA-1632
This commit is contained in:
fieldOfView 2016-06-05 13:54:55 +02:00
parent 8b294fbe97
commit ead91db062

View file

@ -405,11 +405,13 @@ class MachineManagerModel(QObject):
@pyqtSlot(str)
def removeMachine(self, machine_id):
# If the machine that is being removed is the currently active machine, set another machine as the active machine
if self._global_container_stack and self._global_container_stack.getId() == machine_id:
containers = UM.Settings.ContainerRegistry.getInstance().findContainerStacks()
if containers:
Application.getInstance().setGlobalContainerStack(containers[0])
activate_new_machine = (self._global_container_stack and self._global_container_stack.getId() == machine_id)
UM.Settings.ContainerRegistry.getInstance().removeContainer(machine_id)
if activate_new_machine:
stacks = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(type = "machine")
if stacks:
Application.getInstance().setGlobalContainerStack(stacks[0])
@pyqtProperty(bool, notify = globalContainerChanged)
def hasMaterials(self):