Handle the startup situation where there is no global stack. Fixed a bug where the wrong stack was used instead of the first extruder.

Contributes to CURA-2477 Profile menu should only contain valid options for all materials
This commit is contained in:
Simon Edwards 2016-09-28 15:56:10 +02:00
parent 7b7c161d93
commit 062611a92a

View File

@ -18,6 +18,9 @@ class ProfilesModel(InstanceContainersModel):
# See UM.Settings.Models.InstanceContainersModel._fetchInstanceContainers().
def _fetchInstanceContainers(self):
global_container_stack = Application.getInstance().getGlobalContainerStack()
if global_container_stack is None:
return []
global_machine_definition = global_container_stack.getBottom()
extruder_stacks = ExtruderManager.getInstance().getActiveExtruderStacks()
@ -26,7 +29,7 @@ class ProfilesModel(InstanceContainersModel):
# Determine the common set of quality types which can be
# applied to all of the materials for this machine.
quality_type_dict = self.__fetchQualityTypeDictForStack(global_container_stack, global_machine_definition)
quality_type_dict = self.__fetchQualityTypeDictForStack(extruder_stacks[0], global_machine_definition)
common_quality_types = set(quality_type_dict.keys())
for stack in extruder_stacks[1:]:
next_quality_type_dict = self.__fetchQualityTypeDictForStack(stack, global_machine_definition)