Browse Source

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.
Ghostkeeper 5 years ago
parent
commit
eb401defdf
1 changed files with 4 additions and 3 deletions
  1. 4 3
      cura/Settings/GlobalStack.py

+ 4 - 3
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")