mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-21 13:47:51 -06:00
Fix crash when adding a machine without materials
CURA-6775
This commit is contained in:
parent
2b4144386f
commit
830b22e381
1 changed files with 5 additions and 3 deletions
|
@ -27,6 +27,9 @@ class BaseMaterialsModel(ListModel):
|
|||
|
||||
self._application = CuraApplication.getInstance()
|
||||
|
||||
self._available_materials = {} # type: Dict[str, MaterialNode]
|
||||
self._favorite_ids = set() # type: Set[str]
|
||||
|
||||
# Make these managers available to all material models
|
||||
self._container_registry = self._application.getInstance().getContainerRegistry()
|
||||
self._machine_manager = self._application.getMachineManager()
|
||||
|
@ -60,9 +63,6 @@ class BaseMaterialsModel(ListModel):
|
|||
self.addRoleName(Qt.UserRole + 15, "container_node")
|
||||
self.addRoleName(Qt.UserRole + 16, "is_favorite")
|
||||
|
||||
self._available_materials = None # type: Optional[Dict[str, MaterialNode]]
|
||||
self._favorite_ids = set() # type: Set[str]
|
||||
|
||||
def _updateExtruderStack(self):
|
||||
global_stack = self._machine_manager.activeMachine
|
||||
if global_stack is None:
|
||||
|
@ -122,6 +122,8 @@ class BaseMaterialsModel(ListModel):
|
|||
|
||||
# Update the available materials (ContainerNode) for the current active machine and extruder setup.
|
||||
global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
|
||||
if not global_stack.hasMaterials:
|
||||
return # There are no materials for this machine, so nothing to do.
|
||||
extruder_stack = global_stack.extruders.get(str(self._extruder_position))
|
||||
if not extruder_stack:
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue