From 93467dc29f4adeb8e606ee130dc2fa1f1411550d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 5 Nov 2018 17:28:36 +0100 Subject: [PATCH] Ensure that weeding out the duplicates doesn't mess up the order CURA-5898 --- cura/Machines/QualityManager.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cura/Machines/QualityManager.py b/cura/Machines/QualityManager.py index 60a6820772..fc8262de52 100644 --- a/cura/Machines/QualityManager.py +++ b/cura/Machines/QualityManager.py @@ -1,7 +1,7 @@ # Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. -from typing import TYPE_CHECKING, Optional, cast, Dict, List +from typing import TYPE_CHECKING, Optional, cast, Dict, List, Set from PyQt5.QtCore import QObject, QTimer, pyqtSignal, pyqtSlot @@ -264,8 +264,10 @@ class QualityManager(QObject): if fallback_ids: root_material_id_list.extend(fallback_ids) - root_material_id_list = list(set(root_material_id_list)) # Weed out duplicates + # Weed out duplicates while preserving the order. + seen = set() # type: Set[str] + root_material_id_list = [x for x in root_material_id_list if x not in seen and not seen.add(x)] # type: ignore # Here we construct a list of nodes we want to look for qualities with the highest priority first. # The use case is that, when we look for qualities for a machine, we first want to search in the following