Return empty extruder list if no global stack

Just about every call of this function (except 2) would break when this returns None. The signature also says it doesn't return None. Let's return an empty list instead.

Contributes to issue CURA-5045.
This commit is contained in:
Ghostkeeper 2018-03-27 09:28:19 +02:00
parent 6d3fed8f52
commit bd4aba2572
No known key found for this signature in database
GPG Key ID: 5252B696FB5E7C7A
2 changed files with 11 additions and 13 deletions

View File

@ -366,7 +366,7 @@ class ExtruderManager(QObject):
def getActiveExtruderStacks(self) -> List["ExtruderStack"]:
global_stack = Application.getInstance().getGlobalContainerStack()
if not global_stack:
return None
return []
result = []
if global_stack.getId() in self._extruder_trains:

View File

@ -509,12 +509,11 @@ class MachineManager(QObject):
result = {}
active_stacks = ExtruderManager.getInstance().getActiveExtruderStacks()
if active_stacks is not None: # If we have extruder stacks
for stack in active_stacks:
material_container = stack.material
if not material_container:
continue
result[stack.getId()] = material_container.getId()
for stack in active_stacks:
material_container = stack.material
if not material_container:
continue
result[stack.getId()] = material_container.getId()
return result
@ -961,12 +960,11 @@ class MachineManager(QObject):
result = {}
active_stacks = ExtruderManager.getInstance().getActiveExtruderStacks()
if active_stacks is not None:
for stack in active_stacks:
variant_container = stack.variant
position = stack.getMetaDataEntry("position")
if variant_container and variant_container != self._empty_variant_container:
result[position] = variant_container.getName()
for stack in active_stacks:
variant_container = stack.variant
position = stack.getMetaDataEntry("position")
if variant_container and variant_container != self._empty_variant_container:
result[position] = variant_container.getName()
return result