mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Add sanity check for GlobalStack CURA-5045
This commit is contained in:
parent
5a194bb6d1
commit
00d8427e42
4 changed files with 24 additions and 5 deletions
|
@ -402,7 +402,8 @@ class ExtruderManager(QObject):
|
||||||
|
|
||||||
# Register the extruder trains by position
|
# Register the extruder trains by position
|
||||||
for extruder_train in extruder_trains:
|
for extruder_train in extruder_trains:
|
||||||
self._extruder_trains[global_stack_id][extruder_train.getMetaDataEntry("position")] = extruder_train
|
extruder_position = extruder_train.getMetaDataEntry("position")
|
||||||
|
self._extruder_trains[global_stack_id][extruder_position] = extruder_train
|
||||||
|
|
||||||
# regardless of what the next stack is, we have to set it again, because of signal routing. ???
|
# regardless of what the next stack is, we have to set it again, because of signal routing. ???
|
||||||
extruder_train.setParent(global_stack)
|
extruder_train.setParent(global_stack)
|
||||||
|
|
|
@ -153,6 +153,23 @@ class GlobalStack(CuraContainerStack):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
## Perform some sanity checks on the global stack
|
||||||
|
# Sanity check for extruders; they must have positions 0 and up to machine_extruder_count - 1
|
||||||
|
def isValid(self):
|
||||||
|
container_registry = ContainerRegistry.getInstance()
|
||||||
|
extruder_trains = container_registry.findContainerStacks(type = "extruder_train", machine = self.getId())
|
||||||
|
|
||||||
|
machine_extruder_count = self.getProperty("machine_extruder_count", "value")
|
||||||
|
extruder_check_position = set()
|
||||||
|
for extruder_train in extruder_trains:
|
||||||
|
extruder_position = extruder_train.getMetaDataEntry("position")
|
||||||
|
extruder_check_position.add(extruder_position)
|
||||||
|
|
||||||
|
for check_position in range(machine_extruder_count):
|
||||||
|
if str(check_position) not in extruder_check_position:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
## private:
|
## private:
|
||||||
global_stack_mime = MimeType(
|
global_stack_mime = MimeType(
|
||||||
|
|
|
@ -6,6 +6,7 @@ import time
|
||||||
#Type hinting.
|
#Type hinting.
|
||||||
from typing import List, Dict, TYPE_CHECKING, Optional
|
from typing import List, Dict, TYPE_CHECKING, Optional
|
||||||
|
|
||||||
|
from UM.ConfigurationErrorMessage import ConfigurationErrorMessage
|
||||||
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
||||||
from UM.Signal import Signal
|
from UM.Signal import Signal
|
||||||
|
|
||||||
|
@ -165,8 +166,6 @@ class MachineManager(QObject):
|
||||||
if active_machine_id != "" and ContainerRegistry.getInstance().findContainerStacksMetadata(id = active_machine_id):
|
if active_machine_id != "" and ContainerRegistry.getInstance().findContainerStacksMetadata(id = active_machine_id):
|
||||||
# An active machine was saved, so restore it.
|
# An active machine was saved, so restore it.
|
||||||
self.setActiveMachine(active_machine_id)
|
self.setActiveMachine(active_machine_id)
|
||||||
# Make sure _active_container_stack is properly initiated
|
|
||||||
ExtruderManager.getInstance().setActiveExtruderIndex(0)
|
|
||||||
|
|
||||||
def _onOutputDevicesChanged(self) -> None:
|
def _onOutputDevicesChanged(self) -> None:
|
||||||
self._printer_output_devices = []
|
self._printer_output_devices = []
|
||||||
|
@ -357,6 +356,10 @@ class MachineManager(QObject):
|
||||||
return
|
return
|
||||||
|
|
||||||
global_stack = containers[0]
|
global_stack = containers[0]
|
||||||
|
if not global_stack.isValid():
|
||||||
|
# Mark global stack as invalid
|
||||||
|
ConfigurationErrorMessage.getInstance().addFaultyContainers(global_stack.getId())
|
||||||
|
return # We're done here
|
||||||
ExtruderManager.getInstance().setActiveExtruderIndex(0) # Switch to first extruder
|
ExtruderManager.getInstance().setActiveExtruderIndex(0) # Switch to first extruder
|
||||||
self._global_container_stack = global_stack
|
self._global_container_stack = global_stack
|
||||||
Application.getInstance().setGlobalContainerStack(global_stack)
|
Application.getInstance().setGlobalContainerStack(global_stack)
|
||||||
|
|
|
@ -56,8 +56,6 @@ class MachineSettingsAction(MachineAction):
|
||||||
if self._isEmptyDefinitionChanges(definition_changes_id):
|
if self._isEmptyDefinitionChanges(definition_changes_id):
|
||||||
return
|
return
|
||||||
|
|
||||||
self._container_registry.removeContainer(definition_changes_id)
|
|
||||||
|
|
||||||
def _reset(self):
|
def _reset(self):
|
||||||
if not self._global_container_stack:
|
if not self._global_container_stack:
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue