Only get quality-changes fields for quality-changes profiles

And make the upgrade more robust against weird input, too.

Contributes to issue CURA-8510.
This commit is contained in:
Ghostkeeper 2021-09-24 16:32:38 +02:00
parent a08a5625d2
commit ef568ce622
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A

View file

@ -73,9 +73,9 @@ class VersionUpgrade411to412(VersionUpgrade):
# Update user-made quality profiles of flsun_sr printers to use the flsun_sr-specific qualities instead of the # Update user-made quality profiles of flsun_sr printers to use the flsun_sr-specific qualities instead of the
# global ones as their base # global ones as their base
file_base_name = os.path.basename(filename) # Remove any path-related characters from the filename file_base_name = os.path.basename(filename) # Remove any path-related characters from the filename
old_definition = parser["general"]["definition"] if file_base_name.startswith("flsun_sr_") and parser["metadata"].get("type") == "quality_changes":
old_quality_type = parser["metadata"]["quality_type"] if "general" in parser and parser["general"].get("definition") == "fdmprinter":
if file_base_name.startswith("flsun_sr") and old_definition == "fdmprinter" and parser["metadata"]["type"] == "quality_changes": old_quality_type = parser["metadata"].get("quality_type", "normal")
parser["general"]["definition"] = "flsun_sr" parser["general"]["definition"] = "flsun_sr"
parser["metadata"]["quality_type"] = self._flsun_quality_type_mapping.get(old_quality_type, "normal") parser["metadata"]["quality_type"] = self._flsun_quality_type_mapping.get(old_quality_type, "normal")