From b4949a164c887ca09bd4d8e6ed34f124ec0430bd Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 6 Jul 2017 14:17:01 +0200 Subject: [PATCH] WIP: Add temporary fix to make materials work with 2.7 version upgrade CURA-3975 This is a temporary fix to make materials work with 2.7 version upgrade because of the setting_version change from 1 to 2. This MUST be fixed after we have decided on how to determine the versions of an XMLMaterialProfile. --- plugins/XmlMaterialProfile/XmlMaterialProfile.py | 4 ++++ plugins/XmlMaterialProfile/XmlMaterialUpgrader.py | 4 ++++ plugins/XmlMaterialProfile/__init__.py | 2 ++ 3 files changed, 10 insertions(+) diff --git a/plugins/XmlMaterialProfile/XmlMaterialProfile.py b/plugins/XmlMaterialProfile/XmlMaterialProfile.py index 04fc09019b..9319280119 100644 --- a/plugins/XmlMaterialProfile/XmlMaterialProfile.py +++ b/plugins/XmlMaterialProfile/XmlMaterialProfile.py @@ -36,6 +36,10 @@ class XmlMaterialProfile(InstanceContainer): # \param xml_version: The version number found in an XML file. # \return The corresponding setting_version. def xmlVersionToSettingVersion(self, xml_version: str) -> int: + if xml_version == "1.3": + return 2 # FIXME & HACK: This is temporary hack. The setting_version has been increased in CuraApplication, + # but we haven't decided on how to determine the versions of an XMLMaterialProfile yet. + # This MUST be fixed after the decision has been made. if xml_version == "1.3": return 1 return 0 #Older than 1.3. diff --git a/plugins/XmlMaterialProfile/XmlMaterialUpgrader.py b/plugins/XmlMaterialProfile/XmlMaterialUpgrader.py index ad20a44c28..140c0712a3 100644 --- a/plugins/XmlMaterialProfile/XmlMaterialUpgrader.py +++ b/plugins/XmlMaterialProfile/XmlMaterialUpgrader.py @@ -20,6 +20,10 @@ class XmlMaterialUpgrader(VersionUpgrade): return version * 1000000 + setting_version def _xmlVersionToSettingVersion(self, xml_version: str) -> int: + if xml_version == "1.3": + return 2 # FIXME & HACK: This is temporary hack. The setting_version has been increased in CuraApplication, + # but we haven't decided on how to determine the versions of an XMLMaterialProfile yet. + # This MUST be fixed after the decision has been made. if xml_version == "1.3": return 1 return 0 #Older than 1.3. diff --git a/plugins/XmlMaterialProfile/__init__.py b/plugins/XmlMaterialProfile/__init__.py index 63ec979fbd..3effe702be 100644 --- a/plugins/XmlMaterialProfile/__init__.py +++ b/plugins/XmlMaterialProfile/__init__.py @@ -20,6 +20,8 @@ def getMetaData(): }, "version_upgrade": { ("materials", 1000000): ("materials", 1000001, upgrader.upgradeMaterial), + # FIXME: This needs to be changed once we have decided on how to determine the versions + ("materials", 1000001): ("materials", 1000002, upgrader.upgradeMaterial), }, "sources": { "materials": {