From 4bdc819f129061b5554c27fde120bba1a42469c0 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 6 Sep 2019 17:15:45 +0200 Subject: [PATCH] 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. --- cura/Machines/ContainerTree.py | 6 +++--- tests/Machines/TestContainerTree.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cura/Machines/ContainerTree.py b/cura/Machines/ContainerTree.py index eb2ed7d159..12a77083c4 100644 --- a/cura/Machines/ContainerTree.py +++ b/cura/Machines/ContainerTree.py @@ -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 diff --git a/tests/Machines/TestContainerTree.py b/tests/Machines/TestContainerTree.py index e82ce2384d..ed54774acd 100644 --- a/tests/Machines/TestContainerTree.py +++ b/tests/Machines/TestContainerTree.py @@ -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