Added way to dynamicly set loading order

This is to ensure that Global stacks are loaded before extruders, so once the extruders are deseralized, they can always find the next (global) stack

CURA-3497
This commit is contained in:
Jaime van Kessel 2017-05-03 09:54:00 +02:00
parent 58ab9dcd09
commit 8d80f20db7
2 changed files with 15 additions and 0 deletions

View file

@ -38,6 +38,10 @@ class ExtruderStack(CuraContainerStack):
# For backward compatibility: Register the extruder with the Extruder Manager # For backward compatibility: Register the extruder with the Extruder Manager
ExtruderManager.getInstance().registerExtruder(self, stack.id) ExtruderManager.getInstance().registerExtruder(self, stack.id)
@classmethod
def getLoadingPriority(cls) -> int:
return 3
## Overridden from ContainerStack ## Overridden from ContainerStack
# #
# It will perform a few extra checks when trying to get properties. # It will perform a few extra checks when trying to get properties.
@ -64,6 +68,13 @@ class ExtruderStack(CuraContainerStack):
return self.getNextStack()._getMachineDefinition() return self.getNextStack()._getMachineDefinition()
@override(CuraContainerStack)
def deserialize(self, contents: str) -> None:
super().deserialize(contents)
stacks = ContainerRegistry.getInstance().findContainerStacks(id=self.getMetaDataEntry("machine", ""))
if stacks:
self.setNextStack(stacks[0])
extruder_stack_mime = MimeType( extruder_stack_mime = MimeType(
name = "application/x-cura-extruderstack", name = "application/x-cura-extruderstack",
comment = "Cura Extruder Stack", comment = "Cura Extruder Stack",

View file

@ -40,6 +40,10 @@ class GlobalStack(CuraContainerStack):
def extruders(self) -> list: def extruders(self) -> list:
return self._extruders return self._extruders
@classmethod
def getLoadingPriority(cls) -> int:
return 2
## Add an extruder to the list of extruders of this stack. ## Add an extruder to the list of extruders of this stack.
# #
# \param extruder The extruder to add. # \param extruder The extruder to add.