Override getConfigurationTypeFromSerialized for GlobalStack

CURA-3975

GlobalStack has metadata type "machine", which is different from what is
registered in the VersionUpgradeManager "machine_stack". This commit
makes sure that Cura can find the correct upgrade route for the
GlobalStack files.
This commit is contained in:
Lipu Fei 2017-07-06 10:22:36 +02:00
parent 42858b4715
commit 3d48024a47

View file

@ -1,7 +1,7 @@
# Copyright (c) 2017 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher.
from typing import Any, Dict
from typing import Any, Dict, Optional
from PyQt5.QtCore import pyqtProperty
@ -42,6 +42,17 @@ class GlobalStack(CuraContainerStack):
def getLoadingPriority(cls) -> int:
return 2
def getConfigurationTypeFromSerialized(self, serialized: str) -> Optional[str]:
configuration_type = None
try:
parser = self._readAndValidateSerialized(serialized)
configuration_type = parser["metadata"].get("type")
if configuration_type == "machine":
configuration_type = "machine_stack"
except Exception as e:
Logger.log("e", "Could not get configuration type: %s", e)
return configuration_type
## Add an extruder to the list of extruders of this stack.
#
# \param extruder The extruder to add.