Fix nondetermistic result with dictionary values list

Because global_stack.extruders.values can be returned in any order, the configurations matching with the lists doesn't always give a result.
It happened to work on my computer with the test, but there is no guarantee of that.

This is probably also going wrong in other places. I don't think we should use the .extruders property anywhere really!

Contributes to issue CURA-6600.
This commit is contained in:
Ghostkeeper 2019-09-06 17:15:45 +02:00
parent d618f2df71
commit 4bdc819f12
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276
2 changed files with 5 additions and 5 deletions

View file

@ -53,9 +53,9 @@ class ContainerTree:
global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
if global_stack is None:
return {}
variant_names = [extruder.variant.getName() for extruder in global_stack.extruders.values()]
material_bases = [extruder.material.getMetaDataEntry("base_file") for extruder in global_stack.extruders.values()]
extruder_enabled = [extruder.isEnabled for extruder in global_stack.extruders.values()]
variant_names = [extruder.variant.getName() for extruder in global_stack.extrudersList]
material_bases = [extruder.material.getMetaDataEntry("base_file") for extruder in global_stack.extrudersList]
extruder_enabled = [extruder.isEnabled for extruder in global_stack.extrudersList]
return self.machines[global_stack.definition.getId()].getQualityGroups(variant_names, material_bases, extruder_enabled)
## Get the quality changes groups available for the currently activated

View file

@ -19,8 +19,8 @@ def createMockedStack(definition_id: str):
extruder_right_mock.variant.getName = MagicMock(return_value = definition_id + "_right_variant_name")
extruder_right_mock.material.getMetaDataEntry = MagicMock(return_value = definition_id + "_right_material_base_file")
extruder_right_mock.isEnabled = True
extruder_dict = {"1": extruder_right_mock, "0": extruder_left_mock}
result.extruders = extruder_dict
extruder_list = [extruder_left_mock, extruder_right_mock]
result.extrudersList = extruder_list
return result