From eb401defdf21b26f5ee153eb933a74696634a2a5 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 9 Sep 2019 14:21:28 +0200 Subject: [PATCH] Add deprecated marker on extruders: Use extruderList Extruders is dangerous because it's a dict of which the values are randomly ordered. The keys are often cast to int so you can't use anything else than integer numbers. And then they are often cast back so if you're not properly counting from 0 you're also in trouble. So please, only use the list. Eventually we can switch the data structure around. --- cura/Settings/GlobalStack.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cura/Settings/GlobalStack.py b/cura/Settings/GlobalStack.py index 7efc263180..bead31b4e4 100755 --- a/cura/Settings/GlobalStack.py +++ b/cura/Settings/GlobalStack.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018 Ultimaker B.V. +# Copyright (c) 2019 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. from collections import defaultdict @@ -8,7 +8,7 @@ import uuid from PyQt5.QtCore import pyqtProperty, pyqtSlot, pyqtSignal -from UM.Decorators import override +from UM.Decorators import deprecated, override from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase from UM.Settings.ContainerStack import ContainerStack from UM.Settings.SettingInstance import InstanceState @@ -61,12 +61,13 @@ class GlobalStack(CuraContainerStack): # # \return The extruders registered with this stack. @pyqtProperty("QVariantMap", notify = extrudersChanged) + @deprecated("Please use extruderList instead.", "4.4") def extruders(self) -> Dict[str, "ExtruderStack"]: return self._extruders @pyqtProperty("QVariantList", notify = extrudersChanged) def extruderList(self) -> List["ExtruderStack"]: - result_tuple_list = sorted(list(self.extruders.items()), key=lambda x: int(x[0])) + result_tuple_list = sorted(list(self._extruders.items()), key=lambda x: int(x[0])) result_list = [item[1] for item in result_tuple_list] machine_extruder_count = self.getProperty("machine_extruder_count", "value")